chartjs / Chart.js

Simple HTML5 Charts using the <canvas> tag
https://www.chartjs.org/
MIT License
64.04k stars 11.89k forks source link

Multiple Datasets in tooltip bug #10616

Open Dennayz opened 1 year ago

Dennayz commented 1 year ago

Expected behavior

I'm trying to make the tooltip group all datasets under the same x axis but it is not working. I am using interaction: { mode: "index" }. The expected behaviour is suppose to show the correct datasets for each x axis.

Current behavior

It is showing mixed datasets in each of the tooltips, which is incorrect.

Reproducible sample

https://codepen.io/dza48/pen/WNzmymw

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

v3.8.2

Browser name and version

No response

Link to your project

No response

LeeLenaleee commented 1 year ago

The current behaviour is the correct behaviour, since you specify the mode as index it takes the index in the data array, and your data arrays have different lenghts so to get what you want with mode index you need to have all your data arrays be the same length.

Dennayz commented 1 year ago

The current behaviour is the correct behaviour, since you specify the mode as index it takes the index in the data array, and your data arrays have different lenghts so to get what you want with mode index you need to have all your data arrays be the same length.

I see, is there another mode I can use that can help with my situation?

LeeLenaleee commented 1 year ago

No, afaik there is no build in mode that does what you want so you will need to create your own custom mode to achieve what you want