Skip to content

Commit bb1239a

Browse files
authored
Merge pull request #3554 from plotly/scatter3d-colorscale-relink-fixup
Adapt `Colorscale.crossTraceDefaults` to array ` _module.colorbar` definitions
2 parents 399d03b + 8ad3e45 commit bb1239a

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

src/components/colorscale/cross_trace_defaults.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ module.exports = function crossTraceDefaults(fullData) {
4343

4444
for(var i = 0; i < fullData.length; i++) {
4545
var trace = fullData[i];
46-
var _module = trace._module;
46+
var colorbar = trace._module.colorbar;
4747

48-
if(_module.colorbar) {
49-
relinkColorAtts(trace, _module.colorbar);
48+
if(colorbar) {
49+
if(Array.isArray(colorbar)) {
50+
for(var j = 0; j < colorbar.length; j++) {
51+
relinkColorAtts(trace, colorbar[j]);
52+
}
53+
} else {
54+
relinkColorAtts(trace, colorbar);
55+
}
5056
}
5157

5258
// TODO could generalize _module.colorscale and use it here?

test/jasmine/tests/colorscale_test.js

+28-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,10 @@ describe('Test colorscale restyle calls:', function() {
586586
gd = createGraphDiv();
587587
});
588588

589-
afterEach(destroyGraphDiv);
589+
afterEach(function() {
590+
Plotly.purge(gd);
591+
destroyGraphDiv();
592+
});
590593

591594
function getFill(q) {
592595
return d3.select(q).node().style.fill;
@@ -902,4 +905,28 @@ describe('Test colorscale restyle calls:', function() {
902905
.catch(failTest)
903906
.then(done);
904907
});
908+
909+
it('@gl should work with scatter3d', function(done) {
910+
Plotly.plot(gd, [{
911+
type: 'scatter3d',
912+
x: [1, 2, 3],
913+
y: [1, 2, 3],
914+
z: [1, 2, 1],
915+
marker: {color: [1, 2, 1], showscale: true}
916+
}])
917+
.then(function() {
918+
expect(gd._fullData[0].marker.cmin).toBe(1);
919+
expect(gd._fullData[0].marker.cmax).toBe(2);
920+
})
921+
.then(function() {
922+
// some non-calc edit
923+
return Plotly.relayout(gd, 'scene.dragmode', 'pan');
924+
})
925+
.then(function() {
926+
expect(gd._fullData[0].marker.cmin).toBe(1);
927+
expect(gd._fullData[0].marker.cmax).toBe(2);
928+
})
929+
.catch(failTest)
930+
.then(done);
931+
});
905932
});

0 commit comments

Comments
 (0)