trying to customized the tooltip based on the value of the data. Also there are these small circular connectors or joins on the corner of a line chart, when the line goes up or down, that I am also trying to change its color and for those I don't even know where to start. Here is a portion of the code I am using where I am trying to return and change the tooltip color using Chart.js
tooltips: {
mode: 'index',
intersect: false,
callbacks: {
label: function(tooltipItem, data) {
if (tooltipItem.yLabel === 1) {
//return 'Normal';
return { 'Normal',
tooltipFillColor: 'rgb(255, 99, 132)', // red
};
} else if (tooltipItem.yLabel === 2) {
// return 'Active';
return { 'Acitve',
tooltipFillColor: 'rgb(75, 192, 192)', // green
};
}
}
}
},
Thanks for all the help!
Alternatively, you can use the label Color function.
tooltips: {
callbacks: {
labelColor: function(tooltipItem,data) {
if (tooltipItem.datasetIndex === 0) {
return {
borderColor: "#FFFFFF",
backgroundColor: "#FFCD2E"
};
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With