chartjs / Chart.js

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

The callback is not working as expected for x-Axis #11782

Closed adarshk007 closed 1 month ago

adarshk007 commented 1 month ago

Expected behavior

Steps to reproduce:

Paste the below options in https://codepen.io/leelenaleee/pen/WNyJXEe.

var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
    type: 'line',
    data: {
        labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
        datasets: [{
            label: '# of Votes',
            data: [12, 19, 3, 5, 2, 3]
        }]
    },
    options: {
      scales: {
        x: {
          ticks: {
            callback: (label) => `${label} days`
          }
        },
        y: {

        }
      }
    }
});
image

Reproducible sample

https://codepen.io/leelenaleee/pen/WNyJXEe

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

v4.4.2

Browser name and version

No response

Link to your project

No response

adarshk007 commented 1 month ago

It's not a bug though. After checking the structure !! we can add it as enhancement.

LeeLenaleee commented 1 month ago

Duplicate of: https://github.com/chartjs/Chart.js/issues/11748