I hate to keep posting about dash\plotly but I cant understand what is going wrong here. I have copied and pasted from the plotly site the code in order to display a pie chart with a drop down menu. When I create the dashboard there is a dropdown menu that shows all the categories but there is no pie chart to be seen. Please help me to understand what is going wrong. Code below:
import pandas as pd
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.express as px
# This dataframe has 244 lines, but 4 distinct values for `day`
url="https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBM-DS0321EN-SkillsNetwork/datasets/spacex_launch_dash.csv"
spacex_df=pd.read_csv(url)
spacex_df.rename(columns={'Launch Site':'Site'}, inplace=True)
app = dash.Dash(__name__)
app.layout = html.Div([
html.P("site-dropdown:"),
dcc.Dropdown(
id='Site',
value='Site',
options=[{'value': x, 'label': x}
for x in ['CCAFS LC-40', 'CCAFS SLC-40', 'KSC LC-39A', 'VAFB SLC-4E']],
clearable=False
),
dcc.Graph(id="pie-chart"),
])
@app.callback(
Output("pie-chart", "figure"),
[Input("Launch Site", "value")])
def generate_chart(Site, values):
fig = px.pie(spacex_df, values='Site', names='Site')
return fig
app.run_server()
