-
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
Make index mode only work with the horizontal distance to an element #3471
Conversation
@@ -62,7 +63,9 @@ module.exports = function(Chart) { | |||
} | |||
|
|||
var center = element.getCenterPoint(); | |||
var distance = Math.round(helpers.distanceBetweenPoints(position, center)); | |||
var distance = distanceMetric ? |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
…hartjs#3471) Make index mode only work with the horizontal distance to an element if intersect is off
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?