Skip to content

Commit 092006a

Browse files
committed
add 'inner' radial dragbox to all polar subplots
so that: - we don't have to worry about ordering on relayouts - subplots on non-full-circle sectors can have functioning inner radial dragboxes.
1 parent 5a998a2 commit 092006a

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/plots/polar/polar.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,8 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) {
610610
proto.updateFx = function(fullLayout, polarLayout) {
611611
if(!this.gd._context.staticPlot) {
612612
this.updateAngularDrag(fullLayout);
613+
this.updateRadialDrag(fullLayout, polarLayout, 0);
613614
this.updateRadialDrag(fullLayout, polarLayout, 1);
614-
if(this.innerRadius) this.updateRadialDrag(fullLayout, polarLayout, 0);
615615
this.updateMainDrag(fullLayout);
616616
}
617617
};
@@ -934,6 +934,8 @@ proto.updateRadialDrag = function(fullLayout, polarLayout, rngIndex) {
934934
var cx = _this.cx;
935935
var cy = _this.cy;
936936
var radialAxis = _this.radialAxis;
937+
var bl = constants.radialDragBoxSize;
938+
var bl2 = bl / 2;
937939

938940
if(!radialAxis.visible) return;
939941

@@ -944,20 +946,23 @@ proto.updateRadialDrag = function(fullLayout, polarLayout, rngIndex) {
944946
var rbase = rl[rngIndex];
945947
var m = 0.75 * (rl[1] - rl[0]) / (1 - polarLayout.hole) / radius;
946948

947-
var bl = constants.radialDragBoxSize;
948-
var bl2 = bl / 2;
949-
var className = 'radialdrag' + (rngIndex ? '' : '-inner');
950-
var radialDrag = dragBox.makeRectDragger(layers, className, 'crosshair', -bl2, -bl2, bl, bl);
951-
var dragOpts = {element: radialDrag, gd: gd};
952-
953-
var tx, ty;
949+
var tx, ty, className;
954950
if(rngIndex) {
955951
tx = cx + (radius + bl2) * Math.cos(angle0);
956952
ty = cy - (radius + bl2) * Math.sin(angle0);
953+
className = 'radialdrag';
957954
} else {
955+
// the 'inner' box can get called:
956+
// - when polar.hole>0
957+
// - when polar.sector isn't a full circle
958+
// otherwise it is hidden behind the main drag.
958959
tx = cx + (innerRadius - bl2) * Math.cos(angle0);
959960
ty = cy - (innerRadius - bl2) * Math.sin(angle0);
961+
className = 'radialdrag-inner';
960962
}
963+
964+
var radialDrag = dragBox.makeRectDragger(layers, className, 'crosshair', -bl2, -bl2, bl, bl);
965+
var dragOpts = {element: radialDrag, gd: gd};
961966
d3.select(radialDrag).attr('transform', strTranslate(tx, ty));
962967

963968
// move function (either rotate or re-range flavor)

0 commit comments

Comments
 (0)