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
};

src/traces/scatterternary/event_data.js

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

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-
127
if(cd[pointNumber]) {
138
var cdi = cd[pointNumber];
149

src/traces/waterfall/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
};

test/jasmine/tests/click_test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ describe('Test click interactions:', function() {
117117
var pt = futureData.points[0];
118118
expect(Object.keys(pt).sort()).toEqual([
119119
'data', 'fullData', 'curveNumber', 'pointNumber', 'pointIndex',
120-
'bbox', 'x0', 'x1', 'y0', 'y1',
120+
'bbox',
121121
'x', 'y', 'xaxis', 'yaxis'
122122
].sort());
123123
expect(pt.curveNumber).toEqual(0);
@@ -151,7 +151,7 @@ describe('Test click interactions:', function() {
151151
var pt = futureData.points[0];
152152
expect(Object.keys(pt).sort()).toEqual([
153153
'data', 'fullData', 'curveNumber', 'pointNumber', 'pointIndex',
154-
'bbox', 'x0', 'x1', 'y0', 'y1',
154+
'bbox',
155155
'x', 'y', 'xaxis', 'yaxis'
156156
].sort());
157157
expect(pt.curveNumber).toEqual(0);
@@ -223,7 +223,7 @@ describe('Test click interactions:', function() {
223223
var pt = futureData.points[0];
224224
expect(Object.keys(pt).sort()).toEqual([
225225
'data', 'fullData', 'curveNumber', 'pointNumber', 'pointIndex',
226-
'bbox', 'x0', 'x1', 'y0', 'y1',
226+
'bbox',
227227
'x', 'y', 'xaxis', 'yaxis'
228228
].sort());
229229
expect(pt.curveNumber).toEqual(0);
@@ -313,7 +313,7 @@ describe('Test click interactions:', function() {
313313
var pt = futureData.points[0];
314314
expect(Object.keys(pt).sort()).toEqual([
315315
'data', 'fullData', 'curveNumber', 'pointNumber', 'pointIndex',
316-
'bbox', 'x0', 'x1', 'y0', 'y1',
316+
'bbox',
317317
'x', 'y', 'xaxis', 'yaxis'
318318
].sort());
319319
expect(pt.curveNumber).toEqual(0);
@@ -347,7 +347,7 @@ describe('Test click interactions:', function() {
347347
var pt = futureData.points[0];
348348
expect(Object.keys(pt).sort()).toEqual([
349349
'data', 'fullData', 'curveNumber', 'pointNumber', 'pointIndex',
350-
'bbox', 'x0', 'x1', 'y0', 'y1',
350+
'bbox',
351351
'x', 'y', 'xaxis', 'yaxis'
352352
].sort());
353353
expect(pt.curveNumber).toEqual(0);
@@ -385,7 +385,7 @@ describe('Test click interactions:', function() {
385385
var pt = futureData.points[0];
386386
expect(Object.keys(pt).sort()).toEqual([
387387
'data', 'fullData', 'curveNumber', 'pointNumber', 'pointIndex',
388-
'bbox', 'x0', 'x1', 'y0', 'y1',
388+
'bbox',
389389
'x', 'y', 'xaxis', 'yaxis'
390390
].sort());
391391
expect(pt.curveNumber).toEqual(0);

test/jasmine/tests/funnelarea_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ describe('funnelarea hovering', function() {
763763

764764
var fields = [
765765
'curveNumber', 'pointNumber', 'pointNumbers',
766-
'data', 'fullData', 'bbox',
766+
'data', 'fullData',
767767
'label', 'color', 'value',
768768
'percent', 'text'
769769
];

test/jasmine/tests/pie_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,9 +1101,9 @@ describe('pie hovering', function() {
11011101

11021102
var fields = [
11031103
'curveNumber', 'pointNumber', 'pointNumbers',
1104-
'data', 'fullData', 'bbox',
1104+
'data', 'fullData',
11051105
'label', 'color', 'value',
1106-
'i', 'v', 'percent', 'text',
1106+
'i', 'v', 'percent', 'text'
11071107
];
11081108

11091109
expect(Object.keys(hoverData.points[0]).sort()).toEqual(fields.sort());

test/jasmine/tests/ternary_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var assertHoverLabelContent = customAssertions.assertHoverLabelContent;
2222
var SORTED_EVENT_KEYS = [
2323
'data', 'fullData', 'curveNumber', 'pointNumber', 'pointIndex',
2424
'xaxis', 'yaxis', 'a', 'b', 'c',
25-
'bbox', 'x0', 'x1', 'y0', 'y1'
25+
'bbox'
2626
].sort();
2727

2828
describe('ternary plots', function() {

0 commit comments

Comments
 (0)