@@ -67,6 +67,7 @@ function newShapes(outlines, dragOptions) {
67
67
clearOutline ( gd ) ;
68
68
69
69
var editHelpers = dragOptions . editHelpers ;
70
+ var plotinfo = dragOptions . plotinfo ;
70
71
var modifyItem = ( editHelpers || { } ) . modifyItem ;
71
72
72
73
var allShapes = [ ] ;
@@ -84,10 +85,21 @@ function newShapes(outlines, dragOptions) {
84
85
case 'line' :
85
86
case 'rect' :
86
87
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
+ }
91
103
break ;
92
104
93
105
case 'path' :
0 commit comments