Skip to content

Commit d245c2d

Browse files
committed
fix issue 2862 by showing colorbar when scatter line has scale e.g. scatter3d case
1 parent fc4511c commit d245c2d

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

src/components/colorbar/connect.js

+16-11
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,24 @@ module.exports = function connectColorbar(gd, cd, moduleOpts) {
4141

4242
var trace = cd[0].trace;
4343
var cbId = 'cb' + trace.uid;
44-
var containerName = moduleOpts.container;
45-
var container = containerName ? trace[containerName] : trace;
44+
var containerNames = moduleOpts.container.split(' | ');
4645

47-
gd._fullLayout._infolayer.selectAll('.' + cbId).remove();
48-
if(!container || !container.showscale) return;
46+
for(var i = 0; i < containerNames.length; i++) {
47+
var containerName = containerNames[i];
4948

50-
var cb = cd[0].t.cb = drawColorbar(gd, cbId);
49+
var container = containerName ? trace[containerName] : trace;
5150

52-
var scl = container.reversescale ?
53-
flipScale(container.colorscale) :
54-
container.colorscale;
51+
gd._fullLayout._infolayer.selectAll('.' + cbId).remove();
52+
if(!container || !container.showscale) continue;
5553

56-
cb.fillgradient(scl)
57-
.zrange([container[moduleOpts.min], container[moduleOpts.max]])
58-
.options(container.colorbar)();
54+
var cb = cd[0].t.cb = drawColorbar(gd, cbId);
55+
56+
var scl = container.reversescale ?
57+
flipScale(container.colorscale) :
58+
container.colorscale;
59+
60+
cb.fillgradient(scl)
61+
.zrange([container[moduleOpts.min], container[moduleOpts.max]])
62+
.options(container.colorbar)();
63+
}
5964
};

src/traces/scatter/line_defaults.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout,
1818
coerce('line.color', defaultColor);
1919

2020
if(hasColorscale(traceIn, 'line')) {
21-
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'line.', cLetter: 'c', noScale: true});
21+
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'line.', cLetter: 'c'});
2222
} else {
2323
var lineColorDflt = (isArrayOrTypedArray(markerColor) ? false : markerColor) || defaultColor;
2424
coerce('line.color', lineColorDflt);

src/traces/scatter/marker_colorbar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'use strict';
1111

1212
module.exports = {
13-
container: 'marker',
13+
container: 'marker | line',
1414
min: 'cmin',
1515
max: 'cmax'
1616
};

src/traces/scatter3d/attributes.js

-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ var lineAttrs = extendFlat({
3131
description: 'Sets the dash style of the lines.'
3232
}
3333
}, colorAttributes('line'));
34-
// not yet implemented
35-
delete lineAttrs.showscale;
36-
delete lineAttrs.colorbar;
3734

3835
function makeProjectionAttr(axLetter) {
3936
return {

0 commit comments

Comments
 (0)