Skip to content

Commit

Permalink
handle case of nonnegative rangemode for inside ticklabels
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Dec 9, 2020
1 parent 6a4a6c5 commit bc38ade
Show file tree
Hide file tree
Showing 3 changed files with 193 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/plots/cartesian/autorange.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,13 @@ function makePadFn(fullLayout, ax, max) {
var A = 0;
var B = 0;
if(!isLinked(fullLayout, ax._id)) {
A = padInsideLabelsOnAnchorAxis(ax, max);
B = padInsideLabelsOnThisAxis(ax, max);
if(ax.rangemode !== 'nonnegative') {
A = padInsideLabelsOnAnchorAxis(ax, max);

if(anchorAxis.rangemode !== 'nonnegative') {
B = padInsideLabelsOnThisAxis(ax, max);
}
}
}

var zero = Math.max(A, B);
Expand Down
Binary file added test/image/baselines/ticklabelposition-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
186 changes: 186 additions & 0 deletions test/image/mocks/ticklabelposition-5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
{
"data": [{
"xaxis": "x",
"yaxis": "y",
"type": "bar",
"orientation": "h",
"x": [
67.5,
23.3,
5.2,
1.8,
0.8,
0.7,
0.23,
0.1,
0.1
],
"y": [
"Hydro",
"Solid biomass",
"Wind",
"Ethanol",
"Renewable municipal waste",
"Solar thermal",
"Biodiesel",
"Solar photovoltaic",
"Tidal"
]
}, {
"xaxis": "x2",
"yaxis": "y2",
"type": "bar",
"orientation": "h",
"x": [
67.5,
23.3,
5.2,
1.8,
0.8,
0.7,
0.23,
0.1,
0.1
],
"y": [
"Hydro",
"Solid biomass",
"Wind",
"Ethanol",
"Renewable municipal waste",
"Solar thermal",
"Biodiesel",
"Solar photovoltaic",
"Tidal"
]
}, {
"xaxis": "x3",
"yaxis": "y3",
"type": "bar",
"orientation": "v",
"y": [
67.5,
23.3,
5.2,
1.8,
0.8,
0.7,
0.23,
0.1,
0.1
],
"x": [
"Hydro",
"Solid biomass",
"Wind",
"Ethanol",
"Renewable municipal waste",
"Solar thermal",
"Biodiesel",
"Solar photovoltaic",
"Tidal"
]
}, {
"xaxis": "x4",
"yaxis": "y4",
"type": "bar",
"orientation": "v",
"y": [
67.5,
23.3,
5.2,
1.8,
0.8,
0.7,
0.23,
0.1,
0.1
],
"x": [
"Hydro",
"Solid biomass",
"Wind",
"Ethanol",
"Renewable municipal waste",
"Solar thermal",
"Biodiesel",
"Solar photovoltaic",
"Tidal"
]
}],
"layout": {
"xaxis": {
"rangemode": "nonnegative",
"anchor": "y",
"domain": [0, 0.475],
"side": "bottom",
"ticklabelposition": "outside",
"gridcolor": "white"
},
"yaxis": {
"anchor": "x",
"domain": [0, 0.475],
"side": "left",
"ticklabelposition": "inside",
"gridcolor": "white"
},
"xaxis2": {
"rangemode": "nonnegative",
"anchor": "y2",
"domain": [0.525, 1],
"side": "bottom",
"ticklabelposition": "inside",
"gridcolor": "white"
},
"yaxis2": {
"anchor": "x2",
"domain": [0, 0.475],
"side": "right",
"ticklabelposition": "inside",
"gridcolor": "white"
},
"xaxis3": {
"anchor": "y3",
"domain": [0.525, 1],
"side": "top",
"ticklabelposition": "inside",
"gridcolor": "white"
},
"yaxis3": {
"rangemode": "nonnegative",
"anchor": "x3",
"domain": [0.525, 1],
"side": "right",
"ticklabelposition": "inside",
"gridcolor": "white"
},
"xaxis4": {
"anchor": "y4",
"domain": [0, 0.475],
"side": "top",
"ticklabelposition": "inside",
"gridcolor": "white"
},
"yaxis4": {
"rangemode": "nonnegative",
"anchor": "x4",
"domain": [0.525, 1],
"side": "left",
"ticklabelposition": "outside",
"gridcolor": "white"
},
"font": {
"size": 24
},
"plot_bgcolor": "lightblue",
"showlegend": false,
"width": 1000,
"height": 1000,
"margin": {
"t": 40,
"b": 40,
"l": 40,
"r": 40
}
}
}

0 comments on commit bc38ade

Please sign in to comment.