Learn how to use Dash Bio for next-gen sequencing & quality control. 🧬 Register for the Oct 27 webinar.

Call back not working

Can someone help me to understand why I’m not getting the callback for the piechart ? :slight_smile:

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import pandas as pd

app = dash.Dash()

data2020 = data[data[‘Year’]==2020]

list1 = [‘OTP’,‘OTA’]

list2.sort()

app.layout = html.Div([

                html.Label('Select a Week'),
                dcc.Dropdown(id='demo-dropdown_2',
                options=[{'label': i, 'value': i} for i in range(40)],
                               style={'width': '48%'},
                            value=29),

                html.Label('Select a OTA/OTA'),
                dcc.Dropdown(id='demo-dropdown_3',
                options=[{'label': i, 'value': i} for i in list1],
                            style={'width': '48%'},
                            value='OTP'),





                dcc.Graph(id='pi-graph',
                            style={"width": "38%",'float': 'right', "display": "inline-block" })])

@app.callback(Output(‘pi-graph’, ‘fig’),
[Input(‘demo-dropdown_2’, ‘value’),
Input(‘demo-dropdown_3’, ‘value’)])

def update_figure(week,OTX):

cw = data2020[data2020['Week']== week]

total = len(cw)

if OTX == 'OTP':
    cwOTP = cw[['Origin Late Reason','Load ID']].dropna()
    values = cw.groupby(['Origin Late Reason']).count()
    
    fig = px.pie(values, values='Load ID', names=values.index,
        title='LTR used count to {}, about of {}% the total'.format(values.sum()[0],
        round(values.sum()[0]/total,2)))
    
    return fig

else:
    
    cwOTP = cw[['Destination Late Reason','Load ID']].dropna()
    values = cw.groupby(['Destination Late Reason']).count()
    
    fig = px.pie(values, values='Load ID', names=values.index,
        title='LTR used count to {}, about of {}% the total'.format(values.sum()[0],
        round(values.sum()[0]/total,2)))
    
    return fig

if name == ‘main’:
app.run_server()