Tihauan / jsgauge

Automatically exported from code.google.com/p/jsgauge
0 stars 0 forks source link

gauge.js: fix when inadvertently sending string instead of numeric data #27

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If passing a string for the value to set the control to, an error is triggered 
in gauge.js:

     ret = value.toFixed( decimals );
     while ( ( decimals > 0 ) && ret.match( /^(-)?\d+\.(\d+)?0$/ ) ) {
       decimals -= 1;
       ret = value.toFixed( decimals );
     }

Changed to:

   ret = (parseFloat(value)).toFixed( decimals );
   while ( ( decimals > 0 ) && ret.match( /^(-)?\d+\.(\d+)?0$/ ) ) {
       decimals -= 1;
       ret = (parseFloat(value)).toFixed( decimals );
    }

Just forcing the conversion here.

Original issue reported on code.google.com by KMALIT...@gmail.com on 13 Apr 2012 at 6:33

GoogleCodeExporter commented 9 years ago
Thanks, this has been merged in: 
http://code.google.com/p/jsgauge/source/detail?r=70

Original comment by justin.e...@gmail.com on 16 Apr 2012 at 4:50