Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5357501

Browse files
committed
clear polar radial range viewInitial during log <-> linear relayout
1 parent 8b4c2b5 commit 5357501

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/plot_api/plot_api.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,6 +1944,12 @@ function _relayout(gd, aobj) {
19441944
ax.range = (ax.range[1] > ax.range[0]) ? [1, 2] : [2, 1];
19451945
}
19461946

1947+
// clear polar view initial stash for radial range so that
1948+
// value get recomputed in correct units
1949+
if(fullLayout._subplots.polar && fullLayout[p.parts[0]]) {
1950+
delete fullLayout[p.parts[0]]._subplot.viewInitial['radialaxis.range'];
1951+
}
1952+
19471953
// Annotations and images also need to convert to/from linearized coords
19481954
// Shapes do not need this :)
19491955
Registry.getComponentMethod('annotations', 'convertCoords')(gd, parentFull, vi, doextra);

test/jasmine/tests/polar_test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,21 @@ describe('Test relayout on polar subplots:', function() {
232232
var fig = Lib.extendDeep({}, require('@mocks/polar_scatter.json'));
233233

234234
Plotly.plot(gd, fig).then(function() {
235+
expect(gd._fullLayout.polar._subplot.viewInitial['radialaxis.range'])
236+
.toBeCloseToArray([0, 11.225]);
237+
235238
return Plotly.relayout(gd, 'polar.radialaxis.type', 'log');
236239
})
240+
.then(function() {
241+
expect(gd._fullLayout.polar._subplot.viewInitial['radialaxis.range'])
242+
.toBeCloseToArray([-0.53, 1.158]);
243+
244+
return Plotly.relayout(gd, 'polar.radialaxis.type', 'linear');
245+
})
246+
.then(function() {
247+
expect(gd._fullLayout.polar._subplot.viewInitial['radialaxis.range'])
248+
.toBeCloseToArray([0, 11.225]);
249+
})
237250
.catch(fail)
238251
.then(done);
239252
});

0 commit comments

Comments
 (0)