0👍
What I personally do for all my custom charts is create a custom title / label independent of what I pass as options to the chart. I like to have control over the HTML / whatever which gets outputted to the label. You can do this with the callbacks key
tooltips: {
enabled: true,
position: "nearest",
caretSize: 20,
mode: "index",
intersect: false,
titleFontSize: 16,
titleFontColor: "white",
backgroundColor: COLORS.DARK,
callbacks: {
title: (tooltipItem, _) => {
return formatDate("LT", tooltipItem[0].xLabel);
},
label: (tooltipItem, _) => {
const { yLabel } = tooltipItem;
return `${yLabel} Sessions Recorded`;
}
}
},
- Chartjs-Chart.js reduce canvas size without changing the size of the chart
- Chartjs-Cannot read properties of undefined with react-chartjs-2 and chart js problem
Source:stackexchange.com