Skip to content

Commit 1122907

Browse files
committed
fix and 🔒 maindrag when polar.hole>0
1 parent 9c3dcef commit 1122907

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/plots/polar/polar.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ proto.updateMainDrag = function(fullLayout) {
629629
var cyy = _this.cyy;
630630
var sectorInRad = _this.sectorInRad;
631631
var vangles = _this.vangles;
632+
var radialAxis = _this.radialAxis;
632633
var clampTiny = helpers.clampTiny;
633634
var findXYatLength = helpers.findXYatLength;
634635
var findEnclosingVertexAngles = helpers.findEnclosingVertexAngles;
@@ -840,16 +841,13 @@ proto.updateMainDrag = function(fullLayout) {
840841

841842
dragBox.showDoubleClickNotifier(gd);
842843

843-
var radialAxis = _this.radialAxis;
844844
var rl = radialAxis._rl;
845-
var drl = rl[1] - rl[0];
846-
var updateObj = {};
847-
updateObj[_this.id + '.radialaxis.range'] = [
848-
rl[0] + r0 * drl / radius,
849-
rl[0] + r1 * drl / radius
845+
var m = (rl[1] - rl[0]) / (1 - innerRadius / radius) / radius;
846+
var newRng = [
847+
rl[0] + (r0 - innerRadius) * m,
848+
rl[0] + (r1 - innerRadius) * m
850849
];
851-
852-
Registry.call('relayout', gd, updateObj);
850+
Registry.call('relayout', gd, _this.id + '.radialaxis.range', newRng);
853851
}
854852

855853
dragOpts.prepFn = function(evt, startX, startY) {

test/jasmine/tests/polar_test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,13 @@ describe('Test polar interactions:', function() {
924924
expect(eventCnts.plotly_relayout)
925925
.toBe(relayoutNumber, 'no new relayout events after *not far enough* cases');
926926
})
927+
.then(_reset)
928+
.then(function() { return Plotly.relayout(gd, 'polar.hole', 0.2); })
929+
.then(function() { relayoutNumber++; })
930+
.then(function() { return _drag([mid[0] + 30, mid[0] - 30], [50, -50]); })
931+
.then(function() {
932+
_assertDrag([1.15, 7.70], 'with polar.hole>0, from quadrant #1 move top-right');
933+
})
927934
.catch(failTest)
928935
.then(done);
929936
});

0 commit comments

Comments
 (0)