Skip to content

Hover on fills #673

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

Merged
merged 17 commits into from
Jun 22, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/traces/heatmap/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
'use strict';

var Fx = require('../../plots/cartesian/graph_interact');
var constants = require('../../plots/cartesian/constants');
var Lib = require('../../lib');


module.exports = function hoverPoints(pointData, xval, yval, hovermode, contour) {
// never let a heatmap override another type as closest point
if(pointData.distance < Fx.MAXDIST) return;
if(pointData.distance < constants.MAXDIST) return;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@etpinard I didn't notice you fixed this issue in #655 too - but when I merged master back in I used your version, which is cleaner.


var cd0 = pointData.cd[0],
trace = cd0.trace,
Expand Down Expand Up @@ -46,8 +47,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, contour)
return;
}
}
else if(Fx.inbox(xval - x[0], xval - x[x.length - 1]) > Fx.MAXDIST ||
Fx.inbox(yval - y[0], yval - y[y.length - 1]) > Fx.MAXDIST) {
else if(Fx.inbox(xval - x[0], xval - x[x.length - 1]) > constants.MAXDIST ||
Fx.inbox(yval - y[0], yval - y[y.length - 1]) > constants.MAXDIST) {
return;
}
else {
Expand Down Expand Up @@ -99,7 +100,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, contour)
return [Lib.extendFlat(pointData, {
index: [ny, nx],
// never let a 2D override 1D type as closest point
distance: Fx.MAXDIST + 10,
distance: constants.MAXDIST + 10,
x0: x0,
x1: x1,
y0: y0,
Expand Down
3 changes: 2 additions & 1 deletion src/traces/scatter/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

var Lib = require('../../lib');
var Fx = require('../../plots/cartesian/graph_interact');
var constants = require('../../plots/cartesian/constants');
var ErrorBars = require('../../components/errorbars');
var getTraceColor = require('./get_trace_color');
var Color = require('../../components/color');
Expand Down Expand Up @@ -59,7 +60,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {

Lib.extendFlat(pointData, {
// never let a 2D override 1D type as closest point
distance: Fx.MAXDIST + 10,
distance: constants.MAXDIST + 10,
Copy link
Contributor

Choose a reason for hiding this comment

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

why the + 10 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

same as heatmap - other types will return a distance that's no bigger than MAXDIST, so as long as we make this distance more than that, any matching scatter points always win. +10 is arbitrary, but I suppose we could make a priority ladder by making this different from heatmap in case of overlaps? Or leave them identical so trace order is the tiebreaker (though I don't actually know whether the first or last match will get it... I guess for visual consistency it should be the last trace, wouldn't it be clever if I wrote it that way???)

Copy link
Contributor

Choose a reason for hiding this comment

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

Parity with heatmaps is fine for now. Thanks for the clarification. 👍

x0: x0,
x1: x1,
y0: y0,
Expand Down