docs: function (legendHeight) {
              var legend = this,
                chart = this.chart,
                renderer = chart.renderer,
                options = this.options,
                optionsY = options.y,
                alignTop = options.verticalAlign === 'top',
                spaceHeight = chart.spacingBox.height + (alignTop ? -optionsY : optionsY) - this.padding,
                maxHeight = options.maxHeight,
                clipHeight,
                clipRect = this.clipRect,
                navOptions = options.navigation,
                animation = pick(navOptions.animation, true),
                arrowSize = navOptions.arrowSize || 12,
                nav = this.nav,
                pages = this.pages,
                lastY,
                allItems = this.allItems;
  
              // Adjust the height
              if (options.layout === 'horizontal') {
                  spaceHeight /= 2;
              }
              if (maxHeight) {
                  spaceHeight = mathMin(spaceHeight, maxHeight);
              }
  
              // Reset the legend height and adjust the clipping rectangle
              pages.length = 0;
              if (legendHeight > spaceHeight && !options.useHTML) {
  
                  this.clipHeight = clipHeight = mathMax(spaceHeight - 20 - this.titleHeight - this.padding, 0);
                  this.currentPage = pick(this.currentPage, 1);
                  this.fullHeight = legendHeight;
  
                  // Fill pages with Y positions so that the top of each a legend item defines
                  // the scroll top for each page (#2098)
                  each(allItems, function (item, i) {
                      var y = item._legendItemPos[1],
                        h = mathRound(item.legendItem.getBBox().height),
                        len = pages.length;
  
                      if (!len || (y - pages[len - 1] > clipHeight && (lastY || y) !== pages[len - 1])) {
                          pages.push(lastY || y);
                          len++;
                      }
  
                      if (i === allItems.length - 1 && y + h - pages[len - 1] > clipHeight) {
                          pages.push(y);
                      }
                      if (y !== lastY) {
                          lastY = y;
                      }
                  });
  
                  // Only apply clipping if needed. Clipping causes blurred legend in PDF export (#1787)
                  if (!clipRect) {
                      clipRect = legend.clipRect = renderer.clipRect(0, this.padding, 9999, 0);
                      legend.contentGroup.clip(clipRect);
                  }
                  clipRect.attr({
                      height: clipHeight
                  });
  
                  // Add navigation elements
                  if (!nav) {
                      this.nav = nav = renderer.g().attr({ zIndex: 1 }).add(this.group);
                      this.up = renderer.symbol('triangle', 0, 0, arrowSize, arrowSize)
                        .on('click', function () {
                            legend.scroll(-1, animation);
                        })
                        .add(nav);
                      this.pager = renderer.text('', 15, 10)
                        .css(navOptions.style)
                        .add(nav);
                      this.down = renderer.symbol('triangle-down', 0, 0, arrowSize, arrowSize)
                        .on('click', function () {
                            legend.scroll(1, animation);
                        })
                        .add(nav);
                  }
  
                  // Set initial position
                  legend.scroll(0);
  
                  legendHeight = spaceHeight;
  
              } else if (nav) {
                  clipRect.attr({
                      height: chart.chartHeight
                  });
                  nav.hide();
                  this.scrollGroup.attr({
                      translateY: 1
                  });
                  this.clipHeight = 0; // #1379
              }
  
              return legendHeight;
          }