import { ReactElement, ReactNode } from 'react'; import { ChartSnapshot } from '../chart-context'; import { NormalizedRow } from '../engine/normalize'; import { ChartSeries } from '../types'; import { RangeScales } from '../engine/ranges'; /** A neutral column uses the mark's own geometry, never an accepted observation. */ export interface LoadingMark { kind: string; depth?: boolean; render: (input: { cx: number; low: number; high: number; scales: RangeScales; mask: boolean; }) => ReactNode; } /** * The private contract every range mark is built on. A mark is an ordinary primitive that * draws from the chart context; its spec tells the plot how to lay it out and inspect it. * The contract is internal until it has proved itself across several marks. */ export interface MarkSpec

{ /** * `column` marks give each observation a bar-like slot, so the plot insets its edges, and * replace the line point with their own highlight on inspection. `overlay` marks, such as a * band behind a line, leave layout and inspection to the line. */ layout: 'column' | 'overlay'; series: (props: P) => string; /** Field IDs the mark reads from its series. */ fields: (props: P) => readonly string[]; loading?: (props: P) => LoadingMark; /** Draws one observation emphasized, over the dimmed marks, while it is inspected. */ highlight?: (props: P, input: MarkHighlightInput) => ReactNode; /** * The color one observation is drawn in, when the mark decides it (rising and falling * candles). Otherwise the series' `colorAt`, then its color. */ color?: (props: P, input: Omit) => string | undefined; } export interface MarkHighlightInput { row: NormalizedRow; snapshot: ChartSnapshot; descriptor: ChartSeries; color: string; } /** A mark found among a plot's children, with its props bound. */ export interface PlotMark { series: string; layout: MarkSpec['layout']; fields: readonly string[]; loading?: LoadingMark; highlight?: (input: MarkHighlightInput) => ReactNode; color?: (input: Omit) => string | undefined; } export declare function defineMark

(component: (props: P) => ReactElement, spec: MarkSpec

): (props: P) => ReactElement; /** Marks placed directly in a plot, or inside fragments there, in document order. */ export declare function collectMarks(children: ReactNode): PlotMark[]; /** The descriptor a mark draws, after checking it carries every field the mark reads. */ export declare function markSeries(mark: string, descriptors: readonly ChartSeries[], series: string, fields: readonly string[]): { descriptor: ChartSeries; index: number; }; /** Field values of one row, or null when any of them is missing. */ export declare function rowFields(row: NormalizedRow, series: string, fields: readonly string[]): number[] | null; /** An observation's own color, falling back to the series color. */ export declare function observationColor(descriptor: ChartSeries, row: NormalizedRow, fallback: string): string;