2025-01-03 10:22 AM
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)
Solved! Go to Solution.
2025-08-10 9:13 AM
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
2025-08-10 10:07 AM - edited 2025-08-11 1:58 AM
Hi JTP,
thank you very much for this quick help! Now it works as I need it!
Have a nice evening
BR GS
2025-08-11 11:13 AM
Hi GS
Im glad to be able you help you.
If somebody is using WrapAndOverwrite- mode, then it is needed to manipulate GraphWrapAndOverwrite.cpp slightly to get clear- function work properly.
So copy it like at previous posts to \TouchGFX\gui\src\common\ -folder.
Then add two lines:
void GraphWrapAndOverwriteData::clear()
{
// add these two lines
dataCounter=0;
invalidateAllXAxisPoints();
DynamicDataGraph::clear();
current = 0;
}
After these changes, calling the clear-function from the user code should work.
Br JTP