Chart.js
更新資料點的內容
用callbacks function添加
官方文件
https://www.chartjs.org/docs/latest/configuration/tooltip.html
https://chartjs-doc.abingoal.com/configuration/tooltip.html
小範例
https://codepen.io/k3no/pen/OReEKx?editors=0010
Issue
有些function實測後發現需要指定tooltipItem的index位置
小範例
options: {
tooltips: {
callbacks: {
afterBody: function(tooltipItem, data) {
var tooltipItem = tooltipItem[0];
var label = date_dic[tooltipItem.xLabel]
return label;
},
afterLabel: function(tooltipItem, data) {
var label = data.datasets[tooltipItem.datasetIndex].label || '';
label += tooltipItem.yLabel + '---' + tooltipItem.xLabel + 'afterLabel'
return label;
}
}
}
}
}
https://stackoverflow.com/questions/50480837/chartjs-2-tooltip-title-is-undefined
Last updated
Was this helpful?