code: function generateLegend(legendHelper) {
    var legendProps;
    if (
      !defined(legendHelper.tableColumn) ||
      !defined(legendHelper.tableColumn.values)
    ) {
      // If no table column is active, color it as if it were an ENUM with the maximum available colors.
      if (legendHelper.regionProvider) {
        legendHelper._binColors = buildEnumBinColors(
          legendHelper,
          legendHelper.regionProvider.regions,
          "top",
          undefined
        );
        legendProps = buildEnumLegendProps(
          legendHelper,
          legendHelper.regionProvider.regions
        );
      } else {
        legendProps = defined(legendHelper.name)
          ? {
              items: [
                {
                  title: legendHelper.name,
                  color: convertColorArrayToCssString(
                    legendHelper._noColumnColorArray
                  )
                }
              ]
            }
          : undefined;
      }
    } else if (legendHelper.tableColumn.isEnum) {
      var tableColumnStyle = legendHelper.tableColumnStyle;
      var uniqueValues = legendHelper.tableColumn.uniqueValues;
      legendHelper._binColors = buildEnumBinColors(
        legendHelper,
        uniqueValues,
        tableColumnStyle.colorBinMethod,
        tableColumnStyle.colorBins
      );
      legendProps = buildEnumLegendProps(legendHelper, uniqueValues);
    } else {
      var colorMap = defaultValue(
        legendHelper.tableColumnStyle.colorMap,
        defaultScalarColorMap
      );
      var colorBins = defaultValue(
        legendHelper.tableColumnStyle.colorBins,
        defaultNumberOfColorBins
      );
  
      legendHelper._colorGradient = buildColorGradient(colorMap);
      legendHelper._binColors = buildBinColors(legendHelper, colorBins);
      legendProps = buildLegendProps(legendHelper, colorMap);
    }
    if (defined(legendProps)) {
      legendHelper._legend = new Legend(legendProps);
    } else {
      legendHelper._legend = null; // use null so that we know it tried and failed, so don't try again.
    }
  }
docs: Generates intermediate variables (such as _colorGradient, _binColors) and saves the legend.
  This could be exposed in an API if needed.
  @private