Skip to content

Commit cebdb15

Browse files
authored
Merge pull request #1289 from plotly/bar-legend-style
Fix bar marker color array legend style
2 parents 9b7c18f + 81d3db1 commit cebdb15

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

src/components/legend/style.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,15 @@ function styleBars(d) {
176176
.attr('transform', 'translate(20,0)');
177177
barpath.exit().remove();
178178
barpath.each(function(d) {
179-
var w = (d.mlw + 1 || markerLine.width + 1) - 1,
180-
p = d3.select(this);
179+
var p = d3.select(this),
180+
d0 = d[0],
181+
w = (d0.mlw + 1 || markerLine.width + 1) - 1;
181182

182183
p.style('stroke-width', w + 'px')
183-
.call(Color.fill, d.mc || marker.color);
184+
.call(Color.fill, d0.mc || marker.color);
184185

185186
if(w) {
186-
p.call(Color.stroke, d.mlc || markerLine.color);
187+
p.call(Color.stroke, d0.mlc || markerLine.color);
187188
}
188189
});
189190
}
@@ -198,15 +199,15 @@ function styleBoxes(d) {
198199
.attr('d', 'M6,6H-6V-6H6Z')
199200
.attr('transform', 'translate(20,0)');
200201
pts.exit().remove();
201-
pts.each(function(d) {
202-
var w = (d.lw + 1 || trace.line.width + 1) - 1,
202+
pts.each(function() {
203+
var w = trace.line.width,
203204
p = d3.select(this);
204205

205206
p.style('stroke-width', w + 'px')
206-
.call(Color.fill, d.fc || trace.fillcolor);
207+
.call(Color.fill, trace.fillcolor);
207208

208209
if(w) {
209-
p.call(Color.stroke, d.lc || trace.line.color);
210+
p.call(Color.stroke, trace.line.color);
210211
}
211212
});
212213
}
1.17 KB
Loading

test/image/mocks/bar_marker_array.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,26 @@
1919
"#447adb",
2020
"#db5a44",
2121
"#447adb"
22-
]
22+
],
23+
"line": {
24+
"width": [
25+
2,
26+
3,
27+
2,
28+
3
29+
],
30+
"color": [
31+
"red",
32+
"green",
33+
"blue",
34+
"yellow"
35+
]
36+
}
2337
},
2438
"type": "bar"
2539
}
26-
]
40+
],
41+
"layout": {
42+
"showlegend": true
43+
}
2744
}

0 commit comments

Comments
 (0)