Skip to content
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

Tooltip titles have the wrong value when datapoints are a subset of the labels array #6539

Closed
sezanzeb opened this issue Sep 26, 2019 · 1 comment

Comments

@sezanzeb
Copy link

sezanzeb commented Sep 26, 2019

Expected Behavior

Title of the first orange datapoints tooltip should be '3' (see codepen below)
Title of the first grey datapoints tooltip should be '2'

Current Behavior

Title of the first orange datapoints tooltip is '1'
Title of the first grey datapoints tooltip is '1'

Possible Solution

Besides having this fixed (in case this actually is unexpected behaviour), I would appreciate if instead of just having {{ x: number, y: number }} for each datapoint also having the option to add labels {{ x: number, y: number, xLabel: string, yLabel: string }} which will be used in the Tooltip. Might be easier to use than the callbacks. Or #6009

For a workaround, you can try to insert this in your options object:

tooltips: {
    callbacks: {
        title: (datapoints, { datasets }) => {
            const { datasetIndex, index } = datapoints[0]
            return datasets[datasetIndex].data[index].x
        }
    }
},

Steps to Reproduce (for bugs)

https://codepen.io/sezanzeb/pen/pozBgGB

Context

displaying outliers next inside a linechart which is the average of multiple datapoints

Environment

  • Chart.js version: "chart.js": "2.8.0" and whatever codepen uses
  • Browser name and version: Mozilla Firefox 68.0
@kurkle
Copy link
Member

kurkle commented Nov 15, 2019

This has been fixed by #6576
Pen using master

@kurkle kurkle closed this as completed Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants