Skip to content
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

Adapt Colorscale.crossTraceDefaults to array _module.colorbar definitions #3554

Merged
merged 2 commits into from
Feb 19, 2019
Merged
Show file tree
Hide file tree
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
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);
});
});