@@ -69,12 +69,12 @@ exports.getDataToPixel = function(gd, axis, shift, isVertical, refType) {
6969 var shiftPixels = 0 ;
7070 if ( axis . type === 'category' || axis . type === 'multicategory' ) {
7171 if ( isVertical ) {
72- shiftPixels = - 1 * ( ( gs . h - axis . r2p ( d2r ( 0.5 , true ) ) ) * shift ) ;
72+ shiftPixels = ( ( axis . r2p ( 1 ) - axis . r2p ( 0 ) ) * shift ) ;
7373 } else {
74- shiftPixels = axis . r2p ( d2r ( 0.5 , true ) ) * shift ;
74+ shiftPixels = axis . r2p ( 0.5 ) * shift ;
7575 }
7676 }
77- return axis . _offset + axis . r2p ( d2r ( v , true ) ) + ( shiftPixels || 0 ) ;
77+ return axis . _offset + axis . r2p ( d2r ( v , true ) ) + shiftPixels ;
7878 } ;
7979
8080 if ( axis . type === 'date' ) dataToPixel = exports . decodeDate ( dataToPixel ) ;
@@ -187,8 +187,10 @@ exports.getPathString = function(gd, options) {
187187 var ya = Axes . getFromId ( gd , options . yref ) ;
188188 var gs = gd . _fullLayout . _size ;
189189 var x2r , x2p , y2r , y2p ;
190- var shiftUnitX = 0 ;
191- var shiftUnitY = 0 ;
190+ var xShiftStart = 0 ;
191+ var xShiftEnd = 0 ;
192+ var yShiftStart = 0 ;
193+ var yShiftEnd = 0 ;
192194 var x0 , x1 , y0 , y1 ;
193195
194196 if ( xa ) {
@@ -198,7 +200,9 @@ exports.getPathString = function(gd, options) {
198200 x2r = exports . shapePositionToRange ( xa ) ;
199201 x2p = function ( v ) { return xa . _offset + xa . r2p ( x2r ( v , true ) ) ; } ;
200202 if ( xa . type === 'category' || xa . type === 'multicategory' ) {
201- shiftUnitX = xa . r2p ( x2r ( 0.5 , true ) ) ;
203+ var shiftUnitX = xa . r2p ( 0.5 ) ;
204+ xShiftStart = shiftUnitX * options . x0shift ;
205+ xShiftEnd = shiftUnitX * options . x1shift ;
202206 }
203207 }
204208 } else {
@@ -212,7 +216,9 @@ exports.getPathString = function(gd, options) {
212216 y2r = exports . shapePositionToRange ( ya ) ;
213217 y2p = function ( v ) { return ya . _offset + ya . r2p ( y2r ( v , true ) ) ; } ;
214218 if ( ya . type === 'category' || ya . type === 'multicategory' ) {
215- shiftUnitY = gs . h - ya . r2p ( y2r ( 0.5 , true ) ) ;
219+ var shiftUnitY = ya . r2p ( 0 ) - ya . r2p ( 1 ) ;
220+ yShiftStart = shiftUnitY * options . y0shift ;
221+ yShiftEnd = shiftUnitY * options . y1shift ;
216222 }
217223 }
218224 } else {
@@ -226,20 +232,20 @@ exports.getPathString = function(gd, options) {
226232 }
227233 if ( options . xsizemode === 'pixel' ) {
228234 var xAnchorPos = x2p ( options . xanchor ) ;
229- x0 = xAnchorPos + options . x0 + shiftUnitX * options . xshift ;
230- x1 = xAnchorPos + options . x1 + shiftUnitX * options . xshift ;
235+ x0 = xAnchorPos + options . x0 + xShiftStart ;
236+ x1 = xAnchorPos + options . x1 + xShiftEnd ;
231237 } else {
232- x0 = x2p ( options . x0 ) + shiftUnitX * options . xshift ;
233- x1 = x2p ( options . x1 ) + shiftUnitX * options . xshift ;
238+ x0 = x2p ( options . x0 ) + xShiftStart ;
239+ x1 = x2p ( options . x1 ) + xShiftEnd ;
234240 }
235241
236242 if ( options . ysizemode === 'pixel' ) {
237243 var yAnchorPos = y2p ( options . yanchor ) ;
238- y0 = yAnchorPos - options . y0 - shiftUnitY * options . yshift ;
239- y1 = yAnchorPos - options . y1 - shiftUnitY * options . yshift ;
244+ y0 = yAnchorPos - options . y0 - yShiftStart ;
245+ y1 = yAnchorPos - options . y1 - yShiftEnd ;
240246 } else {
241- y0 = y2p ( options . y0 ) - shiftUnitY * options . yshift ;
242- y1 = y2p ( options . y1 ) - shiftUnitY * options . yshift ;
247+ y0 = y2p ( options . y0 ) - yShiftStart ;
248+ y1 = y2p ( options . y1 ) - yShiftEnd ;
243249 }
244250
245251 if ( type === 'line' ) return 'M' + x0 + ',' + y0 + 'L' + x1 + ',' + y1 ;
0 commit comments