We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import pandas as pd import plotly.express as px import plotly.graph_objects as go from dash import Dash, dcc, html, Input, Output
app = Dash(name)
df = pd.read_csv("https://raw.githubusercontent.com/Coding-with-Adam/Dash-by-Plotly/master/Other/Dash_Introduction/intro_bees.csv")
df = df.groupby(['State', 'ANSI', 'Affected by', 'Year', 'state_code'])[['Pct of Colonies Impacted']].mean() df.reset_index(inplace=True) print(df[:5])
app.layout = html.Div([
html.H1("Web Application Dashboards with Dash", style={'text-align': 'center'}), dcc.Dropdown(id="slct_year", options=[ {"label": "2015", "value": 2015}, {"label": "2016", "value": 2016}, {"label": "2017", "value": 2017}, {"label": "2018", "value": 2018}], multi=False, value=2015, style={'width': "40%"} ), html.Div(id='output_container', children=[]), html.Br(), dcc.Graph(id='my_bee_map', figure={})
])
@app.callback( [Output(component_id='output_container', component_property='children'), Output(component_id='my_bee_map', component_property='figure')], [Input(component_id='slct_year', component_property='value')] ) def update_graph(option_slctd): print(option_slctd) print(type(option_slctd))
container = "The year chosen by user was: {}".format(option_slctd) dff = df.copy() dff = dff[dff["Year"] == option_slctd] dff = dff[dff["Affected by"] == "Varroa_mites"] fig = px.choropleth( data_frame=dff, locationmode='USA-states', locations='state_code', scope="usa", color='Pct of Colonies Impacted', hover_data=['State', 'Pct of Colonies Impacted'], color_continuous_scale=px.colors.sequential.YlOrRd, labels={'Pct of Colonies Impacted': '% of Bee Colonies'}, template='plotly_dark' ) return container, fig
if name == 'main': app.run_server(debug=True)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
from dash import Dash, dcc, html, Input, Output
app = Dash(name)
df = pd.read_csv("https://raw.githubusercontent.com/Coding-with-Adam/Dash-by-Plotly/master/Other/Dash_Introduction/intro_bees.csv")
df = df.groupby(['State', 'ANSI', 'Affected by', 'Year', 'state_code'])[['Pct of Colonies Impacted']].mean()
df.reset_index(inplace=True)
print(df[:5])
app.layout = html.Div([
])
@app.callback(
[Output(component_id='output_container', component_property='children'),
Output(component_id='my_bee_map', component_property='figure')],
[Input(component_id='slct_year', component_property='value')]
)
def update_graph(option_slctd):
print(option_slctd)
print(type(option_slctd))
if name == 'main':
app.run_server(debug=True)
The text was updated successfully, but these errors were encountered: