bernii / gauge.js

100% native and cool looking JavaScript gauge
MIT License
1.42k stars 391 forks source link

two point error when guage.set(0) #71

Open sunys99 opened 9 years ago

sunys99 commented 9 years ago

when I set 0 to gage chart I found 2 guage pointer with angle 0. example: http://jsfiddle.net/niftytushar/vAnGE/1/

vcanales commented 9 years ago

I just wanted to point out that this happens only when you "initialize" it on 0, not if you use set(0) from the console or otherwise if the gauge has been set to anything > 0 as the first value.

sanurocks commented 9 years ago

A simple solution for it. Logic is c#, Script is in razor text mode. @{ if (yourItem.CompletionPercentage != 0) { @:var completionPercentage = @yourItem.CompletionPercentage; } else { @:var completionPercentage = 0.1; } @:var gauge = new Gauge(document.getElementById('canvas')).setOptions(opts); // Create gauge @:gauge.maxValue = 100; gauge.animationSpeed = 100; gauge.set(completionPercentage); $('#yourTextDisplay').text(@yourItem.CompletionPercentage + "%");// Set gauge }

The point being use fraction value for plugin and actual value for display.

jonnywilliamson commented 8 years ago

Yep. Confirm I have this issue too.

At the moment I'm doing gauge.set(1); gauge.set(0);

When I load my page to work around this.

vvnc commented 6 years ago

I had this issue in some older version too, but now this issue seems to be fixed, run js fiddle again.

I'm using google chrome 66