ChartView with a circular buffer?
-
I've got a Quick Controls 2 chartView, in which I'd like to show the last 10 seconds of data from a running operation.
Adding on to my line series is fairly easy:
property int count:0 onMyValueChanged: { var parameterValue = value; myChartLineSeries.append(count,parameterValue); count++; }
But I can't figure out how to remove the oldest element in the line series when a new one is appended. Is there any easy way to do this without copying all the values in the LineSeries?
-
When you want to do this sort of bounded charts, you must pay attention to:
- How many points (x,y) you want to have in the Chart. I call it range.
- You must take care about the sample periodo to refresh your data. In this case, we call it x
- The axis and series data must be disengaged from the Chartview in ValueAxis and LineSeries components.
So, in a period you must realize each refresh.
// Here we bounded te data, removing the first element if(lineseries.count > range){ lineseries.remove(0) } // Append new values lineseries.append(x, y) //we establish the new min limit of x axis to the first value of the data axisX.min = lineseries.at(0).x // if the data have values, we establish the last value to max Limit in X axis if(lineseries.count > 1){ axisX.max = lineseries.at(lineseries.count - 1).x }
This code works for me. Any question is welcome.
-
hi
I am also wants to use this kind of logic
When I give idaxisX.min = idLine.at(0),it is showing Error: Cannot assign QPointF to doubleI wants to plot chart for every 1 second and the time should be the x axis label(the data is fetching from middleware )total 6 points have to show.
Regards
Divya -
hi
I am also wants to use this kind of logic
When I give idaxisX.min = idLine.at(0),it is showing Error: Cannot assign QPointF to doubleI wants to plot chart for every 1 second and the time should be the x axis label(the data is fetching from middleware )total 6 points have to show.
Regards
Divya@drd1988on Ok, you are right, it seems I forgot the x in the line
axisX.min = lineseries.at(0).x
Does this solution work for you?
-
@drd1988on Ok, you are right, it seems I forgot the x in the line
axisX.min = lineseries.at(0).x
Does this solution work for you?
-
@drd1988on impressive chart! Congratulations!
I am thinking about your application, I think that level of detail you are not going to reach it only with qml. Maybe you must customize your own chart component using c++. Sincerely I do not know how to do it, but when you do it, can you post your solution? Kind regards.
-
@drd1988on impressive chart! Congratulations!
I am thinking about your application, I think that level of detail you are not going to reach it only with qml. Maybe you must customize your own chart component using c++. Sincerely I do not know how to do it, but when you do it, can you post your solution? Kind regards.