-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d37502f
commit b001363
Showing
1 changed file
with
7 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,14 @@ | ||
"""Test app""" | ||
|
||
from dash import Dash, html, clientside_callback, Output, Input | ||
import dash_bootstrap_components as dbc | ||
import vizro | ||
import vizro.models as vm | ||
import vizro.plotly.express as px | ||
from vizro import Vizro | ||
|
||
app = Dash(__name__, external_stylesheets=[dbc.icons.FONT_AWESOME, vizro.bootstrap]) | ||
|
||
color_mode_switch = html.Span( | ||
[ | ||
dbc.Label(className="fa fa-moon", html_for="switch"), | ||
dbc.Switch(id="switch", value=False, className="d-inline-block ms-1"), | ||
dbc.Label(className="fa fa-sun", html_for="switch"), | ||
] | ||
) | ||
|
||
app.layout = dbc.Container( | ||
[ | ||
html.H3(["Bootstrap Light Dark Color Modes Demo"], className="bg-primary p-2"), | ||
color_mode_switch, | ||
] | ||
page = vm.Page( | ||
title="foo", components=[vm.Graph(figure=px.scatter(data_frame=px.data.iris(), x="sepal_width", y="sepal_length"))] | ||
) | ||
|
||
clientside_callback( | ||
""" | ||
(switchOn) => { | ||
switchOn | ||
? document.documentElement.setAttribute('data-bs-theme', 'light') | ||
: document.documentElement.setAttribute('data-bs-theme', 'dark') | ||
return window.dash_clientside.no_update | ||
} | ||
""", | ||
Output("switch", "id"), | ||
Input("switch", "value"), | ||
) | ||
dashboard = vm.Dashboard(pages=[page]) | ||
|
||
if __name__ == "__main__": | ||
app.run_server(debug=True) | ||
Vizro().build(dashboard).run() |