Skip to content

Commit 18c8190

Browse files
committed
fix insiderange react
1 parent c7ffaa6 commit 18c8190

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

src/plot_api/helpers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ exports.cleanLayout = function(layout) {
7272
ax.autorange = true;
7373
ax.rangemode = 'tozero';
7474
}
75+
76+
if(ax.insiderange) delete ax.range;
77+
7578
delete ax.islog;
7679
delete ax.isdate;
7780
delete ax.categories; // replaced by _categories

src/plot_api/plot_api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ function _doPlot(gd, data, layout, config) {
355355
drawAxes,
356356
function insideTickLabelsAutorange(gd) {
357357
if(gd._fullLayout._insideTickLabelsUpdaterange) {
358-
relayout(gd, gd._fullLayout._insideTickLabelsUpdaterange).then(function() {
358+
return relayout(gd, gd._fullLayout._insideTickLabelsUpdaterange).then(function() {
359359
Axes.saveRangeInitial(gd, true);
360360

361361
gd._fullLayout._insideTickLabelsUpdaterange = undefined;

test/jasmine/tests/axes_test.js

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,8 +1628,7 @@ describe('Test axes', function() {
16281628
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([-0.132, 2]);
16291629

16301630
return Plotly.relayout(gd, {
1631-
'xaxis.insiderange': [1, 3],
1632-
'xaxis.range': null
1631+
'xaxis.insiderange': [1, 3]
16331632
});
16341633
}).then(function() {
16351634
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([0.867, 3]);
@@ -7955,6 +7954,40 @@ describe('more react tests', function() {
79557954
})
79567955
.then(done, done.fail);
79577956
});
7957+
7958+
it('insiderange react to new data', function(done) {
7959+
var layout = {
7960+
xaxis: {
7961+
insiderange: [0, 2]
7962+
},
7963+
yaxis: {
7964+
ticklabelposition: 'inside'
7965+
},
7966+
plot_bgcolor: 'lightgray',
7967+
width: 600,
7968+
height: 600
7969+
};
7970+
7971+
var data1 = [{
7972+
y: [1, 3, 2]
7973+
}];
7974+
7975+
var data2 = [{
7976+
y: [1000, 3000, 2000]
7977+
}];
7978+
7979+
var fig1 = {data: data1, layout: layout};
7980+
var fig2 = {data: data2, layout: layout};
7981+
7982+
Plotly.newPlot(gd, fig1)
7983+
.then(function() {
7984+
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([-0.132, 2]);
7985+
7986+
return Plotly.react(gd, fig2);
7987+
}).then(function() {
7988+
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([-0.179, 2]);
7989+
}).then(done, done.fail);
7990+
});
79587991
});
79597992

79607993
describe('category preservation tests on gd passed to Plotly.react()', function() {

0 commit comments

Comments
 (0)