Skip to main content
Senior
January 3, 2025
Solved

Dynamic Graph Scrolling clear failure

  • January 3, 2025
  • 4 replies
  • 2539 views

I have a dynamic graph set to scrolling. When I call graph.clear(); it will set the initial graph back to my range 0-100, but once it starts scrolling it instantly jumps to the last highest value being the start of the new range instead of continuing scrolling.

EX: Graphing is as expected to x = 200. Clear. Normal graphing 0-100. Once scroll starts, jumps to range 200-300 and starts graphing at x = 300

0-200 : clear : 0-100 : 200-300 (graph and scrolling starting at 300)

Best answer by JTP1

Hello

It seems to be bug on the GraphScroll.cpp, this dataCounter- variable is not cleared.

void GraphScrollData::clear()
{
 DynamicDataGraph::clear();
 current = 0;
 dataCounter=0; // ADD THIS LINE
}

This source file is located \Middlewares\ST\touchgfx\framework\source\touchgfx\widgets\graph\ folder.

However, it is not compiled there, so copy it to \TouchGFX\gui\src\common\ -folder, for example.Then add this one line to clear- function.

Hope this helps

Br JTP

 

 

4 replies

GaetanGodart
Technical Moderator
January 13, 2025

Hello @EthanMankins ,

 

I am having trouble understand the problem exactly.

Could you share your project and share some screen shots of the issue?

 

Regards,

Senior
January 13, 2025

Hi @GaetanGodart ,

I am unable to share the project due to business constraints. 

I Currently have worked around the issue by using goToScreen, but just going to the current screen to reload the entire Screen and values.

I have attached some pictures I just made that replicate the issue.

 

normal scrolling actionnormal scrolling action

Normal Scrolling action

graph.clear()

graph.clear() Normal plotting untill x =100graph.clear() Normal plotting untill x =100

Normal plotting action until x = 100 (whenever scrolling action resumes)

 

graph2.png

Once scrolling action starts, x-axis jumps to the last greatest x-value(200) as lowest x range value with the whole range full

GaetanGodart
Technical Moderator
January 23, 2025

Hello @EthanMankins ,

 

I will report the issue with the team.

Can you tell me the steps to reproduce the issue?
(You can share the project in private message if that is ok with you).

 

Regards,

JTP1Best answer
Graduate II
January 14, 2025

Hello

It seems to be bug on the GraphScroll.cpp, this dataCounter- variable is not cleared.

void GraphScrollData::clear()
{
 DynamicDataGraph::clear();
 current = 0;
 dataCounter=0; // ADD THIS LINE
}

This source file is located \Middlewares\ST\touchgfx\framework\source\touchgfx\widgets\graph\ folder.

However, it is not compiled there, so copy it to \TouchGFX\gui\src\common\ -folder, for example.Then add this one line to clear- function.

Hope this helps

Br JTP

 

 

GS1
Senior III
August 10, 2025

Hello,

I have the same issue, but with the Dynamic Behaviour "Wrap and Clear".

When calling .clear() it clears the graphline, but the x-scaling keeps on counting up. I already implemented the "dataCounter=0" for my other scrolling graph which works fine, but I can't find how to reset the scaling to start at 0 when clear() is callend for the Wrap & Clear graphics. (As I have 5 graph lines, I need to use the "Wrap &clear" behaviour instead of the scrolling option due to heavy CPU load then.)

Any help for the "Wrap & Clear" is very much appreciated!

 

BR GS

 

Graduate II
August 10, 2025

Hello GS1

Ok, so it seems to be. In this case you must edit GraphWrapAndClear.cpp file. 

Like in Scroll-mode, at WrapAndClear-mode graph we also need to clear dataCounter when clear function is called.

However, after that change we cannot call GraphWrapAndClearData::clear() function when graph is full. So we must also manipulate GraphWrapAndClearData::beforeAddValue() function as well.

So Copy GraphWrapAndClear.cpp from \Middlewares\ST\touchgfx\framework\source\touchgfx\widgets\graph\ folder to \TouchGFX\gui\src\common\ -folder, for example.

Then manipulate clear and beforeAddValue functions like this:

void GraphWrapAndClearData::clear()
{
	// add this line
	dataCounter=0;
	
 invalidateAllXAxisPoints();
 DynamicDataGraph::clear();
}

void GraphWrapAndClearData::beforeAddValue()
{
 if (usedCapacity >= maxCapacity)
 {
		// comment out call of 'clear' from this class, because it would now clear the dataCounter as well
		// Datacounter clearing is not needed when page is full, because we want to keep X value counting
 //clear();
		
		// Add these two lines to 
		invalidateAllXAxisPoints();
		DynamicDataGraph::clear();
		
 }
}

 

Hope this helps. I'll attach also edited version of this file, it can be just copied to \TouchGFX\gui\src\common\ folder of your project.

BTW It seems that WrapAndOverwrite-mode has the same type bug, I'll check it some other day.

Br JTP

GaetanGodart
Technical Moderator
February 3, 2025

Hello @EthanMankins and @JTP1 ,

 

I will notify the team and together we will determine the appropriate approach to ensure a seamless experience for the users.

 

Regards,

Graduate II
February 3, 2025

Hello Gaetan

If you need, I can make example which repeats the problem.

Br JTP

GaetanGodart
Technical Moderator
February 3, 2025

Hej @JTP1 ,

 

That is kind of you but I have made one myself already, find it attached.

 

Regards,