When I select multi='False", I get blank chart. Please fix error in below code. I want only one input value in the drop down list and its corresponding data on the chart.
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objs as go
import pandas as pd
df = pd.read_csv("full_grouped.csv")
app = dash.Dash(__name__,)
app.layout = html.Div([
html.Div([
html.H1('Covid 19 Dashboard from 5/1/2020 - 7/28/2020')],
style={'text-align': 'center'
}),
html.Div([
dcc.Dropdown(id='countries_name',
multi=False,
clearable=True,
value='Afghanistan',
placeholder='Select Countries',
options=[{'label': c, 'value': c}
for c in (df['Country'].unique())])
], style={'width': '40%',
'margin-left': '30%',
# 'background-color': '#2EBECD'
}),
html.Div([
dcc.Graph(id='countries_new_cases',
config={'displayModeBar': True})
],style={'margin-left':'23%','margin-top':'1%'})
])
@app.callback(Output('countries_new_cases', 'figure'),
[Input('countries_name', 'value')])
def annual_by_country_barchart(states_usa):
return {
'data': [go.Bar(x=df[df['Country'] == c]['Date'],
y=df[df['Country'] == c]['New cases'],
textposition='auto',
name=c)
for c in states_usa],
'layout': go.Layout(
# title='List of States: ' + ', '.join(states_usa),
# plot_bgcolor='#323259',
# paper_bgcolor='#323259',
font={'family': 'Palatino'},
width=1050,
height = 520,
barmode='stack',
template='plotly_white',
yaxis=dict(
title='New Cases',
titlefont_size=18,
tickfont_size=14,
),
xaxis=dict(
title='Date',
titlefont_size=18,
tickfont_size=14,
),
)
}
if __name__ == '__main__':
app.run_server(debug=True)