Skip to main content
Soda
Associate II
March 22, 2021
Solved

How to graph widget can persist the data point when changing the screen?

  • March 22, 2021
  • 1 reply
  • 1892 views

I've adopted the Dynamic Graph widget on my application but when I change the screen from Graph screen to another screen, the data point of the Dynamic Graph widget will free all the data points due to the MVP of TouchGFX will release all resource on the presenter and view objects when changing the screen to another screen.

Now, I store the Graph data points in the Model, and when the screen has transited to the Graph screen, I will copy all data points in the Model to Dynamic Graph widget by using addDataPoint() function but the execution time when copying data from Model to the Dynamic Graph widget has consumed too high (I want to avoid this). 

In practically, how can I make the data points statically or making a pointer to point to static data points when changing the screen?

This topic has been closed for replies.
Best answer by Alexandre RENOUX

Hi Soda,

Unfortunately passing an array of data to the Dynamic Graph is not possible. The reason is because it's a dynamic graph and not a static graph.

I think a static graph would match better what you are trying to do.

This widget is currently being made but I don't know the actual roadmap of it. I'll keep you updated when I get more information.

/Alexandre

1 reply

franck23
Associate III
March 22, 2021

Hi Soda,

when you change the screen, the previous screen is destroyed and the memory freed is reused for the new screen.

All data on the old screen are lost. this is to save memory space.

What you need to do is save the graph data in a static buffer in your application or in the model and then use the app->model->presenter->view system to repopulate the graph when the screen presenter gets activated.

Have a look at the Model-View-Presenter pattern, and there are several online tutorials on how to use it.

https://support.touchgfx.com/docs/development/ui-development/software-architecture/model-view-presenter-design-pattern

Soda
SodaAuthor
Associate II
March 23, 2021

Many thanks Franck23, for the suggestion. Actually, I store the graph data in the Model, but I need to avoid the copying process when the Dynamic Graph widget. Is there possible to avoid this by passing the graph data through to the Dynamic Graph object in the View by pointer instead of using addDataPoint() function?

Alexandre RENOUX
Alexandre RENOUXBest answer
Visitor II
March 23, 2021

Hi Soda,

Unfortunately passing an array of data to the Dynamic Graph is not possible. The reason is because it's a dynamic graph and not a static graph.

I think a static graph would match better what you are trying to do.

This widget is currently being made but I don't know the actual roadmap of it. I'll keep you updated when I get more information.

/Alexandre