@@ -82,27 +82,27 @@ module.exports = function drawLabel(gd, index, options, shapeGroup) {
8282 } else {
8383 // Otherwise, we use the x and y bounds defined in the shape options
8484 // and convert them to pixel coordinates
85- // Setup conversion functions
86- var xa = Axes . getFromId ( gd , options . xref ) ;
87- var xShiftStart = options . x0shift ;
88- var xShiftEnd = options . x1shift ;
89- var xRefType = Axes . getRefType ( options . xref ) ;
90- var ya = Axes . getFromId ( gd , options . yref ) ;
91- var yShiftStart = options . y0shift ;
92- var yShiftEnd = options . y1shift ;
93- var yRefType = Axes . getRefType ( options . yref ) ;
94- var x2p = function ( v , shift ) {
95- var dataToPixel = helpers . getDataToPixel ( gd , xa , shift , false , xRefType ) ;
96- return dataToPixel ( v ) ;
85+ // Setup conversion functions, handling array refs for multi-axis shapes
86+ var isArrayXref = Array . isArray ( options . xref ) ;
87+ var isArrayYref = Array . isArray ( options . yref ) ;
88+ var xa0 = Axes . getFromId ( gd , isArrayXref ? options . xref [ 0 ] : options . xref ) ;
89+ var xa1 = Axes . getFromId ( gd , isArrayXref ? options . xref [ 1 ] : options . xref ) ;
90+ var ya0 = Axes . getFromId ( gd , isArrayYref ? options . yref [ 0 ] : options . yref ) ;
91+ var ya1 = Axes . getFromId ( gd , isArrayYref ? options . yref [ 1 ] : options . yref ) ;
92+ var xRefType0 = Axes . getRefType ( isArrayXref ? options . xref [ 0 ] : options . xref ) ;
93+ var xRefType1 = Axes . getRefType ( isArrayXref ? options . xref [ 1 ] : options . xref ) ;
94+ var yRefType0 = Axes . getRefType ( isArrayYref ? options . yref [ 0 ] : options . yref ) ;
95+ var yRefType1 = Axes . getRefType ( isArrayYref ? options . yref [ 1 ] : options . yref ) ;
96+ var x2p = function ( v , shift , xa , xRefType ) {
97+ return helpers . getDataToPixel ( gd , xa , shift , false , xRefType ) ( v ) ;
9798 } ;
98- var y2p = function ( v , shift ) {
99- var dataToPixel = helpers . getDataToPixel ( gd , ya , shift , true , yRefType ) ;
100- return dataToPixel ( v ) ;
99+ var y2p = function ( v , shift , ya , yRefType ) {
100+ return helpers . getDataToPixel ( gd , ya , shift , true , yRefType ) ( v ) ;
101101 } ;
102- shapex0 = x2p ( options . x0 , xShiftStart ) ;
103- shapex1 = x2p ( options . x1 , xShiftEnd ) ;
104- shapey0 = y2p ( options . y0 , yShiftStart ) ;
105- shapey1 = y2p ( options . y1 , yShiftEnd ) ;
102+ shapex0 = x2p ( options . x0 , options . x0shift , xa0 , xRefType0 ) ;
103+ shapex1 = x2p ( options . x1 , options . x1shift , xa1 , xRefType1 ) ;
104+ shapey0 = y2p ( options . y0 , options . y0shift , ya0 , yRefType0 ) ;
105+ shapey1 = y2p ( options . y1 , options . y1shift , ya1 , yRefType1 ) ;
106106 }
107107
108108 // Handle `auto` angle
0 commit comments