I would set the background colour of tooltips depending on graph
Here's how I made
tooltips: {
yPadding: -2,
xPadding: 10,
footerMarginTop: 5,
titleFontColor: '#FFF',
displayColors: false,
backgroundColor: function(tooltipItem: Chart.ChartTooltipItem, chart: Chart) {
const bgColor = `${chart.config.data.datasets[tooltipItem.datasetIndex].pointBorderColor.toString()}`;
return bgColor;
}
But I get the error
Property 'setTransform' is missing in type '(tooltipItem: ChartTooltipItem, chart: Chart) => string' but required in type 'CanvasPattern'. [2322]
I have also to do it in callbacks
callbacks: {
labelColor: function(tooltipItem: Chart.ChartTooltipItem, chart: Chart) {
const bgColor = `${chart.config.data.datasets[tooltipItem.datasetIndex].pointBorderColor.toString()}`;
return {
backgroundColor: bgColor,
borderColor: ''
};
},
}
but the colour is not getting applicated, I get black colour instead of pointBorderColor
colour which is not black. ( I get well a colour code )