Interactive Pie Charts in Dash

Hi there, I’m new to Dash and have run into some issues with making an interactive Pie Chart. Hopefully some kind soul can help me out!

I don’t seem to be able to get a Pie chart generated by the following sequence of events:

app.layout = html.Div(dcc.Graph(id = ‘Pie’), Some radiobutton with id=‘Pie_selector’)

@app.callback(dash.dependencies.Output(‘Pie’, ‘figure’),[dash.dependencies.Input(‘Pie_selector’, ‘value’)]
def update_figure(pie):
if pie == ‘x’:
piedata = go.Pie(values=[1,2,3], labels=[‘a’,‘b’,‘c’])
return {
‘data’: piedata
}

I’ve done the same process for scatterplots and boxplots and they all work fine. I’ve also used the display_content function to throw up a pie chart (from an answer on the forum) but while I can get it to display, this pie chart is not interactive. My Plotly version is 2.4.0.

Would really appreciate the help! Apologies, I’m not sure how to use the Markdown to show my code

Try

return {'data': [piedata]}
1 Like

Thanks for the quick reply Chris! I’m not sure what went wrong but I’ve got it working now. Will come back later to update here when I figure out what was wrong previously.

Really Thank you! I was trying to understand what is going wrong for an hour!