Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NaN #205

Open
clemsontiger opened this issue Dec 2, 2020 · 0 comments
Open

NaN #205

clemsontiger opened this issue Dec 2, 2020 · 0 comments

Comments

@clemsontiger
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant