kottenator/jquery-circle-progress

NaN

clemsontiger opened this issue · 0 comments

value is displaying NaN when I'm trying to reset to zero before I recalculate again...


//setup
; (function () {
        var _originalInitFill = $.circleProgress.defaults.initFill;

        // circle progress plugin to get sectors
        $.circleProgress.defaults.initFill = function () {
            _originalInitFill.apply(this, arguments);

            if (this.fill.sectors) {
                var s = this.size,
                    r = s / 2,
                    sa = this.startAngle;

                var bg = $('<canvas>')[0];
                bg.width = s;
                bg.height = s;

                var lastValue = 0,
                    ctx = bg.getContext('2d');

                for (var i = 0; i < this.fill.sectors.length; i++) {
                    var sector = this.fill.sectors[i],
                        currentColor = sector[0],
                        currentValue = sector[1];

                    ctx.beginPath();
                    ctx.moveTo(r, r);
                    ctx.arc(r, r, r, sa + 2 * lastValue * Math.PI, sa + 2 * currentValue * Math.PI);
                    ctx.moveTo(r, r);
                    ctx.fillStyle = currentColor;
                    ctx.fill();

                    lastValue = currentValue;
                }

                this.arcFill = this.ctx.createPattern(bg, 'no-repeat');
            }
        };
    })();

//initial load
$("#circle").circleProgress({
                    value: (v1 + v2 )/v3,
                    emptyFill: "#D9D9D'',
                    size: 148,
                    startAngle: -Math.PI / 4 * 2,      
                    fill: {
                        sectors: [ 
                             ["#0072a3",v1 / v3], 
                             ["#f2b72b",(v1 + v2 )/v3] 
                           
                        ]
                    }
                   ,
                    thickness: 12
                });

//reset
$("#circle").circleProgress({ value: 0.0 }); 

I also tried value: 0, still displays NaN. Honestly what I really want it display is " -- ", but i'll take 0