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)] )
fig.update_traces(hoverinfo=‘percent+value’,textinfo=‘value’)
fig.update_layout(
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 plot.ly 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.

fig.update_layout(
   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:
pass
else:
MessageCount.append(item[1])
total = sum(MessageCount)
for x in Records:

        if x[0] == None:
            pass
        else:
            percentage=float((x[1]/total)*100)
            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: