-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Introducing splom traces #2505
8000New 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
Introducing splom traces #2505
Changes from 1 commit
44dc3d8
c56e35e
29ca0ed
8b5af93
3be9569
76c64e5
59588cc
66494c7
20f01cc
c5cda6b
89fb6bb
9cac919
fda1b34
cf485b7
fc6c895
7be161b
80dd61e
0fb65dd
d50746b
a3c87da
c4c1514
469e4cd
c0c5a6e
d02f572
60df466
e7b02c0
658c529
2b6c58e
eab3768
b6359ef
a37abfb
4470447
aaa42c6
a077c3f
f442f59
4f68cba
07d59d5
2a048a9
697a127
32118b0
bb11313
1bc95d5
419458c
9162265
e14013b
22e8c7e
d072121
02ed2eb
3ad1eaa
bb02281
d07ae70
468119e
0979272
ebb35ce
37b585e
92a37c8
ce379a1
f9090b7
b28052b
f2569c3
b283919
571950e
76d8ace
2d39ea7
7f916b0
0c901b5
1193e6c
99712dd
129e1f2
b2ee736
a6f2664
5f0c828
0d5a638
a0b2574
7ae7159
d4a2a53
f07ff4b
fa8adee
d3fe40d
cc1b3de
45266ed
a0caefd
2e6b610
980855c
f7d637d
da81a0e
74abb7f
062d4a3
978a70e
b868959
e38a0a6
651901d
9aea0ba
71a0395
24dad16
9d0bcfd
6fd6919
31e34fa
a79f5dc
31836f2
6cc634a
c7b81ec
8e9eaff
ad5abb6
c98071f
2d93469
6c5a1e7
a7b08b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ var calcMarkerSize = require('../scatter/calc').calcMarkerSize; | |
var calcAxisExpansion = require('../scatter/calc').calcAxisExpansion; | ||
var calcColorscales = require('../scatter/colorscale_calc'); | ||
var convertMarkerStyle = require('../scattergl/convert').convertMarkerStyle; | ||
var getTraceColor = require('../scatter/get_trace_color'); | ||
var calcHover = require('../scattergl').calcHover; | ||
|
||
var BADNUM = require('../../constants/numerical').BADNUM; | ||
var TOO_MANY_POINTS = require('../scattergl/constants').TOO_MANY_POINTS; | ||
|
@@ -214,123 +214,46 @@ function hoverPoints(pointData, xval, yval, hovermode) { | |
if(trace.yaxes[i] === ya._id) yi = i; | ||
} | ||
|
||
var xData = dimensions[xi].values; | ||
var yData = dimensions[yi].values; | ||
var x = dimensions[xi].values; | ||
var y = dimensions[yi].values; | ||
|
||
var id, ptx, pty, dx, dy, dist, dxy; | ||
var minDist = maxDistance; | ||
|
||
if(hovermode === 'x') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK sure, that'll make people happier until we do a better job with defaults - just make a comment about why we're omitting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed for now. |
||
for(i = 0; i < xData.length; i++) { | ||
ptx = xData[i]; | ||
for(i = 0; i < x.length; i++) { | ||
ptx = x[i]; | ||
dx = Math.abs(xa.c2p(ptx) - xpx); | ||
if(dx < maxDistance) { | ||
maxDistance = dx; | ||
dy = ya.c2p(yData[i]) - ypx; | ||
if(dx < minDist) { | ||
minDist = dx; | ||
dy = ya.c2p(y[i]) - ypx; | ||
dxy = Math.sqrt(dx * dx + dy * dy); | ||
id = i; | ||
} | ||
} | ||
} | ||
else { | ||
for(i = 0; i < xData.length; i++) { | ||
ptx = xData[i]; | ||
pty = yData[i]; | ||
for(i = 0; i < x.length; i++) { | ||
ptx = x[i]; | ||
pty = y[i]; | ||
dx = xa.c2p(ptx) - xpx; | ||
dy = ya.c2p(pty) - ypx; | ||
|
||
dist = Math.sqrt(dx * dx + dy * dy); | ||
if(dist < maxDistance) { | ||
maxDistance = dxy = dist; | ||
if(dist < minDist) { | ||
minDist = dxy = dist; | ||
id = i; | ||
} | ||
} | ||
} | ||
|
||
pointData.index = id; | ||
|
||
pointData.distance = minDist; | ||
pointData.dxy = dxy; | ||
|
||
if(id === undefined) return [pointData]; | ||
|
||
// the closest data point | ||
var di = { | ||
pointNumber: id, | ||
x: xData[id], | ||
y: yData[id] | ||
}; | ||
|
||
|
||
// that is single-item arrays_to_calcdata excerpt, since we are doing it for a single point and we don't have to do it beforehead for 1e6 points | ||
// FIXME: combine with scattergl hover di calc | ||
di.tx = Array.isArray(trace.text) ? trace.text[id] : trace.text; | ||
di.htx = Array.isArray(trace.hovertext) ? trace.hovertext[id] : trace.hovertext; | ||
di.data = Array.isArray(trace.customdata) ? trace.customdata[id] : trace.customdata; | ||
di.tp = Array.isArray(trace.textposition) ? trace.textposition[id] : trace.textposition; | ||
|
||
var font = trace.textfont; | ||
if(font) { | ||
di.ts = Array.isArray(font.size) ? font.size[id] : font.size; | ||
di.tc = Array.isArray(font.color) ? font.color[id] : font.color; | ||
di.tf = Array.isArray(font.family) ? font.family[id] : font.family; | ||
} | ||
|
||
var marker = trace.marker; | ||
if(marker) { | ||
di.ms = Lib.isArrayOrTypedArray(marker.size) ? marker.size[id] : marker.size; | ||
di.mo = Lib.isArrayOrTypedArray(marker.opacity) ? marker.opacity[id] : marker.opacity; | ||
di.mx = Array.isArray(marker.symbol) ? marker.symbol[id] : marker.symbol; | ||
di.mc = Lib.isArrayOrTypedArray(marker.color) ? marker.color[id] : marker.color; | ||
} | ||
|
||
var line = marker && marker.line; | ||
if(line) { | ||
di.mlc = Array.isArray(line.color) ? line.color[id] : line.color; | ||
di.mlw = Lib.isArrayOrTypedArray(line.width) ? line.width[id] : line.width; | ||
} | ||
|
||
var grad = marker && marker.gradient; | ||
if(grad && grad.type !== 'none') { | ||
di.mgt = Array.isArray(grad.type) ? grad.type[id] : grad.type; | ||
di.mgc = Array.isArray(grad.color) ? grad.color[id] : grad.color; | ||
} | ||
|
||
var xp = xa.c2p(di.x, true); | ||
var yp = ya.c2p(di.y, true); | ||
var rad = di.mrc || 1; | ||
|
||
var hoverlabel = trace.hoverlabel; | ||
|
||
if(hoverlabel) { | ||
di.hbg = Array.isArray(hoverlabel.bgcolor) ? hoverlabel.bgcolor[id] : hoverlabel.bgcolor; | ||
di.hbc = Array.isArray(hoverlabel.bordercolor) ? hoverlabel.bordercolor[id] : hoverlabel.bordercolor; | ||
di.hts = Array.isArray(hoverlabel.font.size) ? hoverlabel.font.size[id] : hoverlabel.font.size; | ||
di.htc = Array.isArray(hoverlabel.font.color) ? hoverlabel.font.color[id] : hoverlabel.font.color; | ||
di.htf = Array.isArray(hoverlabel.font.family) ? hoverlabel.font.family[id] : hoverlabel.font.family; | ||
di.hnl = Array.isArray(hoverlabel.namelength) ? hoverlabel.namelength[id] : hoverlabel.namelength; | ||
} | ||
var hoverinfo = trace.hoverinfo; | ||
if(hoverinfo) { | ||
di.hi = Array.isArray(hoverinfo) ? hoverinfo[id] : hoverinfo; | ||
} | ||
|
||
|
||
var fakeCd = {}; | ||
fakeCd[pointData.index] = di; | ||
|
||
Lib.extendFlat(pointData, { | ||
color: getTraceColor(trace, di), | ||
|
||
x0: xp - rad, | ||
x1: xp + rad, | ||
xLabelVal: di.x, | ||
|
||
y0: yp - rad, | ||
y1: yp + rad, | ||
yLabelVal: di.y, | ||
|
||
cd: fakeCd, | ||
distance: maxDistance, | ||
spikeDistance: dxy | ||
}); | ||
calcHover(pointData, x, y, trace); | ||
|
||
return [pointData]; | ||
} | ||
|
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.
It's a little weird to use compare mode for splom - I guess maybe there could be uses for it, but especially since the same data will appear as both x and y, compare mode will confuse people. Eventually we should default to
closest
when there's a splom, see #778. For now lets just encourage splom users to specifyclosest
explicitly.