Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions draftlogs/6796_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix range defaults to take into account minallowed and maxallowed values [[#6796](https://github.com/plotly/plotly.js/pull/6796)]
17 changes: 17 additions & 0 deletions src/plots/cartesian/set_convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,23 @@ module.exports = function setConvert(ax, fullLayout) {

if(minallowed !== undefined && rng[0] < bounds[0]) range[axrev ? 1 : 0] = minallowed;
if(maxallowed !== undefined && rng[1] > bounds[1]) range[axrev ? 0 : 1] = maxallowed;

if(range[0] === range[1]) {
var minL = ax.l2r(minallowed);
var maxL = ax.l2r(maxallowed);

if(minallowed !== undefined) {
var _max = minL + 1;
if(maxallowed !== undefined) _max = Math.min(_max, maxL);
range[axrev ? 1 : 0] = _max;
}

if(maxallowed !== undefined) {
var _min = maxL + 1;
if(minallowed !== undefined) _min = Math.max(_min, minL);
range[axrev ? 0 : 1] = _min;
}
}
};

/*
Expand Down
18 changes: 18 additions & 0 deletions src/plots/polar/polar.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,24 @@ proto.doAutoRange = function(fullLayout, polarLayout) {
radialAxis.r2l(rng[0], null, 'gregorian'),
radialAxis.r2l(rng[1], null, 'gregorian')
];

if(radialAxis.minallowed !== undefined) {
var minallowed = radialAxis.r2l(radialAxis.minallowed);
if(radialAxis._rl[0] > radialAxis._rl[1]) {
radialAxis._rl[1] = Math.max(radialAxis._rl[1], minallowed);
} else {
radialAxis._rl[0] = Math.max(radialAxis._rl[0], minallowed);
}
}

if(radialAxis.maxallowed !== undefined) {
var maxallowed = radialAxis.r2l(radialAxis.maxallowed);
if(radialAxis._rl[0] < radialAxis._rl[1]) {
radialAxis._rl[1] = Math.min(radialAxis._rl[1], maxallowed);
} else {
radialAxis._rl[0] = Math.min(radialAxis._rl[0], maxallowed);
}
}
};

proto.updateRadialAxis = function(fullLayout, polarLayout) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/zz-allowed-range.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 81 additions & 0 deletions test/image/mocks/zz-allowed-range-small.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"data": [
{
"type": "scatter",
"mode": "markers",
"xaxis": "x",
"yaxis": "y",
"x": [0,1,2,3,4,5,6,7,8,9,10],
"y":[0,10,20,30,40,50,60,70,80,90,100]
},
{
"type": "scatter",
"mode": "markers",
"xaxis": "x2",
"yaxis": "y2",
"x": [0,1,2,3,4,5,6,7,8,9,10],
"y":[0,10,20,30,40,50,60,70,80,90,100]
},
{
"type": "scatterpolar",
"mode": "markers",
"subplot": "polar",
"r": [0,1,2,3,4,5,6,7,8,9,10],
"theta":[0,10,20,30,40,50,60,70,80,90,100]
},
{
"type": "scatterpolar",
"mode": "markers",
"subplot": "polar2",
"r": [0,1,2,3,4,5,6,7,8,9,10],
"theta":[0,10,20,30,40,50,60,70,80,90,100]
}
],
"layout": {
"showlegend": false,
"width": 800,
"height": 800,
"xaxis": {
"anchor": "y",
"domain": [0, 0.45],
"maxallowed": 6.2,
"minallowed": 5.8
},
"yaxis": {
"anchor": "x",
"domain": [0, 0.45]
},
"xaxis2": {
"autorange": "reversed",
"anchor": "y2",
"domain": [0, 0.45],
"maxallowed": 6.2,
"minallowed": 5.8
},
"yaxis2": {
"anchor": "x2",
"domain": [0.55, 1]
},
"polar": {
"domain": {
"x": [0.55, 1],
"y": [0, 0.45]
},
"radialaxis": {
"maxallowed": 6.2,
"minallowed": 5.8
}
},
"polar2": {
"domain": {
"x": [0.55, 1],
"y": [0.55, 1]
},
"radialaxis": {
"autorange": "reversed",
"maxallowed": 6.2,
"minallowed": 5.8
}
}
}
}
77 changes: 77 additions & 0 deletions test/image/mocks/zz-allowed-range.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"data": [
{
"type": "scatter",
"mode": "markers",
"xaxis": "x",
"yaxis": "y",
"x": [0,1,2,3,4,5,6,7,8,9,10],
"y":[0,10,20,30,40,50,60,70,80,90,100]
},
{
"type": "scatter",
"mode": "markers",
"xaxis": "x2",
"yaxis": "y2",
"x": [0,1,2,3,4,5,6,7,8,9,10],
"y":[0,10,20,30,40,50,60,70,80,90,100]
},
{
"type": "scatterpolar",
"mode": "markers",
"subplot": "polar",
"r": [0,1,2,3,4,5,6,7,8,9,10],
"theta":[0,10,20,30,40,50,60,70,80,90,100]
},
{
"type": "scatterpolar",
"mode": "markers",
"subplot": "polar2",
"r": [0,1,2,3,4,5,6,7,8,9,10],
"theta":[0,10,20,30,40,50,60,70,80,90,100]
}
],
"layout": {
"showlegend": false,
"width": 800,
"height": 800,
"xaxis": {
"anchor": "y",
"domain": [0, 0.45],
"minallowed": 6
},
"yaxis": {
"anchor": "x",
"domain": [0, 0.45]
},
"xaxis2": {
"autorange": "reversed",
"anchor": "y2",
"domain": [0, 0.45],
"minallowed": 6
},
"yaxis2": {
"anchor": "x2",
"domain": [0.55, 1]
},
"polar": {
"domain": {
"x": [0.55, 1],
"y": [0, 0.45]
},
"radialaxis": {
"minallowed": 6
}
},
"polar2": {
"domain": {
"x": [0.55, 1],
"y": [0.55, 1]
},
"radialaxis": {
"autorange": "reversed",
"minallowed": 6
}
}
}
}