liorhe
Posts: 9
Joined: Mon Feb 26, 2024 2:36 am

Persist layout changes

Hi,

I'm looking into the dashboards library and I wasn't able to find documentation that may answer this use case.

When a user creates a dashboard, or updates the dashboard -
e.g. widget is resized, removed, or added
I would like to capture that event so that I can persist the layout on my server for the next time the user would like to view their dashboard.

Is that possible?

Thanks.
User avatar
dawid.d
Posts: 850
Joined: Thu Oct 06, 2022 11:31 am

Re: Persist layout changes

Hello,

Thanks for the question!

Yes, exporting settings based on which you can create a chart with the same settings is possible. Just call the getOptions method on the `board` object. See the demo below.

Demo: https://jsfiddle.net/gh/get/library/pur ... t-to-json/

Let me know if this is what you were looking for
Best regards!
Dawid Draguła
Highcharts Developer
liorhe
Posts: 9
Joined: Mon Feb 26, 2024 2:36 am

Re: Persist layout changes

Thank you Dawid, I appreciate the prompt response!

This is not exactly what I meant.
What you're proposing is that whenever I click on a button I'll persist the state.
I'm looking for an event that on any change in the layout I will persist the state, meaning when a user resizes a cell, I will immediately update the state in my server as well.
User avatar
dawid.d
Posts: 850
Joined: Thu Oct 06, 2022 11:31 am

Re: Persist layout changes

Oh, sorry for the misunderstanding. Basically, there is no single event responsible for capturing such behavior, but you can capture any event that is triggered every time the layout is changed (e.g. mouse up), compare whether the options are equal, and if not, send an update query.

Demo: https://jsfiddle.net/BlackLabel/jzvcah6g/

Hope it was useful.
Dawid Draguła
Highcharts Developer
liorhe
Posts: 9
Joined: Mon Feb 26, 2024 2:36 am

Re: Persist layout changes

Thank you, that's a good workaround to use!

In the future, is there any plan to add a functionality in the edit mode that is more responsive to changes?
Another example is that today when a user edits a chart they will see the change only after they confirm the change, meaning that they need to go through the configuration flow again to make fixes.
Back to the original question - having the ability to constantly update the state of the dashboard and charts, and persist them on changes will be a great user experience enhancement in my opinion.
User avatar
dawid.d
Posts: 850
Joined: Thu Oct 06, 2022 11:31 am

Re: Persist layout changes

I think it's a good idea for a feature. Would you like to describe it in more detail in a feature request on our GitHub? (here: https://github.com/highcharts/highchart ... new/choose) If you'd prefer me to do it, let me know.
Dawid Draguła
Highcharts Developer
liorhe
Posts: 9
Joined: Mon Feb 26, 2024 2:36 am

Re: Persist layout changes

Sure, happy to do it. Thank you!

Return to “Highcharts Dashboards”