Skip to content

Axis visible in 3D #1599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 17, 2017
Merged
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: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
29 changes: 15 additions & 14 deletions src/plots/cartesian/axis_defaults.js
Original file line number Diff line number Diff line change
@@ -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;
};
20 changes: 14 additions & 6 deletions src/plots/gl3d/layout/convert.js
Original file line number Diff line number Diff line change
@@ -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) {
6 changes: 6 additions & 0 deletions src/plots/gl3d/layout/spikes.js
Original file line number Diff line number Diff line change
@@ -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;
Binary file added test/image/baselines/axes_visible-false.png
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/gl3d_axes-visible-false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions test/image/mocks/axes_visible-false.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"data": [{
"y": [1, 2, 3]
}],
"layout": {
"xaxis": { "visible": false },
"yaxis": { "visible": false }
}
}
22 changes: 22 additions & 0 deletions test/image/mocks/gl3d_axes-visible-false.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
}