From f6198f5db29df777814e91a7dcce294149c9a1a6 Mon Sep 17 00:00:00 2001 From: James Ward Date: Thu, 3 Jan 2013 12:44:55 +0000 Subject: [PATCH] Change evaluation order for calculating percentage Rounding errors are introduced when calculating the percentage when the total is 100 (for example if percentages have already been calculated). Calculating (total/100) first eliminates the error in this case. --- jquery.flot.pie.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.flot.pie.js b/jquery.flot.pie.js index b48df0b..728d3cb 100644 --- a/jquery.flot.pie.js +++ b/jquery.flot.pie.js @@ -267,7 +267,7 @@ More detail and specific examples can be found in the included HTML file. color: data[i].color, label: data[i].label, angle: data[i].data[0][1] * Math.PI * 2 / total, - percent: data[i].data[0][1] / total * 100 + percent: data[i].data[0][1] / (total / 100) }); } } @@ -278,7 +278,7 @@ More detail and specific examples can be found in the included HTML file. color: color, label: options.series.pie.combine.label, angle: combined * Math.PI * 2 / total, - percent: combined / total * 100 + percent: combined / (total / 100) }); }