Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pie Chart with % sum > 100% #3987

Open
NXML opened this issue Jan 13, 2023 · 6 comments · May be fixed by #5270
Open

Pie Chart with % sum > 100% #3987

NXML opened this issue Jan 13, 2023 · 6 comments · May be fixed by #5270
Labels
Area: Development Graph: Pie Internals: Renderer Status: Pending Is not to be executed as it currently is Type: Bug / Error Something isn't working or is incorrect

Comments

@NXML
Copy link

NXML commented Jan 13, 2023

Description

On mermaid.live, when i put this diagram

pie title Pets adopted by volunteers "Dogs" : 80 "Cats" : 86 "Rats" : 80
Percentages are 33% , 35% and, 33% , the sum of these percentages are 101%,
That is not correct

Steps to reproduce

Go to https://mermaid.live/edit#pako:eNo9z00LwjAMBuC_EnLeYSeRXt1VEL3mEtc4i2s72lQYY__d-jFzCg8vvMmCfbSCBicnoE5HgZNoBrZxUrFwneEZxxJUJGUKUIewi0MmBAP7dqMD6492G53_1GKDXpJnZ2vT8g4Q6l28EJq6Wk4PQgprzXHReJlDj0ZTkQbLZFmlczwk9mhuPOaqYp3GdPye_vlgfQEK10AX

Screenshots

image

Code Sample

`pie title Pets adopted by volunteers
    "Dogs" : 80
    "Cats" : 86
    "Rats" : 80
 `

Setup

Desktop

  • OS and Version: Windows
  • Browser and Version: Chrome

Additional Context

No response

@NXML NXML added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Jan 13, 2023
@tomperr
Copy link
Contributor

tomperr commented Jan 19, 2023

In this kind of situation, I don't really know what to expect. This is obviously a truncation/rounding problem. Having less or more than 100% is the same problem in my opinion.

To take a more classic example:

pie title Pets adopted by volunteers
    "Dogs" : 10
    "Cats" : 10
    "Rats" : 10

Every section is one third, which would give 33% for each section. To solve that (and get a total of 100%, not 99%), the only solution I can see would be to round up a section to 34%, which does not really make sense to me.

@nirname
Copy link
Contributor

nirname commented Jul 11, 2023

That is because of rounding.
To eliminate the problem this rounding error must be added to the biggest element in the set.
The only problem is a set of equal elements. In that case, probably you would get one element that is bigger than others

@nirname nirname added Status: Approved Is ready to be worked on Area: Development Graph: Pie Internals: Renderer and removed Status: Triage Needs to be verified, categorized, etc labels Jul 11, 2023
@nirname nirname self-assigned this Jul 11, 2023
@nirname nirname added Status: Pending Is not to be executed as it currently is and removed Status: Approved Is ready to be worked on labels Jul 13, 2023
@nirname
Copy link
Contributor

nirname commented Jul 13, 2023

What do you think must be the behavior in the case with one third?
Sum is not 100% but 33% is very likely the most desirable in that case

pie
    "Dogs" : 10
    "Cats" : 10
    "Rats" : 10

@NXML
Copy link
Author

NXML commented Jul 29, 2023

Maybe yes ,this is more representative of the equality between each elements

@BrendanTWhite
Copy link

Maybe yes ,this is more representative of the equality between each elements

Hi @NXML, in that case, if you're happy to have 33% / 33% / 33% not adding up perfectly to 100%, would you also be comfortable if we leave 33% / 33% / 35% adding up to nearly (but not exactly) 100%?

@BrendanTWhite
Copy link

BrendanTWhite commented Aug 8, 2023

Another possibility would be to display the raw values, not the (rounded) percentages, on the pie chart.

But if we make this change, it would almost certainly make some folks unhappy. So we'd probably need to leave the labels as percentages by default, and have the raw values as a configurable option ... so we would still have the rounding issue with percentages anyway. So this wouldn't fix the problem. :)

[edit] and this would be a feature request, not a bug fix.

@nirname nirname removed their assignment Aug 24, 2023
@jgreywolf jgreywolf added roadmap items to add to roadmap for auto workflow and removed roadmap items to add to roadmap for auto workflow labels Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Development Graph: Pie Internals: Renderer Status: Pending Is not to be executed as it currently is Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants