Skip to content

fix: pie: Don't sort, keep order. Keep color order constant.#7295

Merged
knsv merged 1 commit intomermaid-js:developfrom
daym:bug/5899_pie_retain_slice_order
Mar 3, 2026
Merged

fix: pie: Don't sort, keep order. Keep color order constant.#7295
knsv merged 1 commit intomermaid-js:developfrom
daym:bug/5899_pie_retain_slice_order

Conversation

@daym
Copy link

@daym daym commented Jan 6, 2026

📑 Summary

This keeps the order of the pie slices in the order their values were ordered in the input. Since we still filter out small slices, make sure this doesn't shift colors either.

Resolves #5899

📏 Design Decisions

  • Keep order of the pie slices in the order their values were ordered in the input.
  • Keep using up colors even if the slice is filtered out as < 1%. That way all following colors dont shift just because something dropped below 1%

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added necessary unit/e2e tests.
  • 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
  • 🦋 If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

@changeset-bot
Copy link

changeset-bot bot commented Jan 6, 2026

⚠️ No Changeset found

Latest commit: d31993f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the Type: Bug / Error Something isn't working or is incorrect label Jan 6, 2026
@netlify
Copy link

netlify bot commented Jan 6, 2026

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit d31993f
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/695d1a3eb8751f000886ceac
😎 Deploy Preview https://deploy-preview-7295--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 6, 2026

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/examples@7295

mermaid

npm i https://pkg.pr.new/mermaid-js/mermaid@7295

@mermaid-js/layout-elk

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-elk@7295

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-tidy-tree@7295

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/mermaid-zenuml@7295

@mermaid-js/parser

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/parser@7295

@mermaid-js/tiny

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/tiny@7295

commit: d31993f

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.57%. Comparing base (d5bc07d) to head (d31993f).
⚠️ Report is 263 commits behind head on develop.

Files with missing lines Patch % Lines
packages/mermaid/src/diagrams/pie/pieRenderer.ts 0.00% 7 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #7295      +/-   ##
==========================================
- Coverage     3.57%   3.57%   -0.01%     
==========================================
  Files          473     474       +1     
  Lines        47475   47489      +14     
  Branches       734     734              
==========================================
  Hits          1696    1696              
- Misses       45779   45793      +14     
Flag Coverage Δ
unit 3.57% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/mermaid/src/diagrams/pie/pieRenderer.ts 0.70% <0.00%> (-0.02%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@argos-ci
Copy link

argos-ci bot commented Jan 6, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 👍 Changes approved 8 changed Jan 6, 2026, 2:31 PM

Copy link
Member

@sidharthv96 sidharthv96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR updates the rendering to match our documentation, which is great.

Image

It would be good to have a follow-up PR to add a config to set sorting order, so people who need different ordering can enable it via frontmatter.

---
config:
  pie:
    sortBy: 'value' | undefined
---
...

@knsv knsv added this pull request to the merge queue Mar 3, 2026
Merged via the queue into mermaid-js:develop with commit 975ce08 Mar 3, 2026
23 checks passed
@mermaid-bot
Copy link

mermaid-bot bot commented Mar 3, 2026

@daym, Thank you for the contribution!
You are now eligible for a year of Premium account on MermaidChart.
Sign up with your GitHub account to activate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug / Error Something isn't working or is incorrect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pie slices aren't sorted by their label as claimed by docs

3 participants