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

Chart data corresponding to data point not included in Custom Tooltip callback #2927

Closed
adampbragg opened this issue Jul 6, 2016 · 3 comments

Comments

@adampbragg
Copy link

adampbragg commented Jul 6, 2016

Using Version 2.1.6 with a Linear X-Axis

When using the Tooltip Callbacks, there exists data to tie the datapoint to the Chart Data.

When using the Custom Tooltip Callback, there does not exist data to tie the datapoint to the Chart Data such as the datasetIndex. So, there is very little data to use to create a custom tooltip and in fact much less than using the Tooltip Callbacks.

It would be great if the tooltip argument passed to the Custom Tooltip Callback included the datasetIndex and other information included in the Tooltip Callbacks arguments. It would also be great if the Chart data could be passed.

For example, I can attach some data to my data point in my dataset like so:
dataset.data.push({ x:xPoint, y:yPoint, pointData: someObject });
Then when I use a Tooltip Callack like for "title," then that pointData is passed with the rest of the data to my callback function.

@etimberg
Copy link
Member

etimberg commented Jul 7, 2016

@adampbragg this could easily be done by modifying: https://github.com/chartjs/Chart.js/blob/master/src/core/core.tooltip.js#L306

The data and tooltipItems could be attached to the model or passed to the custom function some other way. If attached to the model the property names would need to start with an '_' otherwise they will be changed during transition to view. I personally favour just passing these properties to the custom function.

@adampbragg
Copy link
Author

Perfect! That is exactly what I saw before I left the office. I am happy to have a little consensus. Pull request imminent.

@adampbragg adampbragg reopened this Jul 7, 2016
@etimberg
Copy link
Member

Done in #3201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

2 participants