-
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
Tool Tip isn't displaying point data correctly #7839
Labels
Comments
Its the title callback that fails: Chart.js/src/core/core.tooltip.js Lines 43 to 60 in 679ec4a
You can override that. This is most likely fixed in v3, too lazy to create a test from scratch. |
Work around: tooltips: {
callbacks: {
title: function(tooltipItem, data) {
let dataSet = tooltipItem[0].datasetIndex;
let index = tooltipItem[0].index;
let title = data.datasets[dataSet].data[index].x;
return title;
}
}
} |
alessandroasm
added a commit
to alessandroasm/Chart.js
that referenced
this issue
Oct 6, 2020
When using object datasets, labels are displayed incorrect because they are retrieved based on item index instead of the corresponding x or y property. Fixes chartjs#7839
alessandroasm
added a commit
to alessandroasm/Chart.js
that referenced
this issue
Oct 6, 2020
When using object datasets, labels are displayed incorrect because they are retrieved based on item index instead of the corresponding x or y property. Fixes chartjs#7839
alessandroasm
added a commit
to alessandroasm/Chart.js
that referenced
this issue
Oct 8, 2020
When using object datasets, labels are displayed incorrect because they are retrieved based on item index instead of the corresponding x or y property. Fixes chartjs#7839
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected Behavior
The tool tip of a data point should show the x & y values of the data point.
Current Behavior
The tool tip's x value is being take from the series index number rather than from the data point x value.
Possible Solution
When a data set uses the
point
format type, the tooltip has to take the x/y coordinates from the point object rather than assuming that the point's index aligns with the x axis index.Steps to Reproduce
Create an X axis label array with a few values, e.g.
labels = ['January','February','March']
.Create a data series using
format: 'point'
and with the data having fewer points than the x axis labels, e.g.data = [{x: 'March', y: 10}]
Context
The wrong labels are being rendered.
Environment
The text was updated successfully, but these errors were encountered: