2025-05-07 12:55 PM - last edited on 2025-05-07 12:58 PM by Andrew Neil
Hi,
I'm trying to make a dynamic scroll graph such that the number of data points and x-axis scale changes when a user sets a value through a slider. The issue I'm running into is the inability to update the number of data points for when the graph scrolls (ie if scale is 30 min, then graph scrolls after 30 data points are added; if scale is 10 min, then graph scrolls after 10 data points are added).
Using the slider below, the user is able to pick a number of minutes between 1 and 30. I already have it so that the slider changes the x-axis scaling and labeling:
For example, if the slider changes the visible range to 10, the number of data points is still always set to 30. This causes the graph to not scroll until 30 data points have been plotted even if it's not shown on the graph.
Is there a way to change the number of data points (max capacity) through code? One thing I tried is within the touchgfx framework, I went into the graph widget folder and edited the AbstractDataGraph.hpp to add a setMaxCapacity function, but it doesn't work. Thank you for the help in advance!
2025-05-08 4:44 AM
Hello @tv9 ,
I don't understand why you are limited.
You already use your slider to set the label so you have a function that does that.
Now you can just "addDataPoint" x times to add x points.
If you want to add one point every second, then just sue the handleTickEvent function and a counter that you increment every tick until you reach 60, then you reset it and add a data point.
If my message does not help you, could you share your project and an animation of what you want to achieve?
regards,