kottenator / kottenator/jquery-circle-progress

NaN

Open
#205 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.1k
Forks
300
PR merge metrics
No merged PRs in 30d

Description

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 = $('')[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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the circleProgress initialization and the later reset call shown in the report, reproducing the NaN result with the same v1, v2, and v3 inputs. Trace the plugin's zero-value handling and verify that resetting produces a numeric zero or the requested "--" display.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.