-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_dash.py
44 lines (38 loc) · 1.16 KB
/
test_dash.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import plotly.express as px
import dash
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Input, Output
tips = px.data.tips()
col_options = [dict(label=x, value=x) for x in tips.columns]
dimensions = ["x", "y", "color", "facet_col", "facet_row"]
app = dash.Dash(
__name__, external_stylesheets=["https://codepen.io/chriddyp/pen/bWLwgP.css"]
)
server = app.server
app.layout = html.Div(
[
html.H1("Demo: Plotly Express in Dash with Tips Dataset"),
html.Div(
[
html.P([d + ":", dcc.Dropdown(id=d, options=col_options)])
for d in dimensions
],
style={"width": "25%", "float": "left"},
),
dcc.Graph(id="graph", style={"width": "75%", "display": "inline-block"}),
]
)
@app.callback(Output("graph", "figure"), [Input(d, "value") for d in dimensions])
def make_figure(x, y, color, facet_col, facet_row):
return px.scatter(
tips,
x=x,
y=y,
color=color,
facet_col=facet_col,
facet_row=facet_row,
height=700,
)
if __name__ == "__main__":
app.run_server(debug=True)