Reset Graph X Values
- November 9, 2020
- 18 replies
- 5269 views
I'm using the dynamic graph to represent a small dataset. The data is acquired all at once through a back-end process, leaving me with an array of around 1000 datapoints. Once acquisition is complete, I use the following code to refresh the graph.
graphWidget.clear();
for (int i = 0; i < size; i++) {
graphWidget.addDataPoint(yValues[i]);
}
graphWidget.invalidate();This works sort-of, however the X value labels also increment by size. I want them to restart from 0. I assumed .clear() would do this, but apparently not.
How can I reset the graph and labels back to a fully empty state, such that I can explicitly get labels starting from 0 again? Attached photo shows current (undesirable) behavior.
Solved. Thanks @Vladimir
Open AbstractDataGraph.hpp and scroll down to the AbstractDataGraphWithY class definition, around line 995. Add the following method to the HPP file.
void dataCounterReset() { dataCounter = 0; }In your View code, call the method to reset the x-axis labels.
