-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Tidy] Move figure layout dashboard overrides into a template #662
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…move-graph-layout-to-template
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! 🚀 Very satisfying to see some of the code go 😄
It's all good from my side. I didn't manually test anything, but if the unit tests and screenshots tests have passed + the scratch example looks fine, it should be all good!
…e-graph-layout-to-template # Conflicts: # vizro-core/examples/scratch_dev/app.py # vizro-core/src/vizro/models/_components/graph.py # vizro-core/src/vizro/models/_dashboard.py # vizro-core/tests/unit/vizro/actions/test_on_page_load_action.py # vizro-core/tests/unit/vizro/models/_components/test_graph.py # vizro-core/tests/unit/vizro/models/test_dashboard.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the code and the tests refactoring. ⚡ It will be much easier to maintain themes with these changes.
Here's a screenshot of the scratch dev app. Are we satisfied with the current margins and padding? The reason I ask is that the titles of the graphs, those with subtitles, seem to be positioned too far from the top border of their container. Do you think we should adjust this spacing?
Great observation @petar-qb, thanks for the careful testing 👍 My guess this is because the
Unless @huong-li-nguyen thinks otherwise then I'd say we just leave it how it is because we're going to be removing the whole |
Just leave it as is. It's really icky to get this right, because the graph.title is coming from Plotly so the normal margin / padding specifications don't apply as if this were a completely new html container 😅 So 7px is just a guess. It's not pitch-perfect. I don't think many people use subtitles anyway and as @antonymilne says, I'll change that very soon anyway. |
Description
Completely closes
https://github.com/McK-Internal/vizro-internal/issues/1208. This should now be the last thing we need to do on graph templates 🥳
Now that templates are moving entirely to the clientside there's a much cleaner way to apply the figure layout updates:
fig.layout
so there's no need to do theif fig.layout.property is None
check.vizro_light
andvizro_dark
are unchanged and still optimised for use outside dashboards. Now we merge in a new themedashboard_template_overrides
when they're applied in the dashboard. User changes tovizro_light/dark
are still maintained since we just merge the extradashboard_template_overrides
on top of them. The newdashboard_template_overrides
is not public and so not registered inpio.templates
vizro_light/dark + dashboard_template_overrides
is optimised for charts with no titles, so that all the weird custom logic that altersfig.layout
now only applies when atitle
is set. This will probably be removed soon.This is just refactoring. Nothing should have changed here either inside or outside dashboard.
@huong-li-nguyen please could you double check I didn't change anything accidentally here? As I understand it, this should be the behaviour both before and after this PR:
Standalone chart
Chart in dashboard with no title
Same as standalone chart except
title_pad_l, title_pad_r, margin_l, margin_t
different:Chart in dashboard with title and no subtitle
Same as chart in dashboard with no title except
title_pad_t = 7
.Chart in dashboard with title and no subtitle
Same as chart in dashboard with no title except
margin_t = 64
(what it was in standalone chart)Screenshot
Notice
I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":