All files / libs/reporting/dashboards/components/src/lib/home-legacy/benchmark-by-rule-widget/benchmark-by-rule BenchmarkByRule.tsx

12.5% Statements 1/8
0% Branches 0/5
0% Functions 0/5
16.66% Lines 1/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39                            15x                                                
import { memo, useMemo } from 'react';
 
import { sumTotalForUser, type DataBenchmarkByRule } from '../../dashboard.utils';
 
import { BenchmarkByRuleRow } from './BenchmarkByRuleRow';
 
interface BenchmarkByRuleProps {
  readonly colors?: string[];
  readonly height?: number | string;
  readonly width?: number | string;
  readonly data?: DataBenchmarkByRule[];
  readonly loading?: boolean;
}
 
export const BenchmarkByRule = memo(function BenchmarkByRule({
  colors = [],
  width = '300px',
  height = '300px',
  loading = true,
  data = [],
}: BenchmarkByRuleProps) {
  const max = useMemo(() => Math.max(...data.map((entry) => sumTotalForUser(entry))), [data]);
  const graphs = useMemo(
    () =>
      data.map((row, idx) => (
        <BenchmarkByRuleRow
          key={row.label}
          colors={colors}
          idx={idx}
          loading={loading}
          max={max}
          row={row}
        />
      )),
    [colors, data, loading, max],
  );
  return <div style={{ height, width }}>{graphs}</div>;
});