Skip to content
Advertisement

Chart.JS tooltip callbacks label and title (v3.5)

(Please note: There are lots of answers for v2, this is for v3)

I’m trying to setup tooltips label and title for a doughnut chart.

Code:

JavaScript

The label now works, and displays the value of the data, but the title is returning blank, instead of returning the label of the data (“Positive” or “Other”).

How can I return the correct title in the tooltip.callback?

Example: “Positive 35%” and “Other 65%”

Advertisement

Answer

If you log the context you could see its an array containing objects, with the default interaction mode you are using it only contains a single item so you can select that one and then access the label attribute on it like so:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement