Skip to content

Commit 03b22ec

Browse files
committed
revise bbox positions
1 parent 6078118 commit 03b22ec

File tree

16 files changed

+25
-85
lines changed

16 files changed

+25
-85
lines changed

src/components/fx/helpers.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,6 @@ exports.makeEventData = function(pt, trace, cd) {
138138
if('yVal' in pt) out.y = pt.yVal;
139139
else if('y' in pt) out.y = pt.y;
140140

141-
if('x0' in pt) out.x0 = pt.x0;
142-
if('x1' in pt) out.x1 = pt.x1;
143-
if('y0' in pt) out.y0 = pt.y0;
144-
if('y1' in pt) out.y1 = pt.y1;
145-
146141
if(pt.xa) out.xaxis = pt.xa;
147142
if(pt.ya) out.yaxis = pt.ya;
148143
if(pt.zLabelVal !== undefined) out.z = pt.zLabelVal;

src/components/fx/hover.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -752,12 +752,14 @@ function _hover(gd, evt, subplot, noHoverEvent) {
752752
pt.hovertemplate = ht || pt.trace.hovertemplate || false;
753753
}
754754

755-
var bbox = {};
756-
if('x0' in pt) bbox.x0 = pt.x0 + pt.xa._offset + gLeft;
757-
if('x1' in pt) bbox.x1 = pt.x1 + pt.xa._offset + gLeft;
758-
if('y0' in pt) bbox.y0 = pt.y0 + pt.ya._offset + gTop;
759-
if('y1' in pt) bbox.y1 = pt.y1 + pt.ya._offset + gTop;
760-
eventData.bbox = bbox;
755+
if(pt.xa && pt.ya) {
756+
eventData.bbox = {
757+
x0: pt.x0 + pt.xa._offset + gLeft,
758+
x1: pt.x1 + pt.xa._offset + gLeft,
759+
y0: pt.y0 + pt.ya._offset + gTop,
760+
y1: pt.y1 + pt.ya._offset + gTop
761+
};
762+
}
761763

762764
pt.eventData = [eventData];
763765
newhoverdata.push(eventData);

src/traces/bar/event_data.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ module.exports = function eventData(out, pt, trace) {
77
if(pt.xa) out.xaxis = pt.xa;
88
if(pt.ya) out.yaxis = pt.ya;
99

10-
if('x0' in pt) out.x0 = pt.x0;
11-
if('x1' in pt) out.x1 = pt.x1;
12-
if('y0' in pt) out.y0 = pt.y0;
13-
if('y1' in pt) out.y1 = pt.y1;
14-
1510
if(trace.orientation === 'h') {
1611
out.label = out.y;
1712
out.value = out.x;

src/traces/box/event_data.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,5 @@ module.exports = function eventData(out, pt) {
1111
if(pt.xa) out.xaxis = pt.xa;
1212
if(pt.ya) out.yaxis = pt.ya;
1313

14-
if('x0' in pt) out.x0 = pt.x0;
15-
if('x1' in pt) out.x1 = pt.x1;
16-
if('y0' in pt) out.y0 = pt.y0;
17-
if('y1' in pt) out.y1 = pt.y1;
18-
1914
return out;
2015
};

src/traces/funnel/event_data.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,5 @@ module.exports = function eventData(out, pt /* , trace, cd, pointNumber */) {
1313
if(pt.xa) out.xaxis = pt.xa;
1414
if(pt.ya) out.yaxis = pt.ya;
1515

16-
if('x0' in pt) out.x0 = pt.x0;
17-
if('x1' in pt) out.x1 = pt.x1;
18-
if('y0' in pt) out.y0 = pt.y0;
19-
if('y1' in pt) out.y1 = pt.y1;
20-
2116
return out;
2217
};

src/traces/histogram/event_data.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) {
1111
if(pt.xa) out.xaxis = pt.xa;
1212
if(pt.ya) out.yaxis = pt.ya;
1313

14-
if('x0' in pt) out.x0 = pt.x0;
15-
if('x1' in pt) out.x1 = pt.x1;
16-
if('y0' in pt) out.y0 = pt.y0;
17-
if('y1' in pt) out.y1 = pt.y1;
18-
1914
// specific to histogram - CDFs do not have pts (yet?)
2015
if(!(trace.cumulative || {}).enabled) {
2116
var pts = Array.isArray(pointNumber) ?

src/traces/image/event_data.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
module.exports = function eventData(out, pt) {
44
if('xVal' in pt) out.x = pt.xVal;
55
if('yVal' in pt) out.y = pt.yVal;
6-
7-
if('x0' in pt) out.x0 = pt.x0;
8-
if('x1' in pt) out.x1 = pt.x1;
9-
if('y0' in pt) out.y0 = pt.y0;
10-
if('y1' in pt) out.y1 = pt.y1;
11-
126
if(pt.xa) out.xaxis = pt.xa;
137
if(pt.ya) out.yaxis = pt.ya;
148
out.color = pt.color;

src/traces/pie/event_data.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,7 @@ module.exports = function eventData(pt, trace) {
1818
text: pt.text,
1919

2020
// pt.v (and pt.i below) for backward compatibility
21-
v: pt.v,
22-
23-
// TODO: These coordinates aren't quite correct and don't take into account some offset
24-
// I still haven't quite located (similar to xa._offset)
25-
bbox: {
26-
x0: pt.x0,
27-
x1: pt.x1,
28-
y0: pt.y0,
29-
y1: pt.y1,
30-
},
21+
v: pt.v
3122
};
3223

3324
// Only include pointNumber if it's unambiguous

src/traces/pie/plot.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -379,19 +379,12 @@ function attachFxHandlers(sliceTop, gd, cd) {
379379

380380
if(hoverinfo === 'all') hoverinfo = 'label+text+value+percent+name';
381381

382-
// If hoverinfo === 'none', we still want the *coordinates* of hover to be
383-
// output, just not the hover to actually display
384-
var rInscribed = pt.rInscribed || 0;
385-
var hoverCenterX = cx + pt.pxmid[0] * (1 - rInscribed);
386-
var hoverCenterY = cy + pt.pxmid[1] * (1 - rInscribed);
387-
pt.x0 = hoverCenterX - rInscribed * cd0.r;
388-
pt.x1 = hoverCenterX + rInscribed * cd0.r;
389-
pt.y0 = hoverCenterY;
390-
pt.y1 = hoverCenterY;
391-
392382
// in case we dragged over the pie from another subplot,
393383
// or if hover is turned off
394384
if(trace2.hovertemplate || (hoverinfo !== 'none' && hoverinfo !== 'skip' && hoverinfo)) {
385+
var rInscribed = pt.rInscribed || 0;
386+
var hoverCenterX = cx + pt.pxmid[0] * (1 - rInscribed);
387+
var hoverCenterY = cy + pt.pxmid[1] * (1 - rInscribed);
395388
var separators = fullLayout2.separators;
396389
var text = [];
397390

@@ -413,9 +406,9 @@ function attachFxHandlers(sliceTop, gd, cd) {
413406

414407
Fx.loneHover({
415408
trace: trace,
416-
x0: pt.x0,
417-
x1: pt.x1,
418-
y: pt.y0,
409+
x0: hoverCenterX - rInscribed * cd0.r,
410+
x1: hoverCenterX + rInscribed * cd0.r,
411+
y: hoverCenterY,
419412
text: text.join('<br>'),
420413
name: (trace2.hovertemplate || hoverinfo.indexOf('name') !== -1) ? trace2.name : undefined,
421414
idealAlign: pt.pxmid[0] < 0 ? 'left' : 'right',

src/traces/scattercarpet/event_data.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,5 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) {
77
out.b = cdi.b;
88
out.y = cdi.y;
99

10-
if('x0' in pt) out.x0 = pt.x0;
11-
if('x1' in pt) out.x1 = pt.x1;
12-
if('y0' in pt) out.y0 = pt.y0;
13-
if('y1' in pt) out.y1 = pt.y1;
14-
1510
return out;
1611
};

0 commit comments

Comments
 (0)