@@ -58,7 +58,7 @@ function draw(gd) {
58
58
}
59
59
60
60
/*
61
- * drawOne: draw a single annotation, potentially with modifications
61
+ * drawOne: draw a single cartesian or paper-ref annotation, potentially with modifications
62
62
*
63
63
* index (int): the annotation to draw
64
64
*/
@@ -68,28 +68,33 @@ function drawOne(gd, index) {
68
68
var xa = Axes . getFromId ( gd , options . xref ) ;
69
69
var ya = Axes . getFromId ( gd , options . yref ) ;
70
70
71
- drawRaw ( gd , options , index , xa , ya ) ;
71
+ drawRaw ( gd , options , index , false , xa , ya ) ;
72
72
}
73
73
74
- /*
74
+ /**
75
75
* drawRaw: draw a single annotation, potentially with modifications
76
76
*
77
- * options (object): this annotation's options
78
- * index (int): the annotation to draw
79
- * xa (object | undefined): full x-axis object to compute subplot pos-to-px
80
- * ya (object | undefined): ... y-axis
77
+ * @param {DOM element } gd
78
+ * @param {object } options : this annotation's fullLayout options
79
+ * @param {integer } index : index in 'annotations' container of the annotation to draw
80
+ * @param {string } subplotId : id of the annotation's subplot
81
+ * - use false for 2d (i.e. cartesian or paper-ref) annotations
82
+ * @param {object | undefined } xa : full x-axis object to compute subplot pos-to-px
83
+ * @param {object | undefined } ya : ... y-axis
81
84
*/
82
- function drawRaw ( gd , options , index , xa , ya ) {
85
+ function drawRaw ( gd , options , index , subplotId , xa , ya ) {
83
86
var fullLayout = gd . _fullLayout ;
84
87
var gs = gd . _fullLayout . _size ;
85
-
86
- var className = options . _sceneId ?
87
- 'annotation-' + options . _sceneId :
88
- 'annotation' ;
89
-
90
- var annbase = options . _sceneId ?
91
- options . _sceneId + '.annotations[' + index + ']' :
92
- 'annotations[' + index + ']' ;
88
+ var className ;
89
+ var annbase ;
90
+
91
+ if ( subplotId ) {
92
+ className = 'annotation-' + subplotId ;
93
+ annbase = subplotId + '.annotations[' + index + ']' ;
94
+ } else {
95
+ className = 'annotation' ;
96
+ annbase = 'annotations[' + index + ']' ;
97
+ }
93
98
94
99
// remove the existing annotation if there is one
95
100
fullLayout . _infolayer
@@ -515,7 +520,7 @@ function drawRaw(gd, options, index, xa, ya) {
515
520
516
521
// the arrow dragger is a small square right at the head, then a line to the tail,
517
522
// all expanded by a stroke width of 6px plus the arrow line width
518
- if ( gd . _context . editable && arrow . node ( ) . parentNode && ! options . _sceneId ) {
523
+ if ( gd . _context . editable && arrow . node ( ) . parentNode && ! subplotId ) {
519
524
var arrowDragHeadX = headX ;
520
525
var arrowDragHeadY = headY ;
521
526
if ( options . standoff ) {
@@ -625,7 +630,7 @@ function drawRaw(gd, options, index, xa, ya) {
625
630
626
631
drawArrow ( dx , dy ) ;
627
632
}
628
- else if ( ! options . _sceneId ) {
633
+ else if ( ! subplotId ) {
629
634
if ( xa ) update [ annbase + '.x' ] = options . x + dx / xa . _m ;
630
635
else {
631
636
var widthFraction = options . _xsize / gs . w ,
0 commit comments