Skip to content

Legend rank per pie slice#7723

Open
my-tien wants to merge 3 commits intoplotly:masterfrom
my-tien:pie-legendrank-array
Open

Legend rank per pie slice#7723
my-tien wants to merge 3 commits intoplotly:masterfrom
my-tien:pie-legendrank-array

Conversation

@my-tien
Copy link
Contributor

@my-tien my-tien commented Mar 4, 2026

This PR makes it possible to pass arrays to the pie property 'legendrank' so that legend rank assignment can be configured per slice.

Changes:

Previously, traces.pie.legendrank only accepted one value that applied for all slices. With this PR, slice legend entries can be individually ranked in the legend. E.g. the below JSON would produce the displayed chart:

{
  "data": [
    {
      "type": "pie",
      "values": [1, 2, 3, 4, 5],
      "labels": ["E", "D", "C", "B", "A"],
      "legendrank": [5, 4, 3, 2, 1]
    }
  ],
  "layout": {
    "width": 500,
    "height": 400,
    "legend": {
      "title": {
        "text": "A legend"
      }
    }
  }
}

image

Note:

This feature is not expected to work when pie values are not set.

Disclaimer I am required to add that…

the software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. in no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

Each entry then corresponds to one slice.
@my-tien my-tien marked this pull request as draft March 4, 2026 15:00
@my-tien my-tien marked this pull request as ready for review March 4, 2026 15:58
@my-tien
Copy link
Contributor Author

my-tien commented Mar 4, 2026

Hi guys, I'm not sure if the failed baselines-b64 test is related to my changes. It seems that the legendrank array doesn't take effect there?

Expected output (and actual output for the baseline test):

image

output for baselines-b64 test (note incorrect legend entry order):
image

@emilykl emilykl self-requested a review March 4, 2026 16:54
@emilykl emilykl assigned emilykl and unassigned my-tien Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants