All files / src/pages/flowsheet-page/economics/results-panel/charts EconomicsChartTooltip.tsx

18.75% Statements 3/16
12.5% Branches 2/16
33.33% Functions 1/3
22.22% Lines 2/9

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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55        46x                                                   46x                                                
import { formatAmount } from "../../shared/model/economicsFormatters";
import type { ChartAssumption, WarningRef } from "../model/types";
import { tooltipUnit } from "./chartFormatters";
 
export function EconomicsChartTooltip({
  active,
  payload,
}: {
  active?: boolean;
  payload?: Array<{
    name?: string;
    value?: number | string | null;
    dataKey?: string | number;
    payload?: {
      unit?: string;
      assumptions?: ChartAssumption[];
      sourceRowKey?: string;
      warningRefs?: WarningRef[];
      sourceRows?: Record<
        string,
        {
          unit?: string;
          assumptions?: ChartAssumption[];
          warningRefs?: WarningRef[];
        }
      >;
    };
  }>;
  label?: string | number;
}) {
  Iif (!active || !payload?.length) return null;
  const showSeriesLabels = payload.length > 1;
  return (
    <div className="rounded-md border bg-background p-2 text-xs shadow-xl">
      <div className="space-y-1">
        {payload.map((item) => (
          <div
            key={`${item.name}-${item.dataKey}`}
            className="flex items-center gap-2"
          >
            {showSeriesLabels && (
              <span className="text-muted-foreground">
                {String(item.name ?? item.dataKey)}
              </span>
            )}
            <span className="font-mono tabular-nums">
              {formatAmount(item.value)} {tooltipUnit(item)}
            </span>
          </div>
        ))}
      </div>
    </div>
  );
}