mermaid
mermaid copied to clipboard
Order pie chart slices clockwise by order of entries
:bookmark_tabs: Summary
Order pie chart slices clockwise by order of entries.
Resolves #3593
:straight_ruler: Design Decisions
Created an order
field on pie chart data and added a sorting rule to D3 pie
that sorts based on order
.
:clipboard: Tasks
Make sure you
- [x] :book: have read the contribution guidelines
- [ ] :computer: have added unit/e2e tests (if appropriate)
- [x] :bookmark: targeted
develop
branch
To clarify, since it wasn't immediately obvious to me, is this a passive change? Or is the label order now the definitive ordering and to achieve the previous behavior a user would have to list the labels in descending value?
That is correct. This change would make label order the definitive ordering.
I think this will be helpful.
The documentation for pie charts should also be updated so users understand this. Existing users might be surprised at their pie charts suddently being re-ordered.
I don't know what happened with the code in this issue, but it doesn't work.
pie title Pets adopted by volunteers
"Dogs" : 386
"Cats" : 85
"Rats" : 155
pie title Pets adopted by volunteers
"Dogs" : 386
"Cats" : 85
"Rats" : 155
Mermaid orders Rats second, so it sorts by value, not label.
Looks like the index sorting order got removed in https://github.com/mermaid-js/mermaid/commit/9563b221327e4ac50f87d9e14626c974e4852a13
I'm not sure if intentional or regression though since I don't have context for changes after this one
@Yokozuna59 help?
@jasmaa It has been re-added in 267935713c89b9316f0dd8750e9080072e78dcab.
It seems that it was intentional then? It would be nice if label/order sorting was possible, even if it's not the default.
If this feature will not be added back, the docs should at least be fixed, because currently they describe the previous situation.
There be tests added for this. That way this won't happen again. In general, if a feature is accidentally (or intentionally) removed or a bug is found, a test should be written for it so that the removal or bug does not ever happen again.
These tests ultimately save time and effort because they stop this kind of regression.
(Of course there should be tests written when the feature is originally added so this kind of regression never happens. )