import { CSSProperties, ReactElement, ReactNode } from 'react'; import { ChartController, ChartMargins, ChartTooltipContext, NumericXConfig, TimeXConfig, ChartAxis, ChartBarAppearance, ChartBackground, ChartCurve, ChartMotion, ChartPalette, ChartHoverReadout, ChartHoverStyle, ChartSeries, ChartTooltipIndicator, ChartStyle, ChartSurface, CardLegend, ChartLegendSwatch, ChartLoadingStyle, ChartEmptyState } from '../types'; import { NumericKey, ResolvedX, XKey, XKind } from './keys'; import { CardAggregate } from './format'; import { AnimatedNumberVariant } from '../motion/animated-number'; import { ChartEmptyShape } from '../lifecycle/chart-empty'; export interface CardSeries { /** A numeric field of each row. */ key: Key; /** Defaults to the key. */ label?: string; /** Any CSS color. Defaults to the next palette color. */ color?: string; /** * A reference such as a previous period or target: drawn as a dashed line without a fill and * left out of the headline total. */ dashed?: boolean; } /** A goal each point should reach. A number, or a value with its own line label. */ export type CardTarget = number | { value: number; label?: string; }; /** Rows from `from` onward are projections rather than measurements. */ export interface CardForecast { /** Supplied uncertainty envelopes, ordered widest to narrowest. Values are never estimated. */ bands?: readonly { lower: NumericKey; upper: NumericKey; label: string; }[]; /** The x value of the first projected row: a label, number, or Date. */ from: string | number | Date; /** Fields holding the low and high end of the projection, drawn as a band around it. */ lower?: NumericKey; upper?: NumericKey; /** Names the projected region and the hover caption. Defaults to "Forecast". */ label?: string; } export interface CardRange { id: string; label: string; data: readonly Row[]; delta?: number; headline?: number; } /** Props every Cartesian card shares. Each card adds its own shape options. */ export interface CartesianCardProps> { /** Optional visible title. Use aria-label to name an embedded chart. */ title?: string; /** Show the header, including headline and period controls. Defaults to true. */ header?: boolean; /** Accessible name, independent of the visible title. */ 'aria-label'?: string; /** One row per x position. Omit when `ranges` supplies the data. */ data?: readonly Row[]; /** Field used for the x axis: labels, numbers, or dates. */ x: XKey; series: readonly CardSeries[]; /** Resting headline. Defaults to the total of every series except dashed references. */ headline?: number; /** * How the headline and tiles summarize the period at rest: `sum` (default) for counts and * money, `mean` or `max` for rates such as latency, `last` for levels such as seats. */ aggregate?: CardAggregate; /** Make the headline follow one series instead of the total, e.g. p95 latency. */ headlineSeries?: NoInfer; /** Fractional change shown as a chip, e.g. 0.082 → +8.2%. */ delta?: number; deltaTone?: 'default' | 'inverse' | 'neutral'; /** Static period label, e.g. "This year". */ range?: string; /** Period select. Each range replaces data, delta and headline. */ ranges?: readonly CardRange[]; defaultRange?: string; /** Per-series stat tiles under the plot. Defaults to true; false hides the legend. */ tiles?: boolean; /** * How the legend under the plot lays out: value `tiles` (default), compact `inline` labels, * `list` rows, tinted `pills`, or `bars` that also draw each value against the largest. * False removes the legend without changing the data or marks. */ legend?: CardLegend | false; /** The mark beside each legend label: `square` (default), `dot`, or `line`. */ legendSwatch?: ChartLegendSwatch; /** * Gives the plot depth: lines become lit tubes with a soft shadow, and bar cards draw * `isometric` blocks. Every point and bar still reads its exact value. */ depth?: boolean; /** Plot height in pixels. Defaults to 240. */ height?: number; /** Number format for the headline, tiles, and axis, e.g. `{ style: 'currency', currency: 'USD' }`. */ valueFormat?: Intl.NumberFormatOptions; locale?: string; /** Full control over value text. Takes precedence over `valueFormat`. */ formatValue?: (value: number) => string; formatAxisValue?: (value: number) => string; formatX?: (value: string | number | Date) => string; /** Override x inference. Numbers default to `number`; use `time` for timestamps. */ xType?: XKind; /** * Axis preset: `minimal` (default), `dots`, `inline`, `ruler`, `classic`, or `segmented`, for * both axes or one per axis, e.g. `{ x: 'minimal', y: { style: 'segmented', gradient: true } }`. */ axis?: ChartAxis; /** Texture behind the plot: `dots` (default), `grid`, `lines`, or `none`. */ background?: ChartBackground; /** * Light up what is under the pointer: the background around a point, and on bar charts the * whole column. Defaults to true. */ spotlight?: boolean; /** * Draw a long line or area from each pixel column's first, last, lowest and highest * observation, so tens of thousands of points stay fast to hover. The ink is the same, and the * headline, tiles, hover and exports still read every row. Defaults to true. */ decimate?: boolean; /** Card treatment: `elevated` (default), `outline`, or `ghost` inside your own card. */ surface?: ChartSurface; /** A glass tab tucked behind the card's top edge, e.g. a caption, a command, or actions. */ badge?: ReactNode; /** Headline motion: `count` (default), `pop`, `slide`, `roll`, `flow`, or `scramble`. */ numberStyle?: AnimatedNumberVariant; /** Series color set. Explicit series colors still win. */ palette?: ChartPalette; /** * Run marks to the card's edges. Line and area cards fade past the first and last * observations. With `false`, data starts and ends at the plot edges and edge labels hang into * the card padding to stay centered. */ bleed?: boolean; /** * Padding in pixels between the plot edges and axis labels or pills. * Defaults to the card padding (20) when `bleed` is on, otherwise 0. */ axisInset?: number; /** * What the hovered point shows, one readout at a time: `pills` (default) on the axes, a * `tooltip` with every series, a `strip` docked above the plot, or `headline`, which leaves the * plot to the hover dots. */ hover?: ChartHoverReadout; /** How the pills or tooltip look: `soft` (default), `solid`, or `accent`. */ hoverStyle?: ChartHoverStyle; /** * Which series the y pill follows and the tooltip leads with: `nearest` (default) tracks the * line closest to the pointer, a series key locks it, and `total` follows the top of a stack. */ pillSeries?: 'nearest' | 'total' | NoInfer; /** Stacks: show the series' own value (`series`, default) or its stacked height (`stack`). */ pillValue?: 'series' | 'stack'; /** * Where the value pill sits: `mark` above the hovered bar or point, `axis` on the y axis. * `auto` (default) uses `mark` when the axis shows no y labels. */ pillPosition?: 'auto' | 'axis' | 'mark'; /** Series marker on each tooltip row: `square` (default), `dot`, or `line`. */ tooltipIndicator?: ChartTooltipIndicator; /** * Enable range comparison by dragging across the plot. Off by default. `true` or `'headline'` * reads the change out in the headline; `'badge'` reads it out in the card's badge tab and * leaves the headline and tiles at rest. */ compare?: boolean | 'headline' | 'badge'; /** * The value each point should reach, drawn as a dashed line. The hovered point reads against * it, and at rest the header counts points on target. With `deltaTone="inverse"`, on target * means at or below it. */ target?: CardTarget; /** * Mark rows from `forecast.from` onward as projections: drawn dotted, left out of the headline * and tiles, and captioned "Forecast" on hover. `lower` and `upper` add a range band on line * and unstacked area cards; each bound must contain the projected value. */ forecast?: CardForecast; /** * Link hover and pins with every card that uses the same name. Cards match by x: labels * exactly, dates and numbers to the nearest row. Every linked card shows its hover marks, * pills, and headline at that point. A click pins every linked card: the clicked card shows the * pin and the others a ghost of it, and any of them releases it. Alt-click pins one card only. */ sync?: string; loading?: boolean; /** * How the skeleton moves while `loading`: `shimmer` (default) sweeps a highlight over still * shapes, `draw` reveals bars or contours in order, `breathe` lets them rise and settle. * Moving skeletons on a page share a clock. */ loadingStyle?: ChartLoadingStyle; /** * What the plot shows when the period has no data: `dots` (default), the chart's own `shape`, * your own element such as `No visits yet`, or `null` for nothing. */ empty?: ChartEmptyState; /** `none` turns off decorative motion; reduced-motion users get this automatically. */ motion?: ChartMotion; className?: string; style?: CSSProperties | ChartStyle; } /** * Series options only some cards expose. The Combo card draws `as: 'line'` series over its bars, * optionally on their own scale and with their own number format and summary. */ export interface CoreSeries extends CardSeries { as?: 'line'; scale?: 'secondary'; valueFormat?: Intl.NumberFormatOptions; aggregate?: CardAggregate; } /** * How a card combines its series: `false` side by side (bars) or overlapping (areas), `sum` * adds them, `percent` shows each series' share of its period. */ export type CardStack = false | 'sum' | 'percent'; /** The public `stack` prop: `true` adds series, `'percent'` shows shares. */ export declare function cardStack(stack: boolean | 'percent' | undefined): CardStack; /** How a specific card draws its marks; everything else is shared. */ export type CardShape = { kind: 'area'; stack: CardStack; curve: ChartCurve; } | { kind: 'line'; curve: ChartCurve; points: boolean; zero: boolean; indexed?: boolean; } | { kind: 'bar'; stack: CardStack; radius: number; /** `end` rounds each bar's value end; `all` rounds every corner of every bar and segment. */ corners: 'end' | 'all'; tracks: boolean; barWidth?: number; appearance: ChartBarAppearance; /** Curve and point markers of lines drawn over the bars. */ curve?: ChartCurve; points?: boolean; } | CardMarks; /** * Column marks drawn from each series' fields, such as candles or range bars. Cards built on * this shape keep every Cartesian card behaviour: headline, ranges, hover sync and tiles. */ export interface CardMarks { kind: 'marks'; /** A stable description of everything below, so memoized series only rebuild when it changes. */ id: string; /** Descriptor options for a series by key, such as its fields, colors, curve, or area. */ series?: (key: string) => Partial> | undefined; /** * The marks for the drawn series, as elements or fragments of them (not wrapped in a * component), so the plot can find column marks. Dashed references still draw as lines. */ draw: (ids: readonly string[]) => ReactNode; includeZero: boolean; scale?: 'linear' | 'log'; curve?: ChartCurve; /** Values the y axis must reach, such as outliers beyond the fields. */ include?: readonly number[]; /** Slot every observation like a bar, so linked bar panes line up. Column marks imply it. */ slots?: boolean; /** Label the x axis here. Turn off when a pane below carries it. Defaults to true. */ xAxis?: boolean; /** Extra text after the hovered x in the headline caption, e.g. open, high and low. */ describe?: (inspection: ChartTooltipContext) => string | null; /** The outline the `shape` empty look draws. Defaults to `bars` for column marks. */ emptyShape?: ChartEmptyShape; } /** Panes drawn under the main plot, linked to it: same data, x, margins and crosshair. */ export interface CardPaneContext { loadingStyle?: ChartLoadingStyle; data: readonly Row[]; x: TimeXConfig | NumericXConfig; controller: ChartController; margins: ChartMargins; /** The main plot's `axisInset` and `slots`, so a pane's observations sit under its own. */ axisInset: number; slots: boolean; axis: ChartAxis; loading: boolean; motion?: ChartMotion; hoverStyle: ChartHoverStyle; formatValue: (value: number) => string; formatAxis: (value: number) => string; } /** Matches the default `--lilt-card-padding`. */ export declare const CARD_PADDING = 20; /** * The shared card body: headline, delta, period, plot, and value tiles, with hover sync and * range comparison. Area, Line, and Bar cards differ only in their `shape`. */ export declare function CartesianCard>({ shape, title, header, 'aria-label': ariaLabel, data: suppliedData, x, series: seriesInput, headline: suppliedHeadline, aggregate: suppliedAggregate, headlineSeries, delta: suppliedDelta, deltaTone, range, ranges, defaultRange, tiles, legend, legendSwatch, depth, height, valueFormat, locale, formatValue: suppliedFormatValue, formatAxisValue: suppliedFormatAxisValue, formatX, xType, compare, target: suppliedTarget, forecast, sync, axis, hover, hoverStyle, background, spotlight, decimate, surface, badge, numberStyle, palette, bleed, axisInset, pillSeries, pillValue, pillPosition, tooltipIndicator, loading, loadingStyle, empty, motion, className, style, panes, live, heading, restCaption, }: Omit, 'series'> & { series: readonly CoreSeries[]; shape: CardShape; /** Linked panes under the plot, such as volume or indicators. */ panes?: (context: CardPaneContext) => ReactNode; /** Follow the newest observation as rows arrive. */ live?: boolean; /** Richer title content, such as a ticker and its name; `title` still labels the chart. */ heading?: ReactNode; /** Text beside the delta at rest, such as an absolute change, from the active data. */ restCaption?: (data: readonly Row[]) => ReactNode; }): ReactElement; /** The plot position where projections begin: a label's row, or the date or number itself. */ export declare function forecastPosition(data: readonly Row[], x: string, resolved: ResolvedX, from: string | number): number | null;