Trombone0904
Trombone0904

Reputation: 4258

change date format in tooltip of chart.js

I am using the chart.js to generate a chart. All works fine !

enter image description here

But how can I format the tooltip information? It should be: 28.04.2020 - 05:00

Upvotes: 4

Views: 1675

Answers (1)

uminder
uminder

Reputation: 26150

You need to define time.tooltipFormat for your xAxis.

See Moment.js for the allowed format tokens.

options: {
    ...
    scales: {
        xAxes: [{
            type: 'time',
            time: {
                unit: 'hour',
                tooltipFormat: 'DD.MM.YYYY - HH:mm' 
            }
            ...
        }]
    }
    ... 
}

Upvotes: 7

Related Questions