Skip to content

Commit fc79461

Browse files
committed
declare isReversed() function
1 parent 595a00c commit fc79461

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

src/plots/cartesian/autorange.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ function getAutoRange(gd, ax) {
8787
if(ax.autorange === 'reversed') {
8888
axReverse = true;
8989
ax.autorange = true;
90+
} else if(ax.autorange === 'min reversed') {
91+
axReverse = true;
92+
ax.autorange = 'min';
93+
} else if(ax.autorange === 'max reversed') {
94+
axReverse = true;
95+
ax.autorange = 'max';
9096
}
9197

9298
var rangeMode = ax.rangemode;
@@ -214,7 +220,7 @@ function makePadFn(fullLayout, ax, max) {
214220
(ax.ticklabelposition || '').indexOf('inside') !== -1 ||
215221
(anchorAxis.ticklabelposition || '').indexOf('inside') !== -1
216222
) {
217-
var axReverse = ax.autorange === 'reversed';
223+
var axReverse = ax.isReversed();
218224
if(!axReverse) {
219225
var rng = Lib.simpleMap(ax.range, ax.r2l);
220226
axReverse = rng[1] < rng[0];

src/plots/cartesian/set_convert.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,15 @@ module.exports = function setConvert(ax, fullLayout) {
901901
return autorangeDflt;
902902
};
903903

904+
ax.isReversed = function() {
905+
var autorange = ax.autorange;
906+
return (
907+
autorange === 'reversed' ||
908+
autorange === 'min reversed' ||
909+
autorange === 'max reversed'
910+
);
911+
};
912+
904913
ax.isPtWithinRange = function(d, calendar) {
905914
var coord = ax.c2l(d[axLetter], null, calendar);
906915
var r0 = ax.r2l(ax.range[0]);

src/plots/gl3d/scene.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ proto.plot = function(sceneData, fullLayout, layout) {
738738
sceneBounds[0][i] = range[0];
739739
sceneBounds[1][i] = range[1];
740740

741-
if(axis.autorange === 'reversed') {
741+
if(axis.isReversed()) {
742742
// swap bounds:
743743
var tmp = sceneBounds[0][i];
744744
sceneBounds[0][i] = sceneBounds[1][i];

src/plots/polar/layout_defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function handleDefaults(contIn, contOut, coerce, opts) {
8989
handleAutorangeOptionsDefaults(coerceAxis);
9090

9191
if(axType === 'linear' || axType === '-') coerceAxis('rangemode');
92-
if(autoRange === 'reversed') axOut._m = -1;
92+
if(axOut.isReversed()) axOut._m = -1;
9393
}
9494

9595
axOut.cleanRange('range', {dfltRange: [0, 1]});

0 commit comments

Comments
 (0)