kluverua/Chartjs-tsgauge

How to update Gauge value?

Opened this issue · 13 comments

gGauge.data.datasets[0].data = 10 doesn't work...
Can you help me?
Tanks!

What did you mean?
Can you show full chart config?
Dataset has only such parameters:
gaugeData gaugeLimits backgroundColor

I want to change de gaugeData.

myChartInstance.config.data.datasets[0].gaugeData.value = 800; myChartInstance.update({duration:0,lazy: true})

Thank you!

Is it possible to update the position of the pointer without it resetting from 0?

comment this:
//gaugeHelper.animateArrow();
and replace this:
//gaugeHelper.renderSmallValueArrow(gaugeHelper.minValue);
-->
gaugeHelper.renderValueArrow();

Perfect! ahn... and the animation? it is possible to keep?

I think so, if you write some code :D

Hello ! I tried to update the Gauge chart. I was able to update the gaugeData, but not the gaugeLimits. They just stay the same displayed, eventhough I assigned them a new array.

chart.config.data.datasets[0].gaugeLimits = [0,1,2,3,4,5];
chart.config.data.datasets[0].gaugeData.value = 3;
chart.update();

You cant do this in current version.
If you don't want to fix source code, you can try this workaround:

chart.config.data.datasets[0].gaugeLimits[0] = 0;
chart.config.data.datasets[0].gaugeLimits[1] = 1;
...
update

how update valueColor according to the pointer!
example:
function updateColorValue(chart, value){ chart.data.datasets[0].gaugeData.value = value; chart.data.datasets[0].gaugeLimits.forEach(function(element, index) { if(value >= element && value < chart.data.datasets[0].gaugeLimits[index+1]){ chart.data.datasets[0].gaugeData.valueColor = chart.data.datasets[0].backgroundColor[index]; }else if(chart.data.datasets[0].gaugeLimits.length-1 == index && value >= element){ chart.data.datasets[0].gaugeData.valueColor = chart.data.datasets[0].backgroundColor[index-1]; }else if(index == 0 && value <= element){ chart.data.datasets[0].gaugeData.valueColor = chart.data.datasets[0].backgroundColor[index]; } }); chart.update(); }

You cant do this in current version.
If you don't want to fix source code, you can try this workaround:

chart.config.data.datasets[0].gaugeLimits[0] = 0;
chart.config.data.datasets[0].gaugeLimits[1] = 1;
...
update

Hey, this is not working :(
The values of the limit gets updated but they all overlap in the position of the first one

@kluverua How to add text to gaugeLimits in addition to numbers something like '1000( approximately)'. Could you please suggest?