Plotly-Dash error

278 views
Skip to first unread message

GEETHANJALI S P

unread,
Apr 5, 2021, 8:47:12 AM4/5/21
to django...@googlegroups.com
Hi Guys,

I'm getting an error while executing the code...Please help me if anyone is aware of dash and plotly.
Thanks in advance.

#code:
getting error as.. Callback error updating the graph.figure

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

df = pd.read_csv("C:/Users/ganjali001/Documents/DEMO_NEW.csv")

app = dash.Dash(__name__)

#---------------------------------------------------------------
app.layout = html.Div([
html.Div([
html.Label(['Payment Details']),
dcc.Dropdown(
id='my_dropdown',
options=[
{'label': 'Commercial', 'value': 'COMMERCIAL'},
{'label': 'Medicare', 'value': 'MEDICARE'},
{'label': 'Medicaid', 'value': 'MEDICAID'},
{'label': 'Self Pay', 'value': 'SELF-PAY'},
{'label': 'Default', 'value': 'DEFAULT'}
],
value='SELF-PAY',
multi=False,
clearable=False,
style={"width": "50%"}
),
]),

html.Div([
dcc.Graph(id='the_graph')
]),

])

#---------------------------------------------------------------
@app.callback(
Output(component_id='the_graph', component_property='figure'),
[Input(component_id='my_dropdown', component_property='value')]
)

def update_graph(my_dropdown):
dff = df

piechart = px.pie(
data_frame=dff,
values='PaymentAmt',
names=my_dropdown,
color='FinancialClass', # differentiate markers (discrete) by color

title='Payments by Financial Class', # figure title
template='presentation', # 'ggplot2', 'seaborn', 'simple_white', 'plotly',

width=800, # figure width in pixels
height=600, # figure height in pixels
hole=0, # represents the hole in middle of pie
)

return (piechart)


if __name__ == '__main__':
app.run_server(debug=True, port=1200)

John Hughes

unread,
Apr 27, 2021, 9:04:31 AM4/27/21
to Django users
I get the same error - however when I remove the color= option the error disappears. Of course, then I don't get the chart that I need. 
Reply all
Reply to author
Forward
0 new messages