Black Lives Matter. Please consider donating to Black Girls Code today.

How do I disable pie percentage text

How to I disable this percentage indicator.I want the pie chat to look more clean.I want to add the percentages to the legend if that is possible?

Here is the code I have written for this pie chart so far

fig = go.Figure(data=[go.Pie(labels=labels, values=values)] )
title_text=‘Message Type Distrubution Pie Chart’, # title of plot

print("updated Channel Distrabution")
return fig

Instead of setting textinfo = ‘values’, set it = ‘none’.

Do you know how to add the percentage from the text info to the legend?

I am not sure what you mean?
You want to have the data from the pie chart shown as a legend?

Looking at the documentation for a Pie Chart, the legend takes a dictionary-object as a legend.
You could format your data as a dictionary and then feed it into the legend.

   legend = {'Position report': str(data[0]), 'Standard classB': str(data[1]), 'etc.. etc...'}

Ok so i performed the percentage calculation and append it to the label list.

Records = cur.fetchall()
for item in Records:
if item[0] == None:
total = sum(MessageCount)
for x in Records:

        if x[0] == None:
            MessageType.append(str(x[0]+" "+str(round(percentage,2))+"%"))

    labels = MessageType

1 Like

Looks awesome. :slight_smile:

Thank you for posting your full solution to the forum by the way. It might help in the future. :smile: