From 91d384ba0c3cd958366f6000445b34b316673fa4 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Tue, 26 Jul 2016 09:50:22 -0800 Subject: [PATCH] put horizontal legend traces in columns --- src/components/legend/draw.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/legend/draw.js b/src/components/legend/draw.js index 8321e4072e5..1a7a063d470 100644 --- a/src/components/legend/draw.js +++ b/src/components/legend/draw.js @@ -570,12 +570,18 @@ function computeLegendDimensions(gd, groups, traces) { opts.height = 0; var rowHeight = 0, maxTraceHeight = 0, + maxTraceWidth = 0, offsetX = 0; + //calculate largest width for traces and use for width of all legend items + traces.each(function(d) { + maxTraceWidth = Math.max(40 + d[0].width, maxTraceWidth); + }); + traces.each(function(d) { var legendItem = d[0], - traceWidth = 40 + legendItem.width, + traceWidth = maxTraceWidth, traceGap = opts.tracegroupgap || 5; if((borderwidth + offsetX + traceGap + traceWidth) > (fullLayout.width - (fullLayout.margin.r + fullLayout.margin.l))) {