2020-11-09 01:21 PM
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.
Solved! Go to Solution.
2021-04-06 07:43 AM
Thanks, but it gives this error
2021-04-06 07:55 AM
Did you add the dataCounterReset code in the AbstractDataGraph.cpp file?
2021-04-06 07:35 PM
It seems I have the same error as @mbagh.1 , and I already ensure I add add the dataCounterReset code in the AbstractDataGraph.cpp file
2021-04-06 07:42 PM
Anyway, how to do this:
"2. Then, in the properties of Middlewares / ST / touchgfx, unchecked the "Exclude resource from assembly" checkbox and compiled the project."
Any SW tool to uncheck this option?
2021-04-06 10:17 PM
Unfortunately, I used the stm32cubeide program. Perhaps AbstractDataGraph files are not included in the assembly.
2021-04-07 01:05 AM
It seems there was a mistake in my comment. If I remember correctly, it was necessary to uncheck this checkbox in the project properties(stm32cubeide).
2021-04-07 06:11 AM
Try just adding it to the hpp file as below. It's a one-liner and I didn't need to exclude anything from the build.
2021-04-09 02:09 PM
I did not understand this part
2. Then, in the properties of Middlewares / ST / touchgfx, unchecked the "Exclude resource from assembly build" checkbox and compiled the project.
2021-04-09 07:30 PM
Hi @mbagh.1 , I think what @Vladimir meant was that he needed to exclude particular code folder which was touchgfx designer related to make the project in Cube IDE able to build.
However in my case, to resolve the issue in this forum, it is suffice as what @Michael K summarize
"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; }