import { type HTMLAttributes, type ReactElement, type Ref } from 'react'; import type { SyncMethod } from 'recharts/types/synchronisation/types'; import { type TestableProps } from '../../../utils/testId'; import { type LineChartDatum, type LineChartSeries, type LineChartZoomRange } from './LineChartContext'; /** * Generic over the datum shape so `xKey` and `series[].key` are checked at * compile time against the actual data interface. When `T` is left at the * default `LineChartDatum`, the constraints collapse to `string` and the API * keeps its untyped form — the safety only kicks in when callers pass a * concrete datum interface. * * ```ts * interface RequestRow { timestamp: number; requests: number; errors: number } * * * data={rows} * xKey='timestamp' // ✅ valid keyof T * series={[{ key: 'errors', label: 'Errors' }]} // ✅ valid keyof T * /> * data={rows} xKey='timetamp' /> // ❌ Type error * ``` */ export interface LineChartProps extends HTMLAttributes, TestableProps { ref?: Ref; /** Long-form data array, one entry per X position. */ data: T[]; /** Schema describing each line drawn from `data`. */ series: LineChartSeries>[]; /** * Key on each datum used as the X-axis value. Required — a silent fallback * would hide key-name typos until the chart renders empty. */ xKey: Extract; /** * Controlled hover key — pass alongside `onActiveKeyChange` for cross-chart * sync. * * **Heads-up:** if the controlled value points at a series key that no * longer exists in `series` (filter, schema change, refresh), the chart * pushes `null` back through `onActiveKeyChange` so sibling charts stop * highlighting a stale key. If you wire `activeKey` to external state, the * snap-to-null write will arrive as a normal state change — do not be * surprised when your value resets after a series disappears. */ activeKey?: string | null; onActiveKeyChange?: (key: string | null) => void; /** Controlled set of `series.key` values to hide from the plot. */ filteredKeys?: string[]; /** Fired after the user confirms a brush selection. */ onZoomChange?: (range: LineChartZoomRange | null) => void; /** * Charts that share a `syncId` synchronise their tooltip cursor and brush * via recharts' built-in middleware — hovering one chart highlights the * matching X on every sibling chart with the same id. Pair with `activeKey` * + `onActiveKeyChange` if you also want the *series* highlight to sync. */ syncId?: string | number; /** * How sibling `syncId` charts match X positions. Defaults to `'index'` * (Recharts' default). Use `'value'` when the synced charts have different * dataset lengths but share categorical X values. * * @see {@link https://recharts.github.io/en-US/examples/SynchronizedAreaChart/ Recharts synchronisation example} */ syncMethod?: SyncMethod; } export declare function LineChart({ data, series, xKey, activeKey: controlledActiveKey, onActiveKeyChange, filteredKeys, onZoomChange, syncId, syncMethod, className, children, ref, 'data-testid': testId, ...props }: LineChartProps): ReactElement; export declare namespace LineChart { var displayName: string; }