code: function () {
              var allItems = [];
              each(this.chart.series, function (series) {
                  var seriesOptions = series.options;
  
                  // Handle showInLegend. If the series is linked to another series, defaults to false.
                  if (!pick(seriesOptions.showInLegend, !defined(seriesOptions.linkedTo) ? UNDEFINED : false, true)) {
                      return;
                  }
  
                  // use points or series for the legend item depending on legendType
                  allItems = allItems.concat(
                    series.legendItems ||
                    (seriesOptions.legendType === 'point' ?
                      series.data :
                      series)
                  );
              });
              return allItems;
          }
docs: Get all items, which is one item per series for normal series and one item per point
  for pie series.