export function getThresholdConfig()

in src/utils/charts/config.js [244:289]


export function getThresholdConfig(thresholds) {
  if (!thresholds.length) {
    return {};
  }

  const data = thresholds.reduce(
    (acc, alert) => {
      const { threshold, operator } = alert;

      if (GREATER_THAN.includes(operator)) {
        acc.areas.push(
          generateMarkArea({
            min: threshold,
            max: Infinity,
          })
        );
      } else if (LESS_THAN.includes(operator)) {
        acc.areas.push(
          generateMarkArea({
            min: Number.NEGATIVE_INFINITY,
            max: threshold,
          })
        );
      }

      acc.lines.push(
        generateMarkLines({
          max: threshold,
        })
      );

      return acc;
    },
    { lines: [], areas: [] }
  );

  return {
    markLine: {
      data: data.lines,
    },
    markArea: {
      data: data.areas,
      zlevel: -1,
    },
  };
}