Good evening there
I am glad to join your incredibly supportive community I am a beginner in this field of data science , any ways I have designed and deployed my first web app with dash but one my charts failed to display presumably because of my call back please examine this code and give me feed back @adamschroeder
@app.callback(
Output(“graph”, “figure”),
Input(“selection”, “value”))
def display_animated_graph(selection):
if selection==‘Trajectory of Pandemic’:
df[‘date’]=pd.to_datetime(df[‘date’], format=‘%Y-%m-%d’)
date=df[‘date’].dt.strftime(‘%Y-%m-%d’)
df_country=df.groupby([‘Countrycode’,‘Country’,‘date’]).sum().reset_index()
fig = px.choropleth(df_country, locations=“Countrycode”, color = “total_cases”,
hover_name= “Country”,animation_frame=date,
hover_data = df[[‘total_cases’,‘new_cases’,‘total_deaths’]],
color_continuous_scale=px.colors.sequential.Plasma)
fig.update_layout(transition={'duration':1000},paper_bgcolor='#000000',geo=dict(bgcolor= '#000000'),margin=dict(l=0,r=0,t=0,b=0))
fig.update_traces(marker_line_color='rgba(255,255,255,0)', selector=dict(type='choroplethmapbox'))
fig.layout.template='plotly_dark'
else:
df_country=df.groupby(['Countrycode','Country']).sum().reset_index()
yesterdays_date=df['date'].max()
fig = px.choropleth(df_country, locations="Countrycode", color = "total_cases",
hover_name= "Country",
hover_data = ['total_cases','new_cases','total_deaths'],
projection="orthographic",
color_continuous_scale=px.colors.sequential.OrRd_r)
fig.update_layout(paper_bgcolor='#000000',geo=dict(bgcolor= '#000000'),
title=f"Cumulative Cases since the start of pandemic untill {yesterdays_date}")
fig.layout.template='plotly_dark'
return fig
if name==‘main’:
app.run_server(debug=True, port=8000)
link to github repo GitHub - Datascientist88/Dash_Dashboard_COVID19_NO_ONE
thanks in advance