Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change date format in tooltip of chart.js

Tags:

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

like image 731
Ghost108 Avatar asked Sep 03 '25 06:09

Ghost108


1 Answers

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' 
            }
            ...
        }]
    }
    ... 
}
like image 158
uminder Avatar answered Sep 05 '25 01:09

uminder