pizza icon indicating copy to clipboard operation
pizza copied to clipboard

Math.ceil instead of Math.round in pie.js results in wrong Percentages > 100% total

Open ChrisKam opened this issue 10 years ago • 2 comments

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

ChrisKam avatar Aug 29 '14 08:08 ChrisKam

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.

kevinralph avatar Jun 19 '15 16:06 kevinralph

Hey, thank you for the message - glad I could help :)

ChrisKam avatar Jun 19 '15 23:06 ChrisKam