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)