Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Dynamic ChartView updating



  • In my program data for chart are producing in c++ and the QML function is called like this

    QMetaObject::invokeMethod(view.rootObject(), "readValues", Qt::DirectConnection,
                Q_ARG(QVariant, QVariant::fromValue(list)));
    
    

    then data series are appended in readValues function

    Item{
        id: chart
        ChartView {
            id: chartView
            width: parent.width
            height: parent.height
            theme: ChartView.ChartThemeLight
            antialiasing: true
            legend.visible: false
    
            ValueAxis {
                id: axisX
                titleText: "D   N   I"
                labelsFont: Qt.font({pointSize: 12, bold: true})
                min: 0
                max: 200
                tickCount: 21
                labelFormat: "%.0f"
            }
    
            ValueAxis {
                id: axisY
                labelsFont: Qt.font({pointSize: 12, bold: true})
                min: 0
                max: 14000
                tickCount: 8
                labelFormat: "%.0f"
            }
    
            LineSeries {
                id: infectedSeries
                axisX: axisX
                axisY: axisY
                color: "blue"
                width: 4
            }
        }
    
        function readValues(collection)
        {
            for (var i = 0; i < collection.length; i++)
            {
                infectedSeries.append(i, collection[i]);
                console.log("Array item:   " + i + "   val  " + collection[i]);
            }
            // chartView.update();
        }
    }
    
    

    There is no effect on chart. It is strange because on the console logs are printed properly

    Thank you in advance


Log in to reply