@@ -528,9 +528,9 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) {
528528
529529proto . updateFx = function ( fullLayout , polarLayout ) {
530530 if ( ! this . gd . _context . staticPlot ) {
531- this . updateMainDrag ( fullLayout , polarLayout ) ;
532531 this . updateAngularDrag ( fullLayout , polarLayout ) ;
533532 this . updateRadialDrag ( fullLayout , polarLayout ) ;
533+ this . updateMainDrag ( fullLayout , polarLayout ) ;
534534 }
535535} ;
536536
@@ -858,6 +858,10 @@ proto.updateRadialDrag = function(fullLayout, polarLayout) {
858858 dragBox . clearSelect ( fullLayout . _zoomlayer ) ;
859859 } ;
860860
861+ // decrease min drag value to be able to catch smaller dx/dy that
862+ // can determine rotateMove vs rerangeMove
863+ dragOpts . minDrag = 2 ;
864+
861865 dragElement . init ( dragOpts ) ;
862866} ;
863867
@@ -871,17 +875,18 @@ proto.updateAngularDrag = function(fullLayout, polarLayout) {
871875 var cxx = _this . cxx ;
872876 var cyy = _this . cyy ;
873877 var sector = polarLayout . sector ;
878+ var dbs = constants . angularDragBoxSize ;
874879
875880 var angularDrag = dragBox . makeDragger ( layers , 'path' , 'angulardrag' , 'move' ) ;
876881 var dragOpts = { element : angularDrag , gd : gd } ;
877882
878883 d3 . select ( angularDrag )
879- . attr ( 'd' , pathAnnulus ( radius , radius + constants . angularDragBoxSize , sector ) )
884+ . attr ( 'd' , pathAnnulus ( radius , radius + dbs , sector ) )
880885 . attr ( 'transform' , strTranslate ( cx , cy ) )
881886 . call ( setCursor , 'move' ) ;
882887
883888 function xy2a ( x , y ) {
884- return Math . atan2 ( cyy - y , x - cxx ) ;
889+ return Math . atan2 ( cyy + dbs - y , x - cxx - dbs ) ;
885890 }
886891
887892 // scatter trace, points and textpoints selections
@@ -909,6 +914,10 @@ proto.updateAngularDrag = function(fullLayout, polarLayout) {
909914 strTranslate ( _this . xOffset2 , _this . yOffset2 ) + strRotate ( [ - da , cxx , cyy ] )
910915 ) ;
911916
917+ _this . clipPaths . circle . select ( 'path' ) . attr ( 'transform' ,
918+ strTranslate ( cxx , cyy ) + strRotate ( da )
919+ ) ;
920+
912921 // 'un-rotate' marker and text points
913922 scatterPoints . each ( function ( ) {
914923 var sel = d3 . select ( this ) ;
@@ -1111,29 +1120,42 @@ function pathSectorClosed(r, sector) {
11111120 ( isFullCircle ( sector ) ? '' : 'L0,0Z' ) ;
11121121}
11131122
1114- // inspired by https://gist.github.com/buschtoens/4190516
1115- function pathAnnulus ( r0 , r1 , _sector ) {
1116- var sector = _sector . slice ( ) ;
1117- var s0 = deg2rad ( sector [ 0 ] ) ;
1118- var s1 = deg2rad ( sector [ 1 ] ) ;
1119-
1120- // make a small cut on full sectors so that the
1121- // inner region isn't filled
1122- if ( isFullCircle ( sector ) ) s1 -= 1e-3 ;
1123+ // TODO recycle this routine with the ones used for pie traces.
1124+ function pathAnnulus ( r0 , r1 , sector ) {
1125+ var largeArc = Math . abs ( sector [ 1 ] - sector [ 0 ] ) <= 180 ? 0 : 1 ;
1126+ // sector angle at [s]tart, [m]iddle and [e]nd
1127+ var ss , sm , se ;
11231128
1124- var p00 = [ r0 * Math . cos ( s0 ) , - r0 * Math . sin ( s0 ) ] ;
1125- var p01 = [ r0 * Math . cos ( s1 ) , - r0 * Math . sin ( s1 ) ] ;
1126- var p10 = [ r1 * Math . cos ( s0 ) , - r1 * Math . sin ( s0 ) ] ;
1127- var p11 = [ r1 * Math . cos ( s1 ) , - r1 * Math . sin ( s1 ) ] ;
1129+ function pt ( r , s ) {
1130+ return [ r * Math . cos ( s ) , - r * Math . sin ( s ) ] ;
1131+ }
11281132
1129- var largeArc = Math . abs ( sector [ 1 ] - sector [ 0 ] ) <= 180 ? 0 : 1 ;
1133+ function arc ( r , s , cw ) {
1134+ return 'A' + [ r , r ] + ' ' + [ 0 , largeArc , cw ] + ' ' + pt ( r , s ) ;
1135+ }
11301136
1131- return 'M' + p00 +
1132- 'L' + p10 +
1133- 'A' + [ r1 , r1 ] + ' ' + [ 0 , largeArc , 0 ] + ' ' + p11 +
1134- 'L' + p01 +
1135- 'A' + [ r0 , r0 ] + ' ' + [ 0 , largeArc , 1 ] + ' ' + p00 +
1136- 'Z' ;
1137+ if ( isFullCircle ( sector ) ) {
1138+ ss = 0 ;
1139+ se = 2 * Math . PI ;
1140+ sm = Math . PI ;
1141+ return 'M' + pt ( r0 , ss ) +
1142+ arc ( r0 , sm , 0 ) +
1143+ arc ( r0 , se , 0 ) +
1144+ 'Z' +
1145+ 'M' + pt ( r1 , ss ) +
1146+ arc ( r1 , sm , 1 ) +
1147+ arc ( r1 , se , 1 ) +
1148+ 'Z' ;
1149+ } else {
1150+ ss = deg2rad ( sector [ 0 ] ) ;
1151+ se = deg2rad ( sector [ 1 ] ) ;
1152+ return 'M' + pt ( r0 , ss ) +
1153+ 'L' + pt ( r1 , ss ) +
1154+ arc ( r1 , se , 0 ) +
1155+ 'L' + pt ( r0 , se ) +
1156+ arc ( r0 , ss , 1 ) +
1157+ 'Z' ;
1158+ }
11371159}
11381160
11391161function isFullCircle ( sector ) {
0 commit comments