cancel
Showing results for 
Search instead for 
Did you mean: 

Reset Graph X Values

Michael K
Senior III

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.

Embedded UI/UX Consulting: cadenza.design
18 REPLIES 18

Thanks, but it gives this error

0693W000008ymrPQAQ.jpg

Did you add the dataCounterReset code in the AbstractDataGraph.cpp file?

Embedded UI/UX Consulting: cadenza.design

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

0693W000008ypZsQAI.png 

BParh.1
Senior III

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?

Unfortunately, I used the stm32cubeide program. Perhaps AbstractDataGraph files are not included in the assembly.

Vladimir1
Associate II

 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). 0693W000008yqXdQAI.png

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.

Embedded UI/UX Consulting: cadenza.design
mbagh.1
Senior

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.

BParh.1
Senior III

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; }