feat(adapters): add a light and dark house theme - #137
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gives the Plotly renderer one house theme with a light and a dark mode. Before, the plots used the Plotly defaults, and a dark system showed white plots inside a dark page.
Change
ec6d15b).theme.cssholds one set of tokens in:rootand one in:root[data-fv-mode="dark"].plotly/theme.jsbuilds a Plotlylayout.templatefor each figure from the tokens, soupdate_layout()values still win.theme-mode.jsruns inline in<head>before the first paint: the mode comes from localStoragefv-mode, then the OS. A new Mode button in the toolbar cycles Auto, Light and Dark;ToolbarConfigcannot hide it. A switch redraws each figure insidefvRunProgrammaticPlotlyOp, so it sends no request and does not change the spec state.state.group_domainsstores stays right after a switch. Slots 7-8 are#9a8700and#8a8a8a(3.60 and 3.45:1 on white, 5.38 and 5.60:1 on#0b0e12).0117ca1). Light mode keepsopen-street-map. Dark mode uses the same OSM tile source with a MapLibre raster paint that inverts and desaturates the tiles. No CARTO tiles: free CARTO use needs a CARTO API key, and commercial use needs a paid license. The adapter no longer setsmap.stylein Python, so the template supplies it andupdate_layout(map={"style": ...})wins.d00aaa2). In dark mode,"Viridis"starts at#424086instead of#440154, so sparse cells stay visible. The colorbar uses the same scale.662aaab). A series hover label uses the neutral tooltip colors with a border in the series color. Linked-hover guides use ink on a light plot and paper on a dark one.72fde4b). In overlay mode, legend swatches no longer fade with the background layer.b366801).yaxis.automarginin the template: the left margin grows pastmargin.l=60only when a tick label does not fit.a3d803a). Toolbar and panel buttons use the page font.4b1c3e2,80fe9e3,25b8dca,6e1a74f).Architecture.md(theme section),docs/guides/customizing.md(new "Light and dark mode" section),CHANGELOG.md.edd6193: four theme browser test calls no longer pass"plotly"to the test helpers that refactor: remove the ECharts renderer #136 changed.cca4e35:_wait_for_initloses its unusedrendererargument in all four browser test files, also in the calls that fix(cube): brush binned sources on their own bin grid #134 added. TheCHANGELOG.mdconflict with fix(cube): brush binned sources on their own bin grid #134 keeps both entries.988ad95: a map in a figure with its owntemplategetsopen-street-mapwhen neither the layout nor that template setsmap.style. Before this fix, Plotly used its defaultbasicstyle, which loads CARTO tiles.8969d0b: a per-figure step, called bybuildTracesForFigure, sets the series border. It skips a figure that setshoverlabel.bordercolorin its layout or its own template. Before this fix, the border on the trace beat both.38db4e4: the template leaves out each key that the figure's ownfontsets, so the font reaches tick labels, axis titles, the title and the legend, as it does without a template. The hover label keeps the theme font.d1caf0d: anullor invalidfontortemplatecounts as unset. PythonNonearrives asnull. Before this fix,update_layout(font=None),font="serif"ortemplate=Noneon a map threw infvApplyThemewhile the bundle loaded, and the whole dashboard stayed blank.201e833:fvApplyThemeToTracesholds the per-trace theme parts (the dark Viridis and the series border) and skips a figure with its own template. Before this fix, the dark Viridis lift also reached such a figure. A mode switch no longer redraws a figure with its own template.ac00739: the linked-hover overlay takes the mode of its own figure's plot background (fvPlotSurfaceMode), so the guides use ink on a light plot and paper on a dark one. Before this fix, they followed the page mode: on a figure with its own template or aplot_bgcolorapart from the page mode, the contrast fell to about 1.12:1.280ddc3: afontkey set toNonekeeps the theme default. Before this fix,font={"size": None}set the title to 17 px instead of 14 px.Impact
update_layout()wins over the theme, also forfontandhoverlabel.bordercolor. A figure that sets its owntemplategets no house theme.template=Noneandfont=Nonecount as unset.plot_bgcolordiffers from the page mode.yaxis.automargin, the plot area moves when a tick label does not fit in 60 px. In the tests this happened only on an extreme y zoom.Checks
pytest tests flexviz_polars/tests(whatmake testruns): 2,397 passed, 2 skipped, 8 failed. The 8 are the line-envelope kernel tests of fix(cube): brush binned sources on their own bin grid #134: they fail the same way onmain, because the localflexviz-polarsbuild predates that kernel change. CI builds the plugin from source.pytest -m browser -p no:randomly tests(whatmake test-browserruns): 340 passed, with 17TestThemeBrowsertests.ruff format --check,ruff check flexviz tests,mkdocs build --strict,git diff --check: pass.