Skip to content

Commit c2a7092

Browse files
authored
Merge pull request #1599 from plotly/axis-visible-3d
Axis visible in 3D
2 parents f1e8aee + bc0f890 commit c2a7092

File tree

8 files changed

+66
-21
lines changed

8 files changed

+66
-21
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
"dependencies": {
5656
"3d-view": "^2.0.0",
5757
"alpha-shape": "^1.0.0",
58-
"arraytools": "^1.0.0",
5958
"color-rgba": "^1.0.4",
6059
"convex-hull": "^1.0.3",
6160
"country-regex": "^1.1.0",

src/plots/cartesian/axis_defaults.js

+15-14
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
4747
return Lib.coerce2(containerIn, containerOut, layoutAttributes, attr, dflt);
4848
}
4949

50-
coerce('visible', !options.cheateronly);
50+
var visible = coerce('visible', !options.cheateronly);
5151

5252
var axType = containerOut.type;
5353

@@ -58,6 +58,20 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
5858

5959
setConvert(containerOut, layoutOut);
6060

61+
var autoRange = coerce('autorange', !containerOut.isValidRange(containerIn.range));
62+
63+
if(autoRange) coerce('rangemode');
64+
65+
coerce('range');
66+
containerOut.cleanRange();
67+
68+
handleCategoryOrderDefaults(containerIn, containerOut, coerce);
69+
containerOut._initialCategories = axType === 'category' ?
70+
orderedCategories(letter, containerOut.categoryorder, containerOut.categoryarray, options.data) :
71+
[];
72+
73+
if(!visible) return containerOut;
74+
6175
var dfltColor = coerce('color');
6276
// if axis.color was provided, use it for fonts too; otherwise,
6377
// inherit from global font color in case that was provided.
@@ -70,17 +84,9 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
7084
color: dfltFontColor
7185
});
7286

73-
var autoRange = coerce('autorange', !containerOut.isValidRange(containerIn.range));
74-
75-
if(autoRange) coerce('rangemode');
76-
77-
coerce('range');
78-
containerOut.cleanRange();
79-
8087
handleTickValueDefaults(containerIn, containerOut, coerce, axType);
8188
handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options);
8289
handleTickMarkDefaults(containerIn, containerOut, coerce, options);
83-
handleCategoryOrderDefaults(containerIn, containerOut, coerce);
8490

8591
var lineColor = coerce2('linecolor', dfltColor),
8692
lineWidth = coerce2('linewidth'),
@@ -111,10 +117,5 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
111117
delete containerOut.zerolinewidth;
112118
}
113119

114-
// fill in categories
115-
containerOut._initialCategories = axType === 'category' ?
116-
orderedCategories(letter, containerOut.categoryorder, containerOut.categoryarray, options.data) :
117-
[];
118-
119120
return containerOut;
120121
};

src/plots/gl3d/layout/convert.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99

1010
'use strict';
1111

12-
var arrtools = require('arraytools');
1312
var convertHTMLToUnicode = require('../../../lib/html2unicode');
1413
var str2RgbaArray = require('../../../lib/str2rgbarray');
1514

16-
var arrayCopy1D = arrtools.copy1D;
17-
1815
var AXES_NAMES = ['xaxis', 'yaxis', 'zaxis'];
1916

2017
function AxesOptions() {
@@ -64,9 +61,9 @@ function AxesOptions() {
6461
[0.8, 0.8, 0.8, 0.5] ];
6562

6663
// some default values are stored for applying model transforms
67-
this._defaultTickPad = arrayCopy1D(this.tickPad);
68-
this._defaultLabelPad = arrayCopy1D(this.labelPad);
69-
this._defaultLineTickLength = arrayCopy1D(this.lineTickLength);
64+
this._defaultTickPad = this.tickPad.slice();
65+
this._defaultLabelPad = this.labelPad.slice();
66+
this._defaultLineTickLength = this.lineTickLength.slice();
7067
}
7168

7269
var proto = AxesOptions.prototype;
@@ -76,6 +73,17 @@ proto.merge = function(sceneLayout) {
7673
for(var i = 0; i < 3; ++i) {
7774
var axes = sceneLayout[AXES_NAMES[i]];
7875

76+
if(!axes.visible) {
77+
opts.tickEnable[i] = false;
78+
opts.labelEnable[i] = false;
79+
opts.lineEnable[i] = false;
80+
opts.lineTickEnable[i] = false;
81+
opts.gridEnable[i] = false;
82+
opts.zeroEnable[i] = false;
83+
opts.backgroundEnable[i] = false;
84+
continue;
85+
}
86+
7987
// Axes labels
8088
opts.labels[i] = convertHTMLToUnicode(axes.title);
8189
if('titlefont' in axes) {

src/plots/gl3d/layout/spikes.js

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ proto.merge = function(sceneLayout) {
2828
for(var i = 0; i < 3; ++i) {
2929
var axes = sceneLayout[AXES_NAMES[i]];
3030

31+
if(!axes.visible) {
32+
this.enabled[i] = false;
33+
this.drawSides[i] = false;
34+
continue;
35+
}
36+
3137
this.enabled[i] = axes.showspikes;
3238
this.colors[i] = str2RGBArray(axes.spikecolor);
3339
this.drawSides[i] = axes.spikesides;
14.8 KB
Loading
8.29 KB
Loading
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"data": [{
3+
"y": [1, 2, 3]
4+
}],
5+
"layout": {
6+
"xaxis": { "visible": false },
7+
"yaxis": { "visible": false }
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"data": [{
3+
"type": "scatter3d",
4+
"x": [1, 2, 3],
5+
"y": [1, 2, 3],
6+
"z": [1, 2, 0]
7+
}],
8+
"layout": {
9+
"scene": {
10+
"xaxis": { "visible": false },
11+
"yaxis": { "visible": false },
12+
"zaxis": { "visible": false },
13+
"camera": {
14+
"eye": {
15+
"x": -0.1,
16+
"y": 0.2,
17+
"z": 2.1
18+
}
19+
}
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)