From fa463311dc6bb89628e018d6ba9b7e3283bf4261 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Sun, 3 Feb 2013 12:56:43 -0500 Subject: [PATCH] Make redrawAttempts and shrink proper constants. --- jquery.flot.pie.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/jquery.flot.pie.js b/jquery.flot.pie.js index 11c1dbd..f0d5630 100644 --- a/jquery.flot.pie.js +++ b/jquery.flot.pie.js @@ -57,6 +57,14 @@ More detail and specific examples can be found in the included HTML file. (function($) { + // Maximum redraw attempts when fitting labels within the plot + + var REDRAW_ATTEMPTS = 10; + + // Factor by which to shrink the pie when fitting labels within the plot + + var REDRAW_SHRINK = 0.95; + function init(plot) { var canvas = null, @@ -67,8 +75,6 @@ More detail and specific examples can be found in the included HTML file. centerLeft = null, centerTop = null, redraw = true, - redrawAttempts = 10, - shrink = 0.95, legendWidth = 0, processed = false, raw = false, @@ -299,10 +305,10 @@ More detail and specific examples can be found in the included HTML file. var slices = plot.getData(); var attempts = 0; - while (redraw && attempts 0) { - maxRadius *= shrink; + maxRadius *= REDRAW_SHRINK; } attempts += 1; clear(); @@ -312,7 +318,7 @@ More detail and specific examples can be found in the included HTML file. drawPie(); } - if (attempts >= redrawAttempts) { + if (attempts >= REDRAW_ATTEMPTS) { clear(); target.prepend("
Could not draw pie with labels contained inside canvas
"); }