Commits

Ben Bass committed e10e963

further updates after testing with excanvas/IE8

Comments (0)

Files changed (2)

         </li>
     </ul>
     <h3>Min / max test</h3>
-    <p>The following is a quick test of zero: <span class="piefull">0%</span>,
+    The following is a quick test of zero: <span class="piefull">0%</span>,
     and 100 percent: <span class="piefull">100%</span>,
-    which previously caused issues in some browsers.</p>
+    which previously caused issues in some browsers.
     <small>Ben Bass 2011-2012 @codedstructure</small>
     </body>
 </html>
         var _yescol = yescol || this.yescol;
         var _nocol = nocol || this.nocol;
         var _drawArc = function(ctx, arclen, full) {
+            if (arclen > 0.9999) {
+                // this helps excanvas to work...
+                arclen = 0.9999;
+            }
             ctx.beginPath();
             ctx.moveTo(_piesize / 2,_piesize / 2);
-            if (Math.abs(arclen) < 0.000001) {
-                // some renderers optimise arclen of zero
-                // into a no-op even if direction is false
-                arclen = 0.000001;
-            }
             ctx.arc(_piesize / 2,_piesize / 2, _piesize / 2,
-                    that.START_ANGLE, that.START_ANGLE + arclen, !full);
+                    that.START_ANGLE,
+                    that.START_ANGLE + arclen * 2*Math.PI,
+                    !full);
             ctx.fillStyle = full ? _yescol : _nocol;
             ctx.fill();
             ctx.closePath();
             // if no percentage found, don't change anything.
             if (percent_match !== null) {
                 var value = percent_match[0];
-                // convert percentage to arc length
-                var arclen = (2*Math.PI)*parseFloat(value)/100;
+                // convert percentage to arc length (0..1)
+                var arclen = parseFloat(value)/100;
                 // create canvas element
                 var canvas = document.createElement('canvas');
                 // copy across class and id elements if present
                     canvas = window.G_vmlCanvasManager.initElement(canvas);
                 }
                 var ctx = canvas.getContext('2d');
+                // order of these is important, at least for excanvas
+                _drawArc(ctx, arclen, true);
                 _drawArc(ctx, arclen, false);
-                _drawArc(ctx, arclen, true);
             }
         }
     }