cancel
Showing results for 
Search instead for 
Did you mean: 

Plotting large array of data in touchgfx graph

Josh_W020
Associate III

Hi,

I am trying to plot an array of 512 values in a dynamic graph in touchgfx. This is working as intended but I am experiencing poor performance. When in histogram mode the graph updates quickly however I wish to use line mode and when in this mode, the graph will take between two and three seconds to update. I'm aiming to get the graph to update in around one second. 

Any ideas on how to optimise the plotting of the graph. Perhaps the way in which the data is passed from Model.cpp into the screenView.cpp?

Currently I am passing the data through as such:

for(int i = 0; i < 512; i++)
{
    modelListener->UpdateGraph(i, graphData[i]);
}

Any help would be greatly appreciated.

Thanks.

6 REPLIES 6

@Josh_W020 wrote:

Any ideas on how to optimise the plotting of the graph. .


Do you really need to plot all the values?

eg, could you just plot every fourth? Maybe averaged?

Osman SOYKURT
ST Employee

Hello @Josh_W020 ,

Could you try to increase your canvas buffer and see if it's better?

Osman SOYKURT
ST Software Developer | TouchGFX

Tried doubling this from 12000 to 24000 but didn't see any difference.

Yes unfortunately its important that all values are plotted as it needs to be a high accuracy representation of a recorded frequency.

 

Osman SOYKURT
ST Employee

Hello @Josh_W020 ,

What is the size of your graph widget? Does it take up the entire size of your display?

This limitation is known to us, and to explain a bit, it's because a graph of 4 points in "Line" mode for instance, will in reality use more than 12 points that need to be calculated (and then some pixels are alpha blended if I recall correctly). In a histogram, it's much easier as the bottom part of the graph is known and easy to render (straight lines of pixels, no calculation is needed).

I have a suggestion that might help you. If you have not one but two graphs (the same), using "Area" as the mode and not Line or histogram, and you place the second graph on top of the first one with a small shift in the Y axis (and with background color/image), then you should be able to have the same visual as the "Line". From my measurements, it's three times more effective that way when rendered. Just a little downside, when there are curves with big gaps in the Y axis, then the line will not look as good as with "Line". To overcome this limitation, you can have your second graph look almost the same but also shift in X (some points you'll have to add 1, some points you'll subtract 1).


Hope this helps.

Osman SOYKURT
ST Software Developer | TouchGFX

Thats a good suggestion however as the graph will often need to plot high frequencies with large variation in y axis, i don't think the work around you suggested would be usable? 

 

Thanks anyway,

Josh