Greetings,
I am trying to to make the legend of a pie chart display in a set order, rather than in descending order.
I have checked other topics on this subject but all of them seem to have been abandoned without an answer being found.
I am aware of the operator legend_traceorder that is supposed to be used for this purpose.
However, specifying “traceorder: normal” leads to my data still being displayed in descending order.
It is my understanding that I could group my legend to achieve the desired effect, albeit in a roundabout fashion, but it seems that grouping a legend is only possible with other types of charts, not pie charts. Is there in fact some way to accomplish this with a pie chart?
Below is the code for a pie chart I copied from the reference site to use as an example.
I would want to have the legend display in the order “Residential, Non-residential, Utility”.
Thank you in advance for your assistance.
Any new information, or even confirmation that this is not possible, would be appreciated.
var data = [{
values: [19, 26, 55],
labels: ['Residential', 'Non-Residential', 'Utility'],
type: 'pie'
}];
var layout = {
height: 400,
width: 500
};
Plotly.newPlot('myDiv', data, layout);