pandameister / chartjs-chart-radial-gauge

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

Display float type values #9

Closed deviashin closed 4 years ago

deviashin commented 4 years ago

Hello! Thanks for this!

Tell me, please, how to display floating point values in the center of a circle? Initially, data of the String type, for example, "28.73", but after displaying according to mathematical rules, "29" is displayed, is rounded up. How to fix this?

pandameister commented 4 years ago

@deviashin you can specify a custom function in your chart options to format the center value as you like.

eg:


options: {
    centerArea: {
            text: function (value) { return value.toFixed(2); }
    }
}
`
deviashin commented 4 years ago

Thank you very much!

I combined your methods and got the desired result Now in the center of the circle displays a floating point value and a degree of Celsius

centerArea: { text: function (value, options) { return value.toFixed (2) + '°C'; } }

jasonwee commented 3 years ago

try this, dont work... always end with .00 , the decimal point always rounded to 0

nitinkg7 commented 1 year ago

Same here. Decimal points are always rounded to .00. This should be fixed.