Add source example files
This commit is contained in:
24
source/plotting/dash/simple_dashboard.py
Normal file
24
source/plotting/dash/simple_dashboard.py
Normal file
@ -0,0 +1,24 @@
|
||||
import dash
|
||||
import pandas as pd
|
||||
from dash import Dash, html, dash_table, dcc
|
||||
from plotly.express import line
|
||||
|
||||
|
||||
data = pd.read_excel("france-communes.xlsx")
|
||||
dept = data.groupby("departement").sum("population")
|
||||
app = Dash("demo")
|
||||
app.layout = html.Div(children=[
|
||||
html.H1(children="Dashboard"),
|
||||
dash_table.DataTable(data=data.to_dict("records"), page_size=10),
|
||||
dcc.Graph(id="dept-population", figure=line(dept, x=None, y="population")),
|
||||
dcc.Dropdown(id="color-select", options=["#ff0000", "#00ff00"])
|
||||
])
|
||||
|
||||
|
||||
@app.callback(dash.Output("dept-population", "figure"), dash.Input("color-select", "value"))
|
||||
def update_dept_population(color):
|
||||
return line(dept, x=None, y="population", color_discrete_sequence=[color])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
Reference in New Issue
Block a user