Important: Please read the Qt Code of Conduct -

How to update QML chart during runtime ?

  • I found this link in this forum. It works fine after integrating into my application. But i am not able to add data during runtime and not able to display it.

    1. In QMLChartData.Js
      How to push data to the variable data.
    var ChartLineData = {
          labels: ["January","February","March","April","May","June","July","January","February","March","April","May","June","July"],
        datasets: [{
            fillColor : "rgba(220,220,220,0.2)",
            strokeColor : "rgba(220,220,220,1)",
            pointColor : "rgba(220,220,220,1)",
            pointStrokeColor : "#fff",
            pointHighlightFill : "#fff",
            pointHighlightStroke : "rgba(220,220,220,1)",
            **data **: [20,20,40,50,4,35,100,200]

    Since i have imported and binded like this
    import "QMLChartData.js" as ChartsData
    property var chartLineData: ChartsData.ChartLineData
    //push new data;// It says cannot call method push of undefined.

    But I am able to push data to labels.
    but not able to display it on the graph even though i called reqeustPaint().Any help please. I just want to draw a line graph based on the data from cpp side.Any example would be really helpful. Thanks

Log in to reply