mckinsey / vizro

Vizro is a toolkit for creating modular data visualization applications.
https://vizro.readthedocs.io/en/stable/
Apache License 2.0
2.46k stars 109 forks source link

[Tidy] Update Graph theme using clientside_callback #523

Closed petar-qb closed 2 weeks ago

petar-qb commented 2 weeks ago

Description

The PR addresses two issues:

After a little investigation into the overlay style issue, I found that removing it would be a quick and easy fix for the unlovely grey background in the graphs that appears when the theme is changed. However, there is a better solution which idea comes from one old ticket #74 (that also is planned to be addressed in the actions v2 (Unstaged phase) process).

Here are some of the benefits that this PR brings:

Screenshot

Download videos and see visual difference:

from the main branch: https://github.com/mckinsey/vizro/assets/108530920/fd0905a7-80e5-4a76-bf78-d1fb11632a9c

from the tidy/update_graph_theme_clientside branch: https://github.com/mckinsey/vizro/assets/108530920/6baec66f-b1d7-4d72-af20-bc341c7ab502

Notice

maxschulz-COL commented 2 weeks ago

I started reviewing, but for me the theme switch does not work at all now for figures, see below screenshot:

image
huong-li-nguyen commented 2 weeks ago

I started reviewing, but for me the theme switch does not work at all now for figures, see below screenshot:

For me that worked - your hatch environment eventually still has to update to the latest dash version! I just got a bunch of id errors but the theme switch worked 😄

maxschulz-COL commented 2 weeks ago

One other question out of interest: I think previously we could change the graph theme mid animation (e.g. on the animated gapminder tutorial). That should still be possible right, because we are just changing the layout, not the entire object?

petar-qb commented 2 weeks ago

One other question out of interest: I think previously we could change the graph theme mid animation (e.g. on the animated gapminder tutorial). That should still be possible right, because we are just changing the layout, not the entire object?

You're right. The following JS code (that's added in this PR) enables exactly this Plotly.relayout(plotly_graph, { template: theme_to_apply });.