Hello, I am a student studying Plotly-dash in Korea.
I wrote the new code using one example from the plotly-dash gallery.
But the app.callback of this code doesn’t work at all.
I want the pie graph updated by the multi selector.
So I wrote a number of additional functions.
All the data required for the graph were normally imported.
I really want to solve this problem…
And this is my code.
this is part of dropdown and dcc.graph
html.Div(
[
html.H6(children=‘취득자 수’,className=“subtitle padded”),
dcc.Dropdown(
id = ‘drop_down’,
options=drop_down_options,
multi=True,
value=list(DROP_DOWN.keys()),
className=“dcc_control”,
),
dcc.Graph(id=‘my-div3’)
],
className=“seven columns”,
)
this is part of app.callback
@app.callback(
Output(component_id = ‘my-div2’,component_property = ‘figure’),
[Input(component_id = ‘drop_down’, component_property = ‘value’)],
)
def update_pie(drop_down_value):for i in range(len(drop_down_value)): if(drop_down_value[i] == 'age0'): drop_down_value[i] = '0' elif(drop_down_value[i] == 'age10'): drop_down_value[i] = '10' elif(drop_down_value[i] == 'age20'): drop_down_value[i] = '20' elif(drop_down_value[i] == 'age30'): drop_down_value[i] == '30' elif(drop_down_value[i] == 'age40'): drop_down_value[i] == '40' elif(drop_down_value[i] == 'age50'): drop_down_value[i] == '50' elif(drop_down_value[i] == 'age60'): drop_down_value[i] == '60' elif(drop_down_value[i] == 'age70'): drop_down_value[i] == '70' elif(drop_down_value[i] == 'age80'): drop_down_value[i] == '80' elif(drop_down_value[i] == 'age90'): drop_down_value[i] == '90' dff = filter_dataframe(df, drop_down_value) edu, life, house, medic = produce_pie_data(dff) data = [ go.Pie( labels = ['기초교육','기초생계','기초주거','기초의료'], values = [edu,life,house,medic], name = '원그래프', hoverinfo="text+value+percent", textinfo="label+percent+name", hole=0.5, marker=dict(colors=["#fac1b7", "#a9bb95", "#92d8d8"]) ) ] layout_pie["title"] = "취득자 수" layout_pie["font"] = dict(color="#777777") layout_pie["legend"] = dict( font=dict(color="#CCCCCC", size="10"), orientation="h", bgcolor="rgba(0,0,0,0)" ) figure = dict(data=data, layout=layout_pie) return figure
plz help me…