We are creating a custom visual in Power BI using plotly. Currently, by default, the legends are displayed in certain order and we need to allow the user to specify this legend display order in Power BI. Any inputs on how to write plotly code for this? Thanks in advance.
Legend items are listed in the same order as their corresponding items in
gd.data from top to bottom (with the exception of stack bars which are shown in reversed order by default).
You can reverse that order using
Unfortunately, we don’t offer a way to “fully” customize the legend ordering at the moment.
The ability to reorder legend items would be really helpful. I see that there’s the
category_orders) for plotly express, however that reorders the actual traces, which breaks my plot. So it doesn’t seem like it’s possible for me to re-order the legend.