Chart.defaults.global.tooltips.callbacks.label only works for bar, line
See original GitHub issueExpected Behavior
Global setting for tooltips for all chart types I would like to use the global settings to set the display of the tooltips without having to do this via the “options”.
Current Behavior
Chart.defaults.global.tooltips.callbacks.label only works for bar, line
Context
Chart.defaults.global.tooltips.callbacks.label = function (
tooltipItem,
data
) {
let dataset = data.datasets[tooltipItem.datasetIndex];
let datasetLabel = dataset.label || ""
let suffix = dataset.unit || ""
console.log('Tooltips.label',tooltipItem, data )
return (
" " + datasetLabel + ": " + dataset.data[tooltipItem.index].toLocaleString() + " " + suffix
);
Environment
- Chart.js version: “chart.js”: “^2.9.4”
- Browser name and version: Chrome Version 86.0.4240.80 (Offizieller Build) (x86_64)
Am I doing something wrong ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Tooltip - Chart.js
Tooltip Configuration. Namespace: options.plugins.tooltip , the global options for the chart tooltips is defined in Chart.defaults.plugins.
Read more >Chart.js V2: Add prefix or suffix to tooltip label - Stack Overflow
There is a sample for the usage of callbacks here and you can find the possible callbacks in the documentation under Chart.defaults.global.tooltips.
Read more >Tooltips | Charts - Google Developers
In this documentation, you'll learn how to create and customize tooltips in Google Charts. Specifying the tooltip type. Google Charts automatically creates ...
Read more >Chart Configuration - Qiao
Chart.js merges the options object passed to the chart with the global configuration using chart type defaults and scales defaults appropriately.
Read more >How to Show the Labels in the Customize Tooltip in Chart JS
To do this we need to use the callbacks function for the tooltip. ... With chart js you can make line chart, bar...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@etimberg
Thanks, now it is working, perfect 👍
You should be able to override the defaults for the other chart types with something like the following. You would need to override it for the
'bubble'
,'doughnut'
,'pie'
,'polarArea'
, and'scatter'
chart types.