From f1c12e98332ed24f2e9a02975298223f2691aa85 Mon Sep 17 00:00:00 2001 From: Nathan Meyers Date: Thu, 25 Oct 2018 13:14:42 -0700 Subject: [PATCH] Adds the ability to set a maximum height of the legend --- src/components/legend/draw.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/legend/draw.js b/src/components/legend/draw.js index 30d3c66aa7e..3253dc8744e 100644 --- a/src/components/legend/draw.js +++ b/src/components/legend/draw.js @@ -36,6 +36,7 @@ var DBLCLICKDELAY = interactConstants.DBLCLICKDELAY; module.exports = function draw(gd) { var fullLayout = gd._fullLayout; + var legendLayout = gd.layout.legend || {}; var clipId = 'legend' + fullLayout._uid; if(!fullLayout._infolayer || !gd.calcdata) return; @@ -185,8 +186,8 @@ module.exports = function draw(gd) { // Make sure the legend top and bottom are visible // (legends with a scroll bar are not allowed to stretch beyond the extended // margins) - var legendHeight = opts._height, - legendHeightMax = gs.h; + var legendHeight = (legendLayout.maxHeight) ? Math.min(opts._height, legendLayout.maxHeight) : opts._height; + var legendHeightMax = gs.h; if(legendHeight > legendHeightMax) { ly = gs.t;