cancel
Showing results for 
Search instead for 
Did you mean: 

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

Soda
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

6 REPLIES 6
franck23
Senior

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

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?

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

Soda
Associate II

Many thanks Alexandre. Actually, the dynamic graph is a new widget and needs more time for developing some of the features in the future, and I'm glad to hear you will keep me updated!:smiling_face_with_smiling_eyes:

Hello @Soda​ ,

​

I know it's been a while and I'm sorry for this, but I didn't forget you ^^

A new static Graph will finally be released with the next version of TouchGFX 4.19 that should be out around next month :D

Let's see then if it matches your needs

Best regards,

Alexandre

Soda
Associate II

Good news to hear from you!:smiling_face_with_smiling_eyes: For sure, I will try in the TouchGFX next version 4.19.

Thank you.