Repository: apache/superset
File: superset-frontend/plugins/plugin-chart-echarts/src/Radar/transformProps.ts (TypeScript)

Code before:
  };
  const { setDataMask = () => {}, onContextMenu } = hooks;
  const colorFn = CategoricalColorNamespace.getScale(colorScheme as string);
  const numberFormatter = getNumberFormatter(numberFormat);
  const denormalizedSeriesValues: SeriesNormalizedMap = {};

  const getDenormalisedSeriesValue = (
    seriesName: string,
    normalisedValue: string,
  ): number => {
    if (
      Object.prototype.hasOwnProperty.call(
        denormalizedSeriesValues,
        seriesName,
      ) &&
      Object.prototype.hasOwnProperty.call(
        denormalizedSeriesValues[seriesName],
        normalisedValue,
      )
    ) {
      return denormalizedSeriesValues[seriesName][normalisedValue];
    }

    // Fallback: return the normalised value itself as a number
    return Number(normalisedValue);
  };

  const formatter = (params: CallbackDataParams) =>
    formatLabel({
      params,
      numberFormatter,
      labelType,
      getDenormalisedSeriesValue,
      isNormalised,
    });

  const metricLabels = metrics.map(getMetricLabel);
  const groupbyLabels = groupby.map(getColumnLabel);

  const metricLabelAndMaxValueMap = new Map<string, number>();
  const metricLabelAndMinValueMap = new Map<string, number>();
  const columnsLabelMap = new Map<string, string[]>();
  let transformedData: RadarSeriesDataItemOption[] = [];
  data.forEach(datum => {
    const joinedName = extractGroupbyLabel({
      datum,
      groupby: groupbyLabels,
      coltypeMapping,
      timeFormatter: getTimeFormatter(dateFormat),
    });
    // map(joined_name: [columnLabel_1, columnLabel_2, ...])

Review comment (bug):
The  getDenormalisedSeriesValue is getter function for safely getting the denormalised value , if we dont find the value we fallback to normalised value, this shouldnt happen but we do this to prevent crashes & unexpected errors which can crash the user experience

Code after:
    ...DEFAULT_LEGEND_FORM_DATA,
    ...DEFAULT_RADAR_FORM_DATA,
    ...formData,
  };
  const { setDataMask = () => {}, onContextMenu } = hooks;
  const colorFn = CategoricalColorNamespace.getScale(colorScheme as string);
  const numberFormatter = getNumberFormatter(numberFormat);
  const denormalizedSeriesValues: SeriesNormalizedMap = {};

  const getDenormalizedSeriesValue = (
    seriesName: string,
    normalizedValue: string,
  ): number =>
    denormalizedSeriesValues?.[seriesName]?.[normalizedValue] ??
    Number(normalizedValue);

  const metricLabels = metrics.map(getMetricLabel);

  const metricsWithCustomBounds = new Set(
    metricLabels.filter(metricLabel => {
      const config = columnConfig?.[metricLabel];
      const hasMax = !!isDefined(config?.radarMetricMaxValue);
      const hasMin =
        isDefined(config?.radarMetricMinValue) &&
        config?.radarMetricMinValue !== 0;
      return hasMax || hasMin;
    }),
  );

  const formatter = (params: CallbackDataParams) =>
    formatLabel({
      params,
      numberFormatter,
      labelType,
      getDenormalizedSeriesValue,
      metricsWithCustomBounds,
      metricLabels,
    });

  const groupbyLabels = groupby.map(getColumnLabel);

  const metricLabelAndMaxValueMap = new Map<string, number>();
  const metricLabelAndMinValueMap = new Map<string, number>();
  const columnsLabelMap = new Map<string, string[]>();
  const transformedData: RadarSeriesDataItemOption[] = [];
  data.forEach(datum => {
    const joinedName = extractGroupbyLabel({
      datum,
      groupby: groupbyLabels,
      coltypeMapping,
      timeFormatter: getTimeFormatter(dateFormat),