Skip to main content
Michael K
Senior III
November 9, 2020
Solved

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.

This topic has been closed for replies.
Best answer by Vladimir1

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.

18 replies

GPa.1
Associate II
November 16, 2020

Hi Michael,

Did you find how to solve it? I have the same issue, i tried different approaches but without success.

Michael K
Michael KAuthor
Senior III
November 20, 2020

Hi, no luck yet unfortunately.

Embedded UI/UX Consulting: cadenza.design
Vladimir1
Vladimir1Best answer
Visitor II
November 24, 2020

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.

Michael K
Michael KAuthor
Senior III
November 27, 2020

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.

Embedded UI/UX Consulting: cadenza.design
BParh.1
Senior III
April 6, 2021

I second this proposal, this is quite common application

BParh.1
Senior III
April 7, 2021

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?

Vladimir1
Visitor II
April 7, 2021

 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

April 9, 2021

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
April 10, 2021

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