pandameister / chartjs-chart-radial-gauge

chartjs radial gauge chart implementation
MIT License
27 stars 12 forks source link

Decimal values are getting rounded to .00 #27

Open nitinkg7 opened 1 year ago

nitinkg7 commented 1 year ago

Hi, I have been trying to show the decimal value with a % on the radial gauge. Initially, it was showing a ceiled number but after I added .toFixed() with a custom function, it's showing .00 at the end of my value.

Here is an example : https://quickchart.io/sandbox/#%7B%22chart%22%3A%22%7B%5Cn%20%20type%3A%20'radialGauge'%2C%5Cn%20%20data%3A%20%7B%5Cn%20%20%20%20datasets%3A%20%5B%7B%5Cn%20%20%20%20%20%20data%3A%20%5B84.55%5D%2C%5Cn%20%20%20%20%20%20%5Cn%20%20%20%20%20%20backgroundColor%3A%20getGradientFillHelper('horizontal'%2C%20%5B'red'%2C%20'blue'%5D)%2C%5Cn%20%20%20%20%7D%5D%5Cn%20%20%7D%2C%5Cn%20%20options%3A%20%7B%5Cn%20%20%20%20%2F%2F%20See%20https%3A%2F%2Fgithub.com%2Fpandameister%2Fchartjs-chart-radial-gauge%23options%5Cn%20%20%20%20domain%3A%20%5B0%2C%20100%5D%2C%5Cn%20%20%20%20trackColor%3A%20'%23f0f8ff'%2C%20%5Cn%20%20%20%20centerPercentage%3A%2090%2C%5Cn%20%20%20%20centerArea%3A%20%7B%5Cn%20%20%20%20%20%20text%3A%20(val)%20%3D%3E%20val.toFixed(2)%20%2B%20'%25'%2C%5Cn%20%20%20%20%7D%2C%5Cn%20%20%7D%5Cn%7D%22%2C%22width%22%3A500%2C%22height%22%3A300%2C%22version%22%3A%222%22%2C%22backgroundColor%22%3A%22%23fff%22%7D

typpo commented 1 year ago

This appears to be happening because the library passes the value with Math.ceil: https://github.com/pandameister/chartjs-chart-radial-gauge/blob/master/src/controllers/controller.radialGauge.js#L115