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.
2020-11-23 10:00 PM
I am using the following workaround:
1. After adding points using addDataPoint(), the dataCounter field of the AbstractDataGraphWithY class is incremented. In this class, I have added a dataCounterReset () function that zeroes out the dataCounter.
2. Before adding points to dynamicGraph, I called the dataCounterReset () function.
2. Then, in the properties of Middlewares / ST / touchgfx, unchecked the "Exclude resource from assembly build" checkbox and compiled the project.
I also did not find another way.
2020-11-15 10:44 PM
Hi Michael,
Did you find how to solve it? I have the same issue, i tried different approaches but without success.
2020-11-20 03:12 PM
Hi, no luck yet unfortunately.
2020-11-23 10:00 PM
I am using the following workaround:
1. After adding points using addDataPoint(), the dataCounter field of the AbstractDataGraphWithY class is incremented. In this class, I have added a dataCounterReset () function that zeroes out the dataCounter.
2. Before adding points to dynamicGraph, I called the dataCounterReset () function.
2. Then, in the properties of Middlewares / ST / touchgfx, unchecked the "Exclude resource from assembly build" checkbox and compiled the project.
I also did not find another way.
2020-11-26 06:40 PM
Thank you, this worked for me. Hopefully ST implements this as an official feature in the next release.
Edit: the exact thing that worked was adding the following code to the public section of the AbstractDataGraphWithY class declaration in AbstractDataGraph.hpp:
void dataCounterReset() { dataCounter = 0; }
Line 994 on my system. I didn't have to exclude any resources from the build. Make a note wherever you use it to remind yourself to add it back in every time you update TouchGFX.
2021-04-05 11:00 PM
I second this proposal, this is quite common application
2021-04-05 11:01 PM
Hi @Vladimir ,
Do you have the code snippet please?
2021-04-06 03:46 AM
Where should I download the sample code you described?
2021-04-06 04:39 AM
2021-04-06 04:39 AM