Fix for customSectors
jimmyfo opened this issue ยท 2 comments
Custom colors for sectors seems to be broken. The fix appears to be line 1014 in justgage.js.
If you change
if (custSec.length > 0) {
to
if (custSec.length > 0 || (custSec.ranges != undefined && custSec.ranges.length > 0)) {
Then it works. Any chance you can merge a fix?
If you do a console.log of 'custSec.length', you'll notice that it returns undefined.
This is because you can't do a count on the parent property directly.
So your first condition (custSec.length > 0) will always return false.
Instead we would do a count on 'custSec.ranges' to get the length/amount of ranges.
This is my solution:
var ranges = (custSec.ranges) ? custSec.ranges.length : 0;
if (ranges > 0) {
if (custSec.percents === true) val = pct * 100;
for (var i = 0; i < ranges ; i++) {
if (val >= custSec.ranges[i].lo && val <= custSec.ranges[i].hi) {
return custSec.ranges[i].color;
}
}
}
If you do a console.log of 'custSec.length', you'll notice that it returns undefined.
This is because you can't do a count on the parent property directly.
So your first condition (custSec.length > 0) will always return false.Instead we would do a count on 'custSec.ranges' to get the length/amount of ranges.
This is my solution:var ranges = (custSec.ranges) ? custSec.ranges.length : 0; if (ranges > 0) { if (custSec.percents === true) val = pct * 100; for (var i = 0; i < ranges ; i++) { if (val >= custSec.ranges[i].lo && val <= custSec.ranges[i].hi) { return custSec.ranges[i].color; } } }
Thanks for the fix! ๐