Skip to content

Commit 2070279

Browse files
Merge pull request #1327 from plotly/fix-Thumbnail-Clone
fixes 3d thumbnail clone when no xaxis in scene
2 parents 515e6d9 + 33e60ef commit 2070279

File tree

2 files changed

+53
-5
lines changed

2 files changed

+53
-5
lines changed

src/snapshot/cloneplot.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,26 @@ module.exports = function clonePlot(graphObj, options) {
113113
};
114114
}
115115
for(i = 0; i < sceneIds.length; i++) {
116-
var sceneId = sceneIds[i];
116+
var scene = newLayout[sceneIds[i]];
117117

118-
extendFlat(newLayout[sceneId].xaxis, axesImageOverride);
119-
extendFlat(newLayout[sceneId].yaxis, axesImageOverride);
120-
extendFlat(newLayout[sceneId].zaxis, axesImageOverride);
118+
if(!scene.xaxis) {
119+
scene.xaxis = {};
120+
}
121+
122+
if(!scene.yaxis) {
123+
scene.yaxis = {};
124+
}
125+
126+
if(!scene.zaxis) {
127+
scene.zaxis = {};
128+
}
129+
130+
extendFlat(scene.xaxis, axesImageOverride);
131+
extendFlat(scene.yaxis, axesImageOverride);
132+
extendFlat(scene.zaxis, axesImageOverride);
121133

122134
// TODO what does this do?
123-
newLayout[sceneId]._scene = null;
135+
scene._scene = null;
124136
}
125137
}
126138

test/jasmine/tests/snapshot_test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,42 @@ describe('Plotly.Snapshot', function() {
116116
expect(thumbTile.layout.annotations).toEqual(THUMBNAIL_DEFAULT_LAYOUT.annotations);
117117
});
118118

119+
it('should create a 3D thumbnail with limited attributes', function() {
120+
121+
var figure = {
122+
data: [{
123+
type: 'scatter',
124+
mode: 'markers',
125+
y: [2, 4, 6, 5, 7, 4],
126+
x: [1, 3, 4, 6, 3, 1],
127+
name: 'C'
128+
}],
129+
layout: {
130+
autosize: true,
131+
scene: {
132+
aspectratio: {y: 1, x: 1, z: 1}
133+
}
134+
}};
135+
136+
137+
var thumbnailOptions = {
138+
tileClass: 'thumbnail'
139+
};
140+
141+
var AXIS_OVERRIDE = {
142+
title: '',
143+
showaxeslabels: false,
144+
showticklabels: false,
145+
linetickenable: false
146+
};
147+
148+
var thumbTile = Plotly.Snapshot.clone(figure, thumbnailOptions);
149+
expect(thumbTile.layout.scene.xaxis).toEqual(AXIS_OVERRIDE);
150+
expect(thumbTile.layout.scene.yaxis).toEqual(AXIS_OVERRIDE);
151+
expect(thumbTile.layout.scene.zaxis).toEqual(AXIS_OVERRIDE);
152+
});
153+
154+
119155
it('should create a custom sized Tile based on options', function() {
120156
var customOptions = {
121157
tileClass: 'notarealclass',

0 commit comments

Comments
 (0)