Skip to content

Commit

Permalink
fix for histogram and bar charts
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Jan 5, 2019
1 parent 4b07210 commit 6b956cc
Show file tree
Hide file tree
Showing 10 changed files with 159 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/traces/bar/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout

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

var lineColor = (traceOut.marker.line || {}).color;
var markerColor = (traceOut.marker || {}).color;

// override defaultColor for error bars with defaultLine
var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults');
errorBarsSupplyDefaults(traceIn, traceOut, Color.defaultLine, {axis: 'y'});
errorBarsSupplyDefaults(traceIn, traceOut, Color.defaultLine, {axis: 'x', inherit: 'y'});
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || Color.defaultLine, {axis: 'y'});
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || Color.defaultLine, {axis: 'x', inherit: 'y'});

Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
};
11 changes: 7 additions & 4 deletions src/traces/histogram/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout

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

Lib.coerceSelectionMarkerOpacity(traceOut, coerce);

var lineColor = (traceOut.marker.line || {}).color;
var markerColor = (traceOut.marker || {}).color;

// override defaultColor for error bars with defaultLine
var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults');
errorBarsSupplyDefaults(traceIn, traceOut, Color.defaultLine, {axis: 'y'});
errorBarsSupplyDefaults(traceIn, traceOut, Color.defaultLine, {axis: 'x', inherit: 'y'});

Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || Color.defaultLine, {axis: 'y'});
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || Color.defaultLine, {axis: 'x', inherit: 'y'});
};
Binary file not shown.
Binary file not shown.
Binary file not shown.
76 changes: 76 additions & 0 deletions test/image/mocks/gl2d_errorbars-inherit_color-bar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"data": [
{
"x": [0, 1, 2, 3, 4],
"y": [0, 100, 500, 600, 0],
"type": "bar",
"barmode": "group",
"error_y": {
"type": "sqrt"
}
},
{
"x": [0, 1, 2, 3, 4],
"y": [100, 200, 600, 700, 100],
"type": "bar",
"barmode": "group",
"marker": {
"line": {
"width": 2,
"color": "gray"
}
},
"error_y": {
"type": "sqrt"
}
},
{
"x": [0, 1, 2, 3, 4],
"y": [200, 300, 700, 800, 200],
"type": "bar",
"barmode": "group",
"marker": {
"color": "red"
},
"error_y": {
"type": "sqrt"
}
},
{
"x": [0, 1, 2, 3, 4],
"y": [300, 400, 800, 900, 300],
"type": "bar",
"barmode": "group",
"marker": {
"line": {
"color": "green"
}
},
"error_y": {
"type": "sqrt"
}
},
{
"x": [0, 1, 2, 3, 4],
"y": [400, 500, 900, 1000, 400],
"type": "bar",
"barmode": "group",
"marker": {
"line": {
"color": "blue"
},
"color": "black"
},
"error_y": {
"type": "sqrt"
}
}
],
"layout": {
"width": 600,
"heigh": 600,
"title": {
"text": "Bar chart error bars inherit color from marker.line or marker"
}
}
}
71 changes: 71 additions & 0 deletions test/image/mocks/gl2d_errorbars-inherit_color-histogram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"data": [
{
"x": [0, 1, 5, 6, 0],
"type": "histogram",
"barmode": "stack",
"error_y": {
"type": "sqrt"
}
},
{
"x": [1, 2, 6, 7, 1],
"type": "histogram",
"barmode": "stack",
"marker": {
"line": {
"width": 2,
"color": "gray"
}
},
"error_y": {
"type": "sqrt"
}
},
{
"x": [2, 3, 7, 8, 2],
"type": "histogram",
"barmode": "stack",
"marker": {
"color": "red"
},
"error_y": {
"type": "sqrt"
}
},
{
"x": [3, 4, 8, 9, 3],
"type": "histogram",
"barmode": "stack",
"marker": {
"line": {
"color": "green"
}
},
"error_y": {
"type": "sqrt"
}
},
{
"x": [4, 5, 9, 10, 4],
"type": "histogram",
"barmode": "stack",
"marker": {
"line": {
"color": "blue"
},
"color": "black"
},
"error_y": {
"type": "sqrt"
}
}
],
"layout": {
"width": 600,
"heigh": 600,
"title": {
"text": "Histogram error bars inherit color from marker.line or marker"
}
}
}

0 comments on commit 6b956cc

Please sign in to comment.