change date format in tooltip of chart.js

强颜欢笑 提交于 2020-04-30 06:25:43

问题


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

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


回答1:


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' 
            }
            ...
        }]
    }
    ... 
}


来源:https://stackoverflow.com/questions/61474243/change-date-format-in-tooltip-of-chart-js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!