docs: function (item) {
              var legend = this,
                chart = legend.chart,
                renderer = chart.renderer,
                options = legend.options,
                horizontal = options.layout === 'horizontal',
                symbolWidth = legend.symbolWidth,
                symbolPadding = options.symbolPadding,
                itemStyle = legend.itemStyle,
                itemHiddenStyle = legend.itemHiddenStyle,
                padding = legend.padding,
                itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
                ltr = !options.rtl,
                itemHeight,
                widthOption = options.width,
                itemMarginBottom = options.itemMarginBottom || 0,
                itemMarginTop = legend.itemMarginTop,
                initialItemX = legend.initialItemX,
                bBox,
                itemWidth,
                li = item.legendItem,
                series = item.series && item.series.drawLegendSymbol ? item.series : item,
                seriesOptions = series.options,
                showCheckbox = legend.createCheckboxForItem && seriesOptions && seriesOptions.showCheckbox,
                useHTML = options.useHTML;
  
              if (!li) { // generate it once, later move it
  
                  // Generate the group box
                  // A group to hold the symbol and text. Text is to be appended in Legend class.
                  item.legendGroup = renderer.g('legend-item')
                    .attr({ zIndex: 1 })
                    .add(legend.scrollGroup);
  
                  // Generate the list item text and add it to the group
                  item.legendItem = li = renderer.text(
                    options.labelFormat ? format(options.labelFormat, item) : options.labelFormatter.call(item),
                    ltr ? symbolWidth + symbolPadding : -symbolPadding,
                      legend.baseline || 0,
                    useHTML
                    )
                    .css(merge(item.visible ? itemStyle : itemHiddenStyle)) // merge to prevent modifying original (#1021)
                    .attr({
                        align: ltr ? 'left' : 'right',
                        zIndex: 2
                    })
                    .add(item.legendGroup);
  
                  // Get the baseline for the first item - the font size is equal for all
                  if (!legend.baseline) {
                      legend.baseline = renderer.fontMetrics(itemStyle.fontSize, li).f + 3 + itemMarginTop;
                      li.attr('y', legend.baseline);
                  }
  
                  // Draw the legend symbol inside the group box
                  series.drawLegendSymbol(legend, item);
  
                  if (legend.setItemEvents) {
                      legend.setItemEvents(item, li, useHTML, itemStyle, itemHiddenStyle);
                  }
  
                  // Colorize the items
                  legend.colorizeItem(item, item.visible);
  
                  // add the HTML checkbox on top
                  if (showCheckbox) {
                      legend.createCheckboxForItem(item);
                  }
              }
  
              // calculate the positions for the next line
              bBox = li.getBBox();
  
              itemWidth = item.checkboxOffset =
                options.itemWidth ||
                item.legendItemWidth ||
                symbolWidth + symbolPadding + bBox.width + itemDistance + (showCheckbox ? 20 : 0);
              legend.itemHeight = itemHeight = mathRound(item.legendItemHeight || bBox.height);
  
              // if the item exceeds the width, start a new line
              if (horizontal && legend.itemX - initialItemX + itemWidth >
                (widthOption || (chart.chartWidth - 2 * padding - initialItemX - options.x))) {
                  legend.itemX = initialItemX;
                  legend.itemY += itemMarginTop + legend.lastLineHeight + itemMarginBottom;
                  legend.lastLineHeight = 0; // reset for next line
              }
  
              // If the item exceeds the height, start a new column
              /*if (!horizontal && legend.itemY + options.y + itemHeight > chart.chartHeight - spacingTop - spacingBottom) {
               legend.itemY = legend.initialItemY;
               legend.itemX += legend.maxItemWidth;
               legend.maxItemWidth = 0;
               }*/
  
              // Set the edge positions
              legend.maxItemWidth = mathMax(legend.maxItemWidth, itemWidth);
              legend.lastItemY = itemMarginTop + legend.itemY + itemMarginBottom;
              legend.lastLineHeight = mathMax(itemHeight, legend.lastLineHeight); // #915
  
              // cache the position of the newly generated or reordered items
              item._legendItemPos = [legend.itemX, legend.itemY];
  
              // advance
              if (horizontal) {
                  legend.itemX += itemWidth;
  
              } else {
                  legend.itemY += itemMarginTop + itemHeight + itemMarginBottom;
                  legend.lastLineHeight = itemHeight;
              }
  
              // the width of the widest item
              legend.offsetWidth = widthOption || mathMax(
                  (horizontal ? legend.itemX - initialItemX - itemDistance : itemWidth) + padding,
                  legend.offsetWidth
                );
          }