Skip to content

Commit 6b956cc

Browse files
committed
fix for histogram and bar charts
1 parent 4b07210 commit 6b956cc

10 files changed

+159
-6
lines changed

src/traces/bar/defaults.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,13 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
7070

7171
handleStyleDefaults(traceIn, traceOut, coerce, defaultColor, layout);
7272

73+
var lineColor = (traceOut.marker.line || {}).color;
74+
var markerColor = (traceOut.marker || {}).color;
75+
7376
// override defaultColor for error bars with defaultLine
7477
var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults');
75-
errorBarsSupplyDefaults(traceIn, traceOut, Color.defaultLine, {axis: 'y'});
76-
errorBarsSupplyDefaults(traceIn, traceOut, Color.defaultLine, {axis: 'x', inherit: 'y'});
78+
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || Color.defaultLine, {axis: 'y'});
79+
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || Color.defaultLine, {axis: 'x', inherit: 'y'});
7780

7881
Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
7982
};

src/traces/histogram/defaults.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
6262

6363
handleStyleDefaults(traceIn, traceOut, coerce, defaultColor, layout);
6464

65+
Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
66+
67+
var lineColor = (traceOut.marker.line || {}).color;
68+
var markerColor = (traceOut.marker || {}).color;
69+
6570
// override defaultColor for error bars with defaultLine
6671
var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults');
67-
errorBarsSupplyDefaults(traceIn, traceOut, Color.defaultLine, {axis: 'y'});
68-
errorBarsSupplyDefaults(traceIn, traceOut, Color.defaultLine, {axis: 'x', inherit: 'y'});
69-
70-
Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
72+
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || Color.defaultLine, {axis: 'y'});
73+
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || Color.defaultLine, {axis: 'x', inherit: 'y'});
7174
};
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"data": [
3+
{
4+
"x": [0, 1, 2, 3, 4],
5+
"y": [0, 100, 500, 600, 0],
6+
"type": "bar",
7+
"barmode": "group",
8+
"error_y": {
9+
"type": "sqrt"
10+
}
11+
},
12+
{
13+
"x": [0, 1, 2, 3, 4],
14+
"y": [100, 200, 600, 700, 100],
15+
"type": "bar",
16+
"barmode": "group",
17+
"marker": {
18+
"line": {
19+
"width": 2,
20+
"color": "gray"
21+
}
22+
},
23+
"error_y": {
24+
"type": "sqrt"
25+
}
26+
},
27+
{
28+
"x": [0, 1, 2, 3, 4],
29+
"y": [200, 300, 700, 800, 200],
30+
"type": "bar",
31+
"barmode": "group",
32+
"marker": {
33+
"color": "red"
34+
},
35+
"error_y": {
36+
"type": "sqrt"
37+
}
38+
},
39+
{
40+
"x": [0, 1, 2, 3, 4],
41+
"y": [300, 400, 800, 900, 300],
42+
"type": "bar",
43+
"barmode": "group",
44+
"marker": {
45+
"line": {
46+
"color": "green"
47+
}
48+
},
49+
"error_y": {
50+
"type": "sqrt"
51+
}
52+
},
53+
{
54+
"x": [0, 1, 2, 3, 4],
55+
"y": [400, 500, 900, 1000, 400],
56+
"type": "bar",
57+
"barmode": "group",
58+
"marker": {
59+
"line": {
60+
"color": "blue"
61+
},
62+
"color": "black"
63+
},
64+
"error_y": {
65+
"type": "sqrt"
66+
}
67+
}
68+
],
69+
"layout": {
70+
"width": 600,
71+
"heigh": 600,
72+
"title": {
73+
"text": "Bar chart error bars inherit color from marker.line or marker"
74+
}
75+
}
76+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"data": [
3+
{
4+
"x": [0, 1, 5, 6, 0],
5+
"type": "histogram",
6+
"barmode": "stack",
7+
"error_y": {
8+
"type": "sqrt"
9+
}
10+
},
11+
{
12+
"x": [1, 2, 6, 7, 1],
13+
"type": "histogram",
14+
"barmode": "stack",
15+
"marker": {
16+
"line": {
17+
"width": 2,
18+
"color": "gray"
19+
}
20+
},
21+
"error_y": {
22+
"type": "sqrt"
23+
}
24+
},
25+
{
26+
"x": [2, 3, 7, 8, 2],
27+
"type": "histogram",
28+
"barmode": "stack",
29+
"marker": {
30+
"color": "red"
31+
},
32+
"error_y": {
33+
"type": "sqrt"
34+
}
35+
},
36+
{
37+
"x": [3, 4, 8, 9, 3],
38+
"type": "histogram",
39+
"barmode": "stack",
40+
"marker": {
41+
"line": {
42+
"color": "green"
43+
}
44+
},
45+
"error_y": {
46+
"type": "sqrt"
47+
}
48+
},
49+
{
50+
"x": [4, 5, 9, 10, 4],
51+
"type": "histogram",
52+
"barmode": "stack",
53+
"marker": {
54+
"line": {
55+
"color": "blue"
56+
},
57+
"color": "black"
58+
},
59+
"error_y": {
60+
"type": "sqrt"
61+
}
62+
}
63+
],
64+
"layout": {
65+
"width": 600,
66+
"heigh": 600,
67+
"title": {
68+
"text": "Histogram error bars inherit color from marker.line or marker"
69+
}
70+
}
71+
}

0 commit comments

Comments
 (0)