chartjs / chartjs/Chart.js

Tooltip Title is passed Array of tooltip items of size 0

Open
#9,827 6 comments 0 reactions 0 assignees View on GitHub
type: documentation
Dominant language
JavaScript
Stars
67.7k
Forks
11.9k
Avg merge
7h 39m
Merged PRs (30d)
5

Description

Documentation Is:

- [ ] Missing or needed
- [x ] Confusing
- [ x] Not Sure?

### Please Explain in Detail...

When setting the callback for a tooltip label, the callback is passed a single `TooltipItem` variable according to the documentation. However, when setting the callback for a tooltip *title* (which intuitively seems like it should behave exactly the same way), the callback is actually passed `TooltipItem[]` array of length one. It seems unclear from the documentation that this is the case, as well as being unclear to me what the API design of this intends (after all, the callback seems like it should apply the same way as the `label` callback example in the documentation).

https://www.chartjs.org/docs/latest/configuration/tooltip.html#tooltip-item-context

### Your Proposal for Changes

Either fix the "bug" in the API by making `title` accept a `TooltipItem` just like `label` (which makes more sense) or document more explicitly the intended use case of the API and the difference between the two APIs (preferrably with an example)

### Example

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.