pizza
pizza copied to clipboard
Math.ceil instead of Math.round in pie.js results in wrong Percentages > 100% total
Hi there, thank you for this great component!
You can reproduce this issue for example with the following numbers: Make a Pie Chart with 55, 21, 9, 15 which will result in 56%, 21%, 9%, 15% on the rendered chart.
Line 76 in pie.js is responsible, instead of
var visible_text = Math.ceil(percent) + '%';
it should be
var visible_text = Math.round(percent) + '%';
I would put in a pull request but unfortunately I don't have Git on this machine. I just thought I let you know in case somebody else runs into this issue.
Best Chris
Chris, thank you for posting this. I used these pie charts on a project almost a year ago and they contacted me today saying they changed the data and it was adding up to 101%. Your post saved me a lot of time.
Hey, thank you for the message - glad I could help :)