Spaces:
Runtime error
Runtime error
""" | |
Created on Wed Jul 26 14:46:06 2023 | |
@author: mritchey | |
""" | |
# Import packages | |
from dash import Dash, html, dash_table, dcc, callback, Output, Input | |
import pandas as pd | |
import plotly.express as px | |
# Incorporate data | |
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminder2007.csv') | |
# Initialize the app | |
app = Dash(__name__) | |
# App layout | |
app.layout = html.Div([ | |
html.Div(children='My First App with Data, Graph, and Controls'), | |
html.Hr(), | |
dcc.RadioItems(options=['pop', 'lifeExp', 'gdpPercap'], value='lifeExp', id='controls-and-radio-item'), | |
dash_table.DataTable(data=df.to_dict('records'), page_size=20), | |
dcc.Graph(figure={}, id='controls-and-graph') | |
]) | |
# Add controls to build the interaction | |
def update_graph(col_chosen): | |
fig = px.histogram(df, x='continent', y=col_chosen, histfunc='avg') | |
return fig | |
# Run the app | |
if __name__ == '__main__': | |
app.run(debug=True) |