Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c79d993

Browse files
committed
hover basic functionality (and much of the code for zoom/pan/select) in ternary
1 parent f43fe64 commit c79d993

File tree

5 files changed

+316
-13
lines changed

5 files changed

+316
-13
lines changed

src/components/errorbars/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ errorBars.plot = require('./plot');
4646
errorBars.style = require('./style');
4747

4848
errorBars.hoverInfo = function(calcPoint, trace, hoverPoint) {
49-
if(trace.error_y.visible) {
49+
if((trace.error_y || {}).visible) {
5050
hoverPoint.yerr = calcPoint.yh - calcPoint.y;
5151
if(!trace.error_y.symmetric) hoverPoint.yerrneg = calcPoint.y - calcPoint.ys;
5252
}
53-
if(trace.error_x.visible) {
53+
if((trace.error_x || {}).visible) {
5454
hoverPoint.xerr = calcPoint.xh - calcPoint.x;
5555
if(!trace.error_x.symmetric) hoverPoint.xerrneg = calcPoint.x - calcPoint.xs;
5656
}

src/plots/cartesian/dragbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
155155
lum = gd._hmpixcount ?
156156
(gd._hmlumcount / gd._hmpixcount) :
157157
tinycolor(gd._fullLayout.plot_bgcolor).getLuminance();
158-
path0 = path0 = 'M0,0H'+pw+'V'+ph+'H0V0';
158+
path0 = 'M0,0H'+pw+'V'+ph+'H0V0';
159159
dimmed = false;
160160
zoomMode = 'xy';
161161

src/plots/cartesian/graph_interact.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,15 @@ function hover(gd, evt, subplot) {
313313
.map(function(pi) { return pi.id; })),
314314

315315
xaArray = subplots.map(function(spId) {
316+
if(spId.substr(0,7) === 'ternary') {
317+
return gd._fullLayout[spId]._ternary.xaxis;
318+
}
316319
return Plotly.Axes.getFromId(gd, spId, 'x');
317320
}),
318321
yaArray = subplots.map(function(spId) {
322+
if(spId.substr(0,7) === 'ternary') {
323+
return gd._fullLayout[spId]._ternary.yaxis;
324+
}
319325
return Plotly.Axes.getFromId(gd, spId, 'y');
320326
}),
321327
hovermode = evt.hovermode || fullLayout.hovermode;
@@ -366,7 +372,7 @@ function hover(gd, evt, subplot) {
366372
for(curvenum = 0; curvenum<gd.calcdata.length; curvenum++) {
367373
cd = gd.calcdata[curvenum];
368374
trace = cd[0].trace;
369-
if(trace.hoverinfo!=='none' && subplots.indexOf(trace.xaxis + trace.yaxis)!==-1) {
375+
if(trace.hoverinfo!=='none' && subplots.indexOf(getSubplot(trace))!==-1) {
370376
searchData.push(cd);
371377
}
372378
}
@@ -431,7 +437,7 @@ function hover(gd, evt, subplot) {
431437
if(!cd || !cd[0] || !cd[0].trace || cd[0].trace.visible !== true) continue;
432438

433439
trace = cd[0].trace;
434-
subploti = subplots.indexOf(trace.xaxis + trace.yaxis);
440+
subploti = subplots.indexOf(getSubplot(trace));
435441

436442
// within one trace mode can sometimes be overridden
437443
mode = hovermode;
@@ -575,6 +581,12 @@ function hover(gd, evt, subplot) {
575581
});
576582
}
577583

584+
// look for either .subplot (currently just ternary)
585+
// or xaxis and yaxis attributes
586+
function getSubplot(trace) {
587+
return trace.subplot || (trace.xaxis + trace.yaxis);
588+
}
589+
578590
fx.getDistanceFunction = function(mode, dx, dy, dxy) {
579591
if(mode==='closest') return dxy || quadrature(dx, dy);
580592
return mode==='x' ? dx : dy;

0 commit comments

Comments
 (0)