0
votes

I have a simple line chart built using ChartJS. The Y axis scale values are odd. The data set I'm testing with has values of all 0 and a single value of 1. The Y axis ChartJS builds is from 0 to 1. The values start at 0 and proceed up in tenths.. (ex. 0, 0.1, 0.2, etc).. The problem is, when it get's to 0.3, the label is 0.030,000,000,000,000,004 . It does it again on the 0.6 and 0.7 increments.

My options block follows.

responsive: true,
maintainAspectRatio: false,
scales: {
yAxes: [{
        //type: 'logarithmic',
        ticks: {
            beginAtZero: true,
            precision: 1,
            callback: function (label, index, labels) {
                return label.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
            }
        }
    }
]
},
tooltips: {
mode: 'index',
intersect: false,
callbacks: {
    label: function (label, data) {
        return ' ' + data.datasets[label.datasetIndex].label + ' ' + label.yLabel.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    }
}
},
legend: {
    display: true
}

enter image description here

1

1 Answers

0
votes

We were on ChartJS version 2.4 , upgrading to the latest release, 2.9.3 as of today, fixed the scale problem.