Skip to content

Commit

Permalink
Merge pull request #3554 from plotly/scatter3d-colorscale-relink-fixup
Browse files Browse the repository at this point in the history
Adapt `Colorscale.crossTraceDefaults` to array ` _module.colorbar` definitions
  • Loading branch information
etpinard authored Feb 19, 2019
2 parents 399d03b + 8ad3e45 commit bb1239a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/components/colorscale/cross_trace_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ module.exports = function crossTraceDefaults(fullData) {

for(var i = 0; i < fullData.length; i++) {
var trace = fullData[i];
var _module = trace._module;
var colorbar = trace._module.colorbar;

if(_module.colorbar) {
relinkColorAtts(trace, _module.colorbar);
if(colorbar) {
if(Array.isArray(colorbar)) {
for(var j = 0; j < colorbar.length; j++) {
relinkColorAtts(trace, colorbar[j]);
}
} else {
relinkColorAtts(trace, colorbar);
}
}

// TODO could generalize _module.colorscale and use it here?
Expand Down
29 changes: 28 additions & 1 deletion test/jasmine/tests/colorscale_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,10 @@ describe('Test colorscale restyle calls:', function() {
gd = createGraphDiv();
});

afterEach(destroyGraphDiv);
afterEach(function() {
Plotly.purge(gd);
destroyGraphDiv();
});

function getFill(q) {
return d3.select(q).node().style.fill;
Expand Down Expand Up @@ -902,4 +905,28 @@ describe('Test colorscale restyle calls:', function() {
.catch(failTest)
.then(done);
});

it('@gl should work with scatter3d', function(done) {
Plotly.plot(gd, [{
type: 'scatter3d',
x: [1, 2, 3],
y: [1, 2, 3],
z: [1, 2, 1],
marker: {color: [1, 2, 1], showscale: true}
}])
.then(function() {
expect(gd._fullData[0].marker.cmin).toBe(1);
expect(gd._fullData[0].marker.cmax).toBe(2);
})
.then(function() {
// some non-calc edit
return Plotly.relayout(gd, 'scene.dragmode', 'pan');
})
.then(function() {
expect(gd._fullData[0].marker.cmin).toBe(1);
expect(gd._fullData[0].marker.cmax).toBe(2);
})
.catch(failTest)
.then(done);
});
});

0 comments on commit bb1239a

Please sign in to comment.