Chartjs-Change time format in Chart.js date

1👍

Changing the date’s format in Chart.js can be as easy as this:

var chart = new Chart(ctx, {
type: 'line',
data: data,
options: {
    scales: {
        xAxes: [{
            type: 'time',
            time: {
                displayFormats: {
                    quarter: 'MMM YYYY'
                }
            }
        }]
    }
}

})

You can replace the format in displayFormats with any of the names giving in the formating table in documentation.

Leave a comment