Skip to content

Commit 7108e30

Browse files
committed
fix 3392 scatter errorbars inherit color
1 parent 728eacc commit 7108e30

File tree

4 files changed

+99
-5
lines changed

4 files changed

+99
-5
lines changed

src/traces/scatter/defaults.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
7171
if(!subTypes.hasLines(traceOut)) handleLineShapeDefaults(traceIn, traceOut, coerce);
7272
}
7373

74+
var lineColor = (traceOut.line || {}).color;
75+
var markerColor = (traceOut.marker || {}).color;
76+
7477
if(traceOut.fill === 'tonext' || traceOut.fill === 'toself') {
7578
dfltHoverOn.push('fills');
7679
}
7780
coerce('hoveron', dfltHoverOn.join('+') || 'points');
7881
if(traceOut.hoveron !== 'fills') coerce('hovertemplate');
7982
var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults');
80-
errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'y'});
81-
errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'x', inherit: 'y'});
83+
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, {axis: 'y'});
84+
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, {axis: 'x', inherit: 'y'});
8285

8386
Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
8487
};

src/traces/scatter3d/defaults.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
6262
}
6363

6464
var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults');
65-
errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'z'});
66-
errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'y', inherit: 'z'});
67-
errorBarsSupplyDefaults(traceIn, traceOut, defaultColor, {axis: 'x', inherit: 'z'});
65+
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, {axis: 'z'});
66+
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, {axis: 'y', inherit: 'z'});
67+
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, {axis: 'x', inherit: 'z'});
6868
};
6969

7070
function handleXYZDefaults(traceIn, traceOut, coerce, layout) {
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"data": [
3+
{
4+
"x": [0, 1, 2, 3, 4],
5+
"y": [100, 200, 400, 600, 700],
6+
"type": "scatter",
7+
"mode": "markers+lines",
8+
"error_y": {
9+
"type": "sqrt"
10+
}
11+
},
12+
{
13+
"x": [0, 1, 2, 3, 4],
14+
"y": [0, 100, 300, 500, 600],
15+
"type": "scatter",
16+
"mode": "markers+lines",
17+
"marker": {
18+
"color": "green"
19+
},
20+
"error_y": {
21+
"type": "sqrt"
22+
}
23+
},
24+
{
25+
"x": [0, 1, 2, 3, 4],
26+
"y": [200, 300, 500, 700, 800],
27+
"type": "scatter",
28+
"mode": "markers+lines",
29+
"line": {
30+
"color": "red"
31+
},
32+
"error_y": {
33+
"type": "sqrt"
34+
}
35+
}
36+
],
37+
"layout": {
38+
"width": 600,
39+
"heigh": 600,
40+
"title": {
41+
"text": "Scatter error bars inherit color from line or marker"
42+
}
43+
}
44+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"data": [
3+
{
4+
"x": [0, 1, 2, 3, 4],
5+
"y": [-5, -10, -20, -30, -35],
6+
"z": [0, 0, 0, 0, 0],
7+
"type": "scatter3d",
8+
"mode": "markers+lines",
9+
"error_y": {
10+
"type": "sqrt"
11+
}
12+
},
13+
{
14+
"x": [0, 1, 2, 3, 4],
15+
"y": [0, -5, -15, -25, -30],
16+
"z": [1, 1, 1, 1, 1],
17+
"type": "scatter3d",
18+
"mode": "markers+lines",
19+
"marker": {
20+
"color": "green"
21+
},
22+
"error_y": {
23+
"type": "sqrt"
24+
}
25+
},
26+
{
27+
"x": [0, 1, 2, 3, 4],
28+
"y": [-10, -15, -25, -35, -40],
29+
"z": [2, 2, 2, 2, 2],
30+
"type": "scatter3d",
31+
"mode": "markers+lines",
32+
"line": {
33+
"color": "red"
34+
},
35+
"error_y": {
36+
"type": "sqrt"
37+
}
38+
}
39+
],
40+
"layout": {
41+
"width": 600,
42+
"heigh": 600,
43+
"title": {
44+
"text": "Scatter3d error bars inherit color from line or marker"
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)