Skip to content

Commit 7ef2dff

Browse files
authored
Merge pull request #2 from psalmody/h-legend-cols
Horizontal legend in columns
2 parents e7a286f + 91d384b commit 7ef2dff

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: src/components/legend/draw.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -570,12 +570,18 @@ function computeLegendDimensions(gd, groups, traces) {
570570
opts.height = 0;
571571
var rowHeight = 0,
572572
maxTraceHeight = 0,
573+
maxTraceWidth = 0,
573574
offsetX = 0;
574575

576+
//calculate largest width for traces and use for width of all legend items
577+
traces.each(function(d) {
578+
maxTraceWidth = Math.max(40 + d[0].width, maxTraceWidth);
579+
});
580+
575581
traces.each(function(d) {
576582

577583
var legendItem = d[0],
578-
traceWidth = 40 + legendItem.width,
584+
traceWidth = maxTraceWidth,
579585
traceGap = opts.tracegroupgap || 5;
580586

581587
if((borderwidth + offsetX + traceGap + traceWidth) > (fullLayout.width - (fullLayout.margin.r + fullLayout.margin.l))) {

0 commit comments

Comments
 (0)