0

I'm looking for examples how to format the (number) ticks in Chartjs 3.6.0 and up.

My graph uses the default configuration, hence 20.600 and in another graph 1,050.0

How to change that into resp 20.6 and 1050.0 ?

    yAxis1: {
        type: "linear",
        position: "left",
        ticks: {
            beginAtZero: false
        } // ticks
    },
    yAxis2: {
        type: "linear",
        position: "right",
        ticks: {
            suggestedMin: 975,    // minimum will be 950, unless there is a lower value.
            suggestedMax: 1025    // maximum will be 1050, unless there is a lower value.
        } // ticks
    },      ```
  • 1
    Does this answer your question? [Chart.js - Formatting Y axis](https://stackoverflow.com/questions/20371867/chart-js-formatting-y-axis) – LeeLenalee Dec 26 '21 at 19:22
  • Specific answer in that thread for V3: https://stackoverflow.com/a/67993873/8682983 – LeeLenalee Dec 26 '21 at 19:22

1 Answers1

0

Thanks. It did partly the trick. I also found out that there is an option "precision". Still didn't figure out, how to use the ToFixed(2) as return Intl.NumberFormat().format(label).ToFixed(2); doesn't work

I know have:

ticks: {
    suggestedMin: 975,    // minimum will be 950, unless there is a lower value.
    suggestedMax: 1025,   // maximum will be 1050, unless there is a lower value.
    precision: 1,
    callback: function(label, index, labels) {
        return Intl.NumberFormat().format(label).replace("," , "");
    }
} // ticks

But thanks for your suggestions!