-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to customize the tooltip backgroup color dynamically ? #3416
Comments
@mjeanroy this is not possible with the current API. You might have to replace the tooltip draw function. Even better, you could factor out the background draw into a new method on the tooltip then in your case you only have to replace the |
Thank you for your answer @etimberg (and thank you for your great library by the way 😉 )! I'm not sure what you mean by:
Is it something I can do with the current version of Chart.js or do I have to write a custom plugin? |
@mjeanroy I was thinking that you would add the following before creating charts. For the most part you'd copy the implementation from https://github.com/chartjs/Chart.js/blob/master/src/core/core.tooltip.js#L673 except for https://github.com/chartjs/Chart.js/blob/master/src/core/core.tooltip.js#L692 where you'd determine the color based on the Chart.Tooltip.prototype.draw = function() {
// New implementation
}; |
@etimberg Ok, that's clear, thank you. Are you open for a PR to extract a |
Basic codepen example using https://www.chartjs.org/docs/2.7.3/configuration/tooltip.html#tooltip-model |
Hi,
Currently, we can change the tooltip background color with the
backgroundColor
property on the tooltip configuration object but is there a way to change this color dynamically (if I want the color to depends on the point being displayed)? I know we can customize some colors with thelabelColor
callback but I would like to change the entire background color.Here is my use case:
Here is an example:
In this chart, I would like to have the background color of the tooltip to be the same at the line color so, not black but purple).
Do you think it's possible with the current API?
The text was updated successfully, but these errors were encountered: