@@ -67,6 +67,7 @@ function newShapes(outlines, dragOptions) {
6767 clearOutline ( gd ) ;
6868
6969 var editHelpers = dragOptions . editHelpers ;
70+ var plotinfo = dragOptions . plotinfo ;
7071 var modifyItem = ( editHelpers || { } ) . modifyItem ;
7172
7273 var allShapes = [ ] ;
@@ -84,10 +85,21 @@ function newShapes(outlines, dragOptions) {
8485 case 'line' :
8586 case 'rect' :
8687 case 'circle' :
87- modifyItem ( 'x0' , afterEdit . x0 - ( beforeEdit . x0shift || 0 ) ) ;
88- modifyItem ( 'x1' , afterEdit . x1 - ( beforeEdit . x1shift || 0 ) ) ;
89- modifyItem ( 'y0' , afterEdit . y0 - ( beforeEdit . y0shift || 0 ) ) ;
90- modifyItem ( 'y1' , afterEdit . y1 - ( beforeEdit . y1shift || 0 ) ) ;
88+ if ( beforeEdit . xref . includes ( "x" ) && plotinfo . xaxis . type . includes ( "category" ) ) {
89+ plotinfo . xaxis . r2c ( afterEdit . x0 )
90+ modifyItem ( 'x0' , plotinfo . xaxis . r2c ( afterEdit . x0 ) - ( beforeEdit . x0shift || 0 ) ) ;
91+ modifyItem ( 'x1' , plotinfo . xaxis . r2c ( afterEdit . x1 ) - ( beforeEdit . x1shift || 0 ) ) ;
92+ } else {
93+ modifyItem ( 'x0' , afterEdit . x0 ) ;
94+ modifyItem ( 'x1' , afterEdit . x1 ) ;
95+ }
96+ if ( beforeEdit . yref . includes ( "y" ) && plotinfo . yaxis . type . includes ( "category" ) ) {
97+ modifyItem ( 'y0' , plotinfo . xaxis . r2c ( afterEdit . y0 ) - ( beforeEdit . y0shift || 0 ) ) ;
98+ modifyItem ( 'y1' , plotinfo . xaxis . r2c ( afterEdit . y1 ) - ( beforeEdit . y1shift || 0 ) ) ;
99+ } else {
100+ modifyItem ( 'y0' , afterEdit . y0 ) ;
101+ modifyItem ( 'y1' , afterEdit . y1 ) ;
102+ }
91103 break ;
92104
93105 case 'path' :
0 commit comments