chartjs / Chart.js

Simple HTML5 Charts using the <canvas> tag
https://www.chartjs.org/
MIT License
63.92k stars 11.89k forks source link

floating point on y axis #11751

Closed netmanindy closed 1 month ago

netmanindy commented 2 months ago

Expected behavior

I'm trying to chart Barometric pressure with chart.js version 4.4.2 data: [990.25,1013.25,1013.25,1013.25,1013.25,1040.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1030.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25,1000.25,1013.25,1013.25,1013.25,1013.25,1013.25,1013.25],

Current behavior

with chart.js version 4.4.2 the y axis displays with commas, like 1,024, 1,025, etc...this is completely unusable.. with older version of chart.js version 2.9.4...floating point numbers are displayed properly.. 1024.1, 1025.9, etc

Reproducible sample

https://cdn.jsdelivr.net/npm/chart.js@4.4.2/dist/chart.umd.min.js

Optional extra steps/info to reproduce

Anyway, Love chart.js 2.9.4 ...trying up update to 4.4.2

Possible solution

No response

Context

No response

chart.js version

4.4.2

Browser name and version

latest mozilla firefox on ubuntu linux

Link to your project

http://netmanindy.com:7608/

LeeLenaleee commented 2 months ago

You can use the locale options to format the ticks in the locale format you desire. Otherwise you can also use the tick callback to apply a custom format to them

darshit1920 commented 2 months ago

Hey I am not able to reproduce it. Kindly write in detail about to start the server

netmanindy commented 2 months ago

line_chart_baro_pressure.txt

netmanindy commented 2 months ago

Thank You

netmanindy commented 2 months ago

Screenshot from 2024-05-01 19-15-56

netmanindy commented 2 months ago

The .png was rendered using chart.js 2.9.4, its displays floating point numbers correctly ..4.4.2 does not. It inserts a comma.. This is not usable...

netmanindy commented 2 months ago

Screenshot from 2024-05-01 19-27-51_chart js_4 4 2

netmanindy commented 2 months ago

Chart 4.4.2 does not render floating point numbers properly .

LeeLenaleee commented 1 month ago

As per my first comment, this is not a bug. We format the ticks using the locale API when you don't provide a locale to chart.js it will use the default of your system.

Providing a US locale will force the ticks to render with a dot instead of a comma: https://jsfiddle.net/xp5uLdac/1/

Since this is not a bug I am closing this issue