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

Make index mode only work with the horizontal distance to an element #3471

Merged
merged 4 commits into from
Oct 15, 2016

Conversation

etimberg
Copy link
Member

This only applies when intersect: false is in the tooltip options. @simonbrunel noticed this behaviour. I added a test to ensure that the horizontal distance is what applies.

One question ... what do we do for horizontal bar charts? In that case we want to use the y direction. @chartjs/maintainers thoughts on this?

@@ -62,7 +63,9 @@ module.exports = function(Chart) {
}

var center = element.getCenterPoint();
var distance = Math.round(helpers.distanceBetweenPoints(position, center));
var distance = distanceMetric ?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move the distanceMetric decision outside the loop:

if (!distanceMetric) {
    distanceMetric = helpers.distanceBetweenPoints;
}

parseVisibleItems(chart, function(element) {
    // ...
    var distance = distanceMetric(position, center);

var distance = Math.round(helpers.distanceBetweenPoints(position, center));
var distance = distanceMetric ?
distanceMetric(position, center) :
Math.round(helpers.distanceBetweenPoints(position, center));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to round the value?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not, i will remove it

@etimberg etimberg merged commit 6ec6a92 into master Oct 15, 2016
@etimberg etimberg deleted the fix/tooltip-index-mode branch October 15, 2016 21:49
@simonbrunel simonbrunel added this to the Version 2.4 milestone Oct 29, 2016
exwm pushed a commit to exwm/Chart.js that referenced this pull request Apr 30, 2021
…hartjs#3471)

Make index mode only work with the horizontal distance to an element if intersect is off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants