I have the following code. The plots are not being called. May someone help me see where I am getting the code wrong.
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import numpy as np
import pandas as pd
import plotly.graph_objs as go
import plotly.express as px
import plotly.io as pio
from plotly.colors import n_colors
from plotly.subplots import make_subplots
df=pd.read_csv("hire_merge.csv")
app = dash.Dash()
app.layout = html.Div([
html.Div([
dcc.Graph(id = "graph")
],className = 'nine columns'),
html.Div([
html.Br(),
html.Label(['Choose Pit:'],style={'font-weight': 'bold', "text-align": "center"}),
dcc.Dropdown(id = 'pit_drop',
options = [{'label':pit, 'value':pit} for pit in df['Pit'].unique()],
value = 'BON',
multi = False,
disabled=False,
clearable=True,
searchable=True,
placeholder='Choose Pit...',
className='form-dropdown',
style={'width':"90%"},
persistence='string',
persistence_type='memory'),
dcc.Dropdown(id= 'num_drop',
options = [{'label': metric_1, 'value' : metric_1} for metric_1 in df['Metric'].unique()],
value = 'Grade Control Model Insitu',
multi = False,
disabled=False,
clearable=True,
searchable=True,
placeholder='Choose Upper Metric..',
className='form-dropdown',
style={'width':"90%"},
persistence='string',
persistence_type='memory'),
dcc.Dropdown(id = 'den_drop',
options = [{'label':metric_2, 'value':metric_2} for metric_2 in df['Metric'].unique()],
value = 'Monthly Mine Plan Depletion (Latest Model)',
multi = False,
disabled=False,
clearable=True,
searchable=True,
placeholder='Choose Lower Metric..',
className='form-dropdown',
style={'width':"90%"},
persistence='string',
persistence_type='memory'),
])
####################Callbacks#######################
@app.callback(
Output("graph", "figure"),
[Input('pit_drop', 'value'),
Input('num_drop', 'value'),
Input('den_drop', 'value')
])
def update_graph(pit, metric_1, metric_2):
dfi=df.set_index(["Metric","Pit", "Date"])
dfi.xs(pit, level="Pit")
fig=(dfi.loc[metric_1, :]/dfi.loc[metric_2, :].replace(np.inf, 0)).plot()
return fig
app.run_server()