Skip to content

Commit c7ffaa6

Browse files
committed
fix relayout new insiderange and set range to null
1 parent 350a01c commit c7ffaa6

File tree

5 files changed

+54
-18
lines changed

5 files changed

+54
-18
lines changed

src/plots/cartesian/axis_defaults.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,17 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
9292

9393
setConvert(containerOut, layoutOut);
9494

95-
var insiderange;
96-
if(!options.noInsiderange && axType !== 'log') {
97-
insiderange = coerce('insiderange');
98-
}
99-
10095
coerce('minallowed');
10196
coerce('maxallowed');
102-
var range = coerce('range', insiderange);
97+
var range = coerce('range');
98+
if(!range) {
99+
var insiderange;
100+
if(!options.noInsiderange && axType !== 'log') {
101+
insiderange = coerce('insiderange');
102+
range = coerce('range', insiderange);
103+
}
104+
}
105+
103106
var autorangeDflt = containerOut.getAutorangeDflt(range, options);
104107
var autorange = coerce('autorange', autorangeDflt);
105108

src/plots/cartesian/layout_attributes.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,15 +401,15 @@ module.exports = {
401401
insiderange: {
402402
valType: 'info_array',
403403
items: [
404-
{valType: 'any', editType: 'axrange'},
405-
{valType: 'any', editType: 'axrange'}
404+
{valType: 'any', editType: 'plot'},
405+
{valType: 'any', editType: 'plot'}
406406
],
407-
editType: 'axrange',
407+
editType: 'plot',
408408
description: [
409409
'Could be used to set the desired inside range of this axis',
410410
'(excluding the labels) when `ticklabelposition` of',
411411
'the anchored axis has *inside*.',
412-
'Not implemented for axes with `type` *log*',
412+
'Not implemented for axes with `type` *log*.',
413413
'This would be ignored when `range` is provided.'
414414
].join(' ')
415415
},

test/jasmine/tests/axes_test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,37 @@ describe('Test axes', function() {
16061606
});
16071607
});
16081608

1609+
describe('insiderange relayout', function() {
1610+
var gd;
1611+
1612+
beforeEach(function() {
1613+
gd = createGraphDiv();
1614+
});
1615+
1616+
afterEach(destroyGraphDiv);
1617+
1618+
it('can relayout insiderange', function(done) {
1619+
Plotly.newPlot(gd, [{
1620+
y: [1, 3, 2, 4]}
1621+
], {
1622+
xaxis: {insiderange: [0, 2]},
1623+
yaxis: {ticklabelposition: 'inside'},
1624+
plot_bgcolor: 'lightgray',
1625+
width: 600,
1626+
height: 600
1627+
}).then(function() {
1628+
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([-0.132, 2]);
1629+
1630+
return Plotly.relayout(gd, {
1631+
'xaxis.insiderange': [1, 3],
1632+
'xaxis.range': null
1633+
});
1634+
}).then(function() {
1635+
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([0.867, 3]);
1636+
}).then(done, done.fail);
1637+
});
1638+
});
1639+
16091640
describe('constraints relayout', function() {
16101641
var gd;
16111642

test/jasmine/tests/click_test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,7 @@ describe('Test click interactions:', function() {
10551055
], {
10561056
xaxis: {insiderange: [null, 1]},
10571057
yaxis: {ticks: 'inside', ticklabelposition: 'inside'},
1058+
plot_bgcolor: 'lightgray',
10581059
width: 600,
10591060
height: 600
10601061
}).then(function() {
@@ -1081,6 +1082,7 @@ describe('Test click interactions:', function() {
10811082
], {
10821083
xaxis: {insiderange: [1, null]},
10831084
yaxis: {ticks: 'inside', ticklabelposition: 'inside', side: 'right'},
1085+
plot_bgcolor: 'lightgray',
10841086
width: 600,
10851087
height: 600
10861088
}).then(function() {

test/plot-schema.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10893,15 +10893,15 @@
1089310893
"valType": "string"
1089410894
},
1089510895
"insiderange": {
10896-
"description": "Could be used to set the desired inside range of this axis (excluding the labels) when `ticklabelposition` of the anchored axis has *inside*. Not implemented for axes with `type` *log* This would be ignored when `range` is provided.",
10897-
"editType": "axrange",
10896+
"description": "Could be used to set the desired inside range of this axis (excluding the labels) when `ticklabelposition` of the anchored axis has *inside*. Not implemented for axes with `type` *log*. This would be ignored when `range` is provided.",
10897+
"editType": "plot",
1089810898
"items": [
1089910899
{
10900-
"editType": "axrange",
10900+
"editType": "plot",
1090110901
"valType": "any"
1090210902
},
1090310903
{
10904-
"editType": "axrange",
10904+
"editType": "plot",
1090510905
"valType": "any"
1090610906
}
1090710907
],
@@ -12233,15 +12233,15 @@
1223312233
"valType": "string"
1223412234
},
1223512235
"insiderange": {
12236-
"description": "Could be used to set the desired inside range of this axis (excluding the labels) when `ticklabelposition` of the anchored axis has *inside*. Not implemented for axes with `type` *log* This would be ignored when `range` is provided.",
12237-
"editType": "axrange",
12236+
"description": "Could be used to set the desired inside range of this axis (excluding the labels) when `ticklabelposition` of the anchored axis has *inside*. Not implemented for axes with `type` *log*. This would be ignored when `range` is provided.",
12237+
"editType": "plot",
1223812238
"items": [
1223912239
{
12240-
"editType": "axrange",
12240+
"editType": "plot",
1224112241
"valType": "any"
1224212242
},
1224312243
{
12244-
"editType": "axrange",
12244+
"editType": "plot",
1224512245
"valType": "any"
1224612246
}
1224712247
],

0 commit comments

Comments
 (0)