Skip to content

Commit c401f87

Browse files
committed
add support for marker AND line colorbars on same scatter3d graph
1 parent 5c01f53 commit c401f87

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

src/components/colorbar/draw.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ function makeColorBarData(gd) {
8181
var moduleOpts = trace._module.colorbar;
8282

8383
if(trace.visible === true && moduleOpts) {
84-
var cbOpts = Array.isArray(moduleOpts) ? moduleOpts : [moduleOpts];
84+
var allowsMultiplotCbs = Array.isArray(moduleOpts);
85+
var cbOpts = allowsMultiplotCbs ? moduleOpts : [moduleOpts];
8586

8687
for(var j = 0; j < cbOpts.length; j++) {
8788
var cbOpt = cbOpts[j];
@@ -90,7 +91,7 @@ function makeColorBarData(gd) {
9091

9192
if(cont && cont.showscale) {
9293
var opts = cont.colorbar;
93-
opts._id = 'cb' + trace.uid;
94+
opts._id = 'cb' + trace.uid + (allowsMultiplotCbs && contName ? '-' + contName : '');
9495
opts._traceIndex = trace.index;
9596
opts._propPrefix = (contName ? contName + '.' : '') + 'colorbar.';
9697

Loading
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"data": [
3+
{
4+
"x": [1, 2, 4, 8, 16],
5+
"y": [-1, -2, -4, -8, -16],
6+
"z": [0, 1, 0, 1, 0],
7+
"type": "scatter3d",
8+
"mode": "lines+markers",
9+
"line": {
10+
"color": [0, 0.25, 0.5, 0.75, 1.0],
11+
"width": 10,
12+
"colorscale": "Blues",
13+
"colorbar": {
14+
"len": 0.5,
15+
"y": 1,
16+
"yanchor": "top",
17+
"title": {"text": "line colorscale", "side": "right"}
18+
}
19+
},
20+
"marker": {
21+
"color": [1.0, 0.75, 0.5, 0.25, 0],
22+
"size": 10,
23+
"colorscale": "Reds",
24+
"colorbar": {
25+
"len": 0.5,
26+
"y": 0,
27+
"yanchor": "bottom",
28+
"title": {"text": "marker colorscale", "side": "right"}
29+
}
30+
31+
}
32+
}
33+
],
34+
"layout": {
35+
"title": "Scatter3d show line AND marker color scales",
36+
"width": 600,
37+
"height": 600
38+
}
39+
}

0 commit comments

Comments
 (0)