From e491dc7a060ec8026689991f25c3d2b0dc574bc9 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Fri, 8 Feb 2013 19:49:05 -0500 Subject: [PATCH] Cache the data value, since it is used repeatedly. --- jquery.flot.pie.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/jquery.flot.pie.js b/jquery.flot.pie.js index b31919f..4aa7a42 100644 --- a/jquery.flot.pie.js +++ b/jquery.flot.pie.js @@ -232,19 +232,21 @@ More detail and specific examples can be found in the included HTML file. for (var i = 0; i < data.length; ++i) { - if (data[i].data[0][1] / total <= options.series.pie.combine.threshold) { - combined += data[i].data[0][1]; + var value = data[i].data[0][1]; + + if (value / total <= options.series.pie.combine.threshold) { + combined += value; numCombined++; if (!color) { color = data[i].color; } } else { newdata.push({ - data: [[1, data[i].data[0][1]]], + data: [[1, value]], 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) + angle: value * Math.PI * 2 / total, + percent: value / (total / 100) }); } }