naikus / svg-gauge

Minimalistic, animated SVG gauge. Zero dependencies
MIT License
319 stars 74 forks source link

SetMaxValue does not update the label if "this.max" is used in the label #59

Open sharky98 opened 2 years ago

sharky98 commented 2 years ago

Title says it all. Basically, I have using the configuration below for labels

label: function(value) {
    return Math.round(value) + "/" + this.max;
}

But, when I use the setMaxValue() function there, it will not update the this.max in the label. https://github.com/naikus/svg-gauge/blob/5fd44a3f2d62a7019345bc3019a43f81693dbac5/src/gauge.js#L303-L305

I tried to replace this.max by this.limit, as it is the internal variable, but the label shows as NaN instead. https://github.com/naikus/svg-gauge/blob/5fd44a3f2d62a7019345bc3019a43f81693dbac5/src/gauge.js#L303-L305

sharky98 commented 2 years ago

By the way, I have another way around. I wanted to configure the gauge outside of an ajax call and just update the values afterwards so that any refreshed values will be updated, but I'll go the other way around to create (and recreate) the chart each time the values are updated.

naikus commented 2 years ago

Thanks for filing this issue. I'll look into this.