bernii / gauge.js

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

Customize the label display #122

Open kkliuxu opened 7 years ago

kkliuxu commented 7 years ago

This is pretty cool Gauge Library., But I find that, if I want to customized or so call format the label. I can not. this is how I want to showing the label

need_like_this

however, I only can show the value and can not format it.

only_show_value

Could you improve it in the next version? Thanks.

kplindegaard commented 7 years ago

Agree that label formatting is not that great.... The quickest way to improve it is to make the modifications you need yourself, though. Feel free to submit a pull request.

kplindegaard commented 7 years ago

What we could do is to open up for a user-given value formatter function. That means that you as a user can override the standard value formatting function inside gauge.js like this:

function myValueFormat(value, digits) {
  return value.toFixed(digits) + "%";
}

// Provide access to it alongside the other options
var opts = {
  // ...
  valueFormat: myValueFormat
};
var target = document.getElementById('foo'); // your canvas element
var gauge = new Gauge(target).setOptions(opts);

Something like that, maybe?

ghost commented 7 years ago

I'm in need of custom label strings too.

dietervb commented 6 years ago

I also need custom labels based on the value. The proposed solution by kplindegaard looks promising! Any chance of integrating this?

mlRami commented 6 years ago

This is pretty cool Gauge Library. But I find that, if I want to customized or so call format the label. I can not. i want to show % near the label but I only can show the value and can not format it. Could you improve it in the next version? Thanks.