Sentdiario / index.py
thak123's picture
Update index.py
e92aba2 verified
raw
history blame
915 Bytes
from dash import Dash, html, dcc, callback, Output, Input
from app import app
import pandas as pd
server = app.server
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminder_unfiltered.csv')
# def serve_content():
# """
# :return: html div component
# """
# return html.Div([
# dcc.Location(id='url', refresh=False),
# html.Div(id='page-content')
# ])
# app.layout = serve_content()
app.layout = html.Div([
html.H1(children='Title of Dash App', style={'textAlign':'center'}),
dcc.Dropdown(df.country.unique(), 'Canada', id='dropdown-selection'),
dcc.Graph(id='graph-content')
])
@callback(
Output('graph-content', 'figure'),
Input('dropdown-selection', 'value')
)
def update_graph(value):
dff = df[df.country==value]
return px.line(dff, x='year', y='pop')
if __name__ == '__main__':
app.run_server(debug=True)