Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to make the SplineSeries's appended values permanent?

How to make the SplineSeries's appended values permanent?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 154 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    ugurkebir
    wrote on last edited by
    #1

    I created an item called Chart. I put chartview and splineseries in it. Then I created Chart modules in another item and appended the chart values. But on page transition old splineseries values are lost and regenerated. That's why I can't see the old values in the chart. How can I make the SplineSeries's appended values permanent?

    Chart.qml:

    import QtQuick 2.12
    import QtCharts 2.3
    import "Global"
    
    Item {
        id: chartComponent
    
        property double xVal: 0.0
        property double yVal: 0.0
    
        Rectangle{
            id: temperatureChartRect
            //...
    
            Rectangle{
                id: temperatureChartHeader
                //...
                Text {
                    id: temperatureChartHeaderTxt
                    //...
                }
            }
    
            ChartView {
                id: temperatureChart
                //...
                clip: true
                antialiasing: true
                backgroundRoundness: 0.0
                legend.visible: false
    
                Rectangle{
                    id: rectang
                    //...
                }
    
                ValueAxis {
                    id: valueAxisY
                    min: yVal < 0 ? Math.min(yVal*1.2, 0) : yVal*0.5
                    max: Math.max(yVal*1.2, yVal)
                    tickCount: Math.min(temperatureChart.height/40, 25)
                }
                ValueAxis {
                    id: valueAxisX
                    min: 0
                    max: Math.max(xVal*1.2, xVal)
                    tickCount: Math.min(temperatureChart.width/40, temperatureChartSeries.count)
                }
    
                SplineSeries {
                    id: temperatureChartSeries
                    axisX: valueAxisX
                    axisY: valueAxisY
                    useOpenGL: true
                }
            }
        }
    
        onXValChanged : {
            temperatureChartSeries.append(xVal, yVal)
            console.log("SplineSeries count : ", temperatureChartSeries.count)
        }
    }
    

    someOther.qml (Callee qml):

    import QtQuick 2.12
    import QtQuick.Layouts 1.12
    import QtQuick.Controls 2.15
    import QtCharts 2.3
    import "Global"
    
    Item {
        id: remoteControlPage
        FontLoader { id: fontFamily; source: Style.fontFamilySource }
    
        //...
        //...
    
        property int timerCountQml: serialCommQml.timerCount
        property var sensorChartQml: serialCommQml.command.sensorChart
    
        Chart {        //Chart1
            id: pt100TempChart
            anchors.top: parent.top
            anchors.left: stateStatus.right
            anchors.leftMargin: 20
            width: Math.max(300, parent.width / 3)
            height: Math.max(250, parent.height/3)
            chartName: "PT100 Temperature"
    
            xVal:timerCountQml
            yVal: sensorChartQml.pt100Temp
        }
    
        Chart {        //Chart2
            //...
        }
    
        Chart {        //Chart3
            //...
        }
    
        Chart {        //Chart4
            //...
        }
    }
    

    Application Output:
    qml: SplineSeries count : 1 //Chart1
    qml: SplineSeries count : 1 //Chart2
    qml: SplineSeries count : 1 //Chart3
    qml: SplineSeries count : 1 //Chart4
    qml: SplineSeries count : 2
    qml: SplineSeries count : 2
    qml: SplineSeries count : 2
    qml: SplineSeries count : 2
    //...
    //...
    qml: SplineSeries count : 25
    qml: SplineSeries count : 25
    qml: SplineSeries count : 25
    qml: SplineSeries count : 25
    qml: GmtNavigationButton_QMLTYPE_7(0x55e0c0dc9d80) //page transition
    qml: SplineSeries count : 1
    qml: SplineSeries count : 1
    qml: SplineSeries count : 1
    qml: SplineSeries count : 1
    qml: SplineSeries count : 2
    qml: SplineSeries count : 2
    qml: SplineSeries count : 2
    qml: SplineSeries count : 2
    //...
    //...
    qml: GmtNavigationButton_QMLTYPE_7(0x55e0c0dc9d80) //page transition
    qml: SplineSeries count : 1
    qml: SplineSeries count : 1
    qml: SplineSeries count : 1
    qml: SplineSeries count : 1
    qml: SplineSeries count : 2
    qml: SplineSeries count : 2
    qml: SplineSeries count : 2
    qml: SplineSeries count : 2
    //...
    //...

    Screenshots:
    26 seconds of graphic display before page transition
    0ab3c69f-2586-45ed-a2d0-c68dcc91d3f6-image.png

    After 26 seconds the page transition took place and the data started to regenerate in 26 seconds. But the first 26 seconds of data was lost.
    db37806c-2611-4f4f-aa94-e8fc3554cd44-image.png

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved