bernii / gauge.js

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

Missing Number() conversion in function formatNumber() #158

Open JuaniFilardo opened 6 years ago

JuaniFilardo commented 6 years ago

I've been experiencing some issues when creating a Gauge, and after messing around a little I found that the problem was on the function formatNumber(), i.e.:

  formatNumber = function() {
      var digits, num, value;
      num = 1 <= arguments.length ? slice.call(arguments, 0) : [];
      value = num[0];
      digits = 0 || num[1];
      return addCommas(value.toFixed(digits));
  };

The solution I found is to change value = num[0] to value = Number(num[0])

Otherwise I wasn't able to create the Gauge properly when num[0] was something like "7" (as a string) instead of 7 (as a number).

Thanks!