On Monday, 5 April 2021 at 22:47:12 UTC+10 geethanj...@gmail.com wrote:
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.figureimport 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)
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b5a53c1e-cb32-4d5d-8ff8-a6e6704eef69n%40googlegroups.com.
No comments:
Post a Comment