diff --git a/package.json b/package.json index f5b0f7157a1..fc5a7dac605 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,6 @@ "dependencies": { "3d-view": "^2.0.0", "alpha-shape": "^1.0.0", - "arraytools": "^1.0.0", "color-rgba": "^1.0.4", "convex-hull": "^1.0.3", "country-regex": "^1.1.0", diff --git a/src/plots/cartesian/axis_defaults.js b/src/plots/cartesian/axis_defaults.js index 49691e9400c..631255c5a9f 100644 --- a/src/plots/cartesian/axis_defaults.js +++ b/src/plots/cartesian/axis_defaults.js @@ -47,7 +47,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, return Lib.coerce2(containerIn, containerOut, layoutAttributes, attr, dflt); } - coerce('visible', !options.cheateronly); + var visible = coerce('visible', !options.cheateronly); var axType = containerOut.type; @@ -58,6 +58,20 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, setConvert(containerOut, layoutOut); + var autoRange = coerce('autorange', !containerOut.isValidRange(containerIn.range)); + + if(autoRange) coerce('rangemode'); + + coerce('range'); + containerOut.cleanRange(); + + handleCategoryOrderDefaults(containerIn, containerOut, coerce); + containerOut._initialCategories = axType === 'category' ? + orderedCategories(letter, containerOut.categoryorder, containerOut.categoryarray, options.data) : + []; + + if(!visible) return containerOut; + var dfltColor = coerce('color'); // if axis.color was provided, use it for fonts too; otherwise, // inherit from global font color in case that was provided. @@ -70,17 +84,9 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, color: dfltFontColor }); - var autoRange = coerce('autorange', !containerOut.isValidRange(containerIn.range)); - - if(autoRange) coerce('rangemode'); - - coerce('range'); - containerOut.cleanRange(); - handleTickValueDefaults(containerIn, containerOut, coerce, axType); handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options); handleTickMarkDefaults(containerIn, containerOut, coerce, options); - handleCategoryOrderDefaults(containerIn, containerOut, coerce); var lineColor = coerce2('linecolor', dfltColor), lineWidth = coerce2('linewidth'), @@ -111,10 +117,5 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, delete containerOut.zerolinewidth; } - // fill in categories - containerOut._initialCategories = axType === 'category' ? - orderedCategories(letter, containerOut.categoryorder, containerOut.categoryarray, options.data) : - []; - return containerOut; }; diff --git a/src/plots/gl3d/layout/convert.js b/src/plots/gl3d/layout/convert.js index 1bba5caebbe..19814841d76 100644 --- a/src/plots/gl3d/layout/convert.js +++ b/src/plots/gl3d/layout/convert.js @@ -9,12 +9,9 @@ 'use strict'; -var arrtools = require('arraytools'); var convertHTMLToUnicode = require('../../../lib/html2unicode'); var str2RgbaArray = require('../../../lib/str2rgbarray'); -var arrayCopy1D = arrtools.copy1D; - var AXES_NAMES = ['xaxis', 'yaxis', 'zaxis']; function AxesOptions() { @@ -64,9 +61,9 @@ function AxesOptions() { [0.8, 0.8, 0.8, 0.5] ]; // some default values are stored for applying model transforms - this._defaultTickPad = arrayCopy1D(this.tickPad); - this._defaultLabelPad = arrayCopy1D(this.labelPad); - this._defaultLineTickLength = arrayCopy1D(this.lineTickLength); + this._defaultTickPad = this.tickPad.slice(); + this._defaultLabelPad = this.labelPad.slice(); + this._defaultLineTickLength = this.lineTickLength.slice(); } var proto = AxesOptions.prototype; @@ -76,6 +73,17 @@ proto.merge = function(sceneLayout) { for(var i = 0; i < 3; ++i) { var axes = sceneLayout[AXES_NAMES[i]]; + if(!axes.visible) { + opts.tickEnable[i] = false; + opts.labelEnable[i] = false; + opts.lineEnable[i] = false; + opts.lineTickEnable[i] = false; + opts.gridEnable[i] = false; + opts.zeroEnable[i] = false; + opts.backgroundEnable[i] = false; + continue; + } + // Axes labels opts.labels[i] = convertHTMLToUnicode(axes.title); if('titlefont' in axes) { diff --git a/src/plots/gl3d/layout/spikes.js b/src/plots/gl3d/layout/spikes.js index b835642f7cb..4d63677f25b 100644 --- a/src/plots/gl3d/layout/spikes.js +++ b/src/plots/gl3d/layout/spikes.js @@ -28,6 +28,12 @@ proto.merge = function(sceneLayout) { for(var i = 0; i < 3; ++i) { var axes = sceneLayout[AXES_NAMES[i]]; + if(!axes.visible) { + this.enabled[i] = false; + this.drawSides[i] = false; + continue; + } + this.enabled[i] = axes.showspikes; this.colors[i] = str2RGBArray(axes.spikecolor); this.drawSides[i] = axes.spikesides; diff --git a/test/image/baselines/axes_visible-false.png b/test/image/baselines/axes_visible-false.png new file mode 100644 index 00000000000..3f12542a06e Binary files /dev/null and b/test/image/baselines/axes_visible-false.png differ diff --git a/test/image/baselines/gl3d_axes-visible-false.png b/test/image/baselines/gl3d_axes-visible-false.png new file mode 100644 index 00000000000..dab999eeddb Binary files /dev/null and b/test/image/baselines/gl3d_axes-visible-false.png differ diff --git a/test/image/mocks/axes_visible-false.json b/test/image/mocks/axes_visible-false.json new file mode 100644 index 00000000000..8caca6b9d5a --- /dev/null +++ b/test/image/mocks/axes_visible-false.json @@ -0,0 +1,9 @@ +{ + "data": [{ + "y": [1, 2, 3] + }], + "layout": { + "xaxis": { "visible": false }, + "yaxis": { "visible": false } + } +} diff --git a/test/image/mocks/gl3d_axes-visible-false.json b/test/image/mocks/gl3d_axes-visible-false.json new file mode 100644 index 00000000000..34b03edac11 --- /dev/null +++ b/test/image/mocks/gl3d_axes-visible-false.json @@ -0,0 +1,22 @@ +{ + "data": [{ + "type": "scatter3d", + "x": [1, 2, 3], + "y": [1, 2, 3], + "z": [1, 2, 0] + }], + "layout": { + "scene": { + "xaxis": { "visible": false }, + "yaxis": { "visible": false }, + "zaxis": { "visible": false }, + "camera": { + "eye": { + "x": -0.1, + "y": 0.2, + "z": 2.1 + } + } + } + } +}