Commit fa463311 authored by David Schnur's avatar David Schnur

Make redrawAttempts and shrink proper constants.

parent 77889432
...@@ -57,6 +57,14 @@ More detail and specific examples can be found in the included HTML file. ...@@ -57,6 +57,14 @@ More detail and specific examples can be found in the included HTML file.
(function($) { (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) { function init(plot) {
var canvas = null, var canvas = null,
...@@ -67,8 +75,6 @@ More detail and specific examples can be found in the included HTML file. ...@@ -67,8 +75,6 @@ More detail and specific examples can be found in the included HTML file.
centerLeft = null, centerLeft = null,
centerTop = null, centerTop = null,
redraw = true, redraw = true,
redrawAttempts = 10,
shrink = 0.95,
legendWidth = 0, legendWidth = 0,
processed = false, processed = false,
raw = false, raw = false,
...@@ -299,10 +305,10 @@ More detail and specific examples can be found in the included HTML file. ...@@ -299,10 +305,10 @@ More detail and specific examples can be found in the included HTML file.
var slices = plot.getData(); var slices = plot.getData();
var attempts = 0; var attempts = 0;
while (redraw && attempts<redrawAttempts) { while (redraw && attempts < REDRAW_ATTEMPTS) {
redraw = false; redraw = false;
if (attempts > 0) { if (attempts > 0) {
maxRadius *= shrink; maxRadius *= REDRAW_SHRINK;
} }
attempts += 1; attempts += 1;
clear(); clear();
...@@ -312,7 +318,7 @@ More detail and specific examples can be found in the included HTML file. ...@@ -312,7 +318,7 @@ More detail and specific examples can be found in the included HTML file.
drawPie(); drawPie();
} }
if (attempts >= redrawAttempts) { if (attempts >= REDRAW_ATTEMPTS) {
clear(); clear();
target.prepend("<div class='error'>Could not draw pie with labels contained inside canvas</div>"); target.prepend("<div class='error'>Could not draw pie with labels contained inside canvas</div>");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment