@@ -58,7 +58,7 @@ function draw(gd) {
5858} 
5959
6060/* 
61-  * drawOne: draw a single annotation, potentially with modifications 
61+  * drawOne: draw a single cartesian or paper-ref  annotation, potentially with modifications 
6262 * 
6363 * index (int): the annotation to draw 
6464 */ 
@@ -68,28 +68,33 @@ function drawOne(gd, index) {
6868    var  xa  =  Axes . getFromId ( gd ,  options . xref ) ; 
6969    var  ya  =  Axes . getFromId ( gd ,  options . yref ) ; 
7070
71-     drawRaw ( gd ,  options ,  index ,  xa ,  ya ) ; 
71+     drawRaw ( gd ,  options ,  index ,  false ,   xa ,  ya ) ; 
7272} 
7373
74- /* 
74+ /**  
7575 * drawRaw: draw a single annotation, potentially with modifications 
7676 * 
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 
8184 */ 
82- function  drawRaw ( gd ,  options ,  index ,  xa ,  ya )  { 
85+ function  drawRaw ( gd ,  options ,  index ,  subplotId ,   xa ,  ya )  { 
8386    var  fullLayout  =  gd . _fullLayout ; 
8487    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+     } 
9398
9499    // remove the existing annotation if there is one 
95100    fullLayout . _infolayer 
@@ -515,7 +520,7 @@ function drawRaw(gd, options, index, xa, ya) {
515520
516521            // the arrow dragger is a small square right at the head, then a line to the tail, 
517522            // 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 )  { 
519524                var  arrowDragHeadX  =  headX ; 
520525                var  arrowDragHeadY  =  headY ; 
521526                if ( options . standoff )  { 
@@ -625,7 +630,7 @@ function drawRaw(gd, options, index, xa, ya) {
625630
626631                        drawArrow ( dx ,  dy ) ; 
627632                    } 
628-                     else  if ( ! options . _sceneId )  { 
633+                     else  if ( ! subplotId )  { 
629634                        if ( xa )  update [ annbase  +  '.x' ]  =  options . x  +  dx  /  xa . _m ; 
630635                        else  { 
631636                            var  widthFraction  =  options . _xsize  /  gs . w , 
0 commit comments