Skip to content

Commit 9358a56

Browse files
MFedMFed
MFed
authored and
MFed
committed
Fixing a bug where the x,y of the arrow would be changed to stay on the chart, rather than render off screen when panned. Added corresponding annotation to image test.
1 parent e83b947 commit 9358a56

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/components/annotations/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -500,13 +500,17 @@ annotations.draw = function(gd, index, opt, value) {
500500
// and the annotation center are visible
501501
if(options.showarrow) {
502502
if(options.axref === options.xref) {
503-
arrowX = Lib.constrain(annPosPx.x, 1, fullLayout.width - 1);
503+
//we don't want to constrain if the tail is absolute
504+
//or the slope (which is meaningful) will change.
505+
arrowX = annPosPx.x;
504506
} else {
505507
arrowX = Lib.constrain(annPosPx.x - options.ax, 1, fullLayout.width - 1);
506508
}
507509

508510
if(options.ayref === options.yref) {
509-
arrowY = Lib.constrain(annPosPx.y, 1, fullLayout.height - 1);
511+
//we don't want to constrain if the tail is absolute
512+
//or the slope (which is meaningful) will change.
513+
arrowY = annPosPx.y;
510514
} else {
511515
arrowY = Lib.constrain(annPosPx.y - options.ay, 1, fullLayout.height - 1);
512516
}

test/image/baselines/annotations.png

913 Bytes
Loading

test/image/mocks/annotations.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"font":{"color":"rgb(0, 0, 255)","size":20},
4343
"arrowcolor":"rgb(166, 28, 0)","borderpad":3,"textangle":50,"x":5,"y":1
4444
},
45-
{"text":"","showarrow":true,"borderwidth":1.2,"arrowhead":2,"axref":"x","ayref":"y","x":5,"y":5,"ax":4,"ay":3}
45+
{"text":"","showarrow":true,"borderwidth":1.2,"arrowhead":2,"axref":"x","ayref":"y","x":5,"y":3,"ax":4,"ay":5},
46+
{"text":"","showarrow":true,"borderwidth":1.2,"arrowhead":2,"axref":"x","ayref":"y","x":6,"y":2,"ax":3,"ay":3}
4647
]
4748
}
4849
}

0 commit comments

Comments
 (0)