import { ComputedRef, InjectionKey, Ref } from 'vue'; import { ChartXScale, ChartYScale } from './scales'; import { ChartPadding, PlotArea, ScaleKind, SeriesExtent } from './types'; /** * The live reading position in container pixel coordinates. A mouse writes it * while it hovers; a press-drag (mouse, touch or pen) keeps writing it outside * the plot, clamped to the plot's edge; keyboard stepping writes the position * of the datum it lands on. */ export interface ChartPointer { x: number; y: number; /** A reading is showing. */ inside: boolean; /** A press-drag past the 4px slop holds the pointer. */ pressed: boolean; /** What placed the reading: a pointer, or keyboard stepping. */ source: 'pointer' | 'keyboard'; } /** A gesture that moves the chart's view; readings pause while it pans or pinches. */ export type ChartGesture = 'brush' | 'pan' | 'pinch' | null; /** * A layer that answers keys on the focused chart: a pie stepping its slices, * a viewport zooming. Layers are asked newest first, before the chart's own * stepping through x values. */ export interface ChartKeyLayer { /** Handle a key; return true when it was consumed. */ key: (event: KeyboardEvent) => boolean; /** Drop any reading the layer placed (the chart lost focus, or Escape). */ clear?: () => void; } /** A bar series registered for lane/stack layout. */ export interface BarSeriesEntry { uid: number; stack: string | null; /** x key → y value for the series' current data. */ points: () => Map; } export interface BarLayout { /** Side-by-side lanes: each unstacked series is a lane, each stack shares one. */ laneCount: number; laneIndex: (uid: number) => number; /** Cumulative baseline under `uid` at `xKey` (0 unless stacked above others). */ baseline: (uid: number, xKey: string | number) => number; } export interface TxChartContext { width: Readonly>; height: Readonly>; plot: ComputedRef; xType: Readonly>; /** The full x domain the data spans, before any view window. */ xDomainFull: ComputedRef>; /** * The x window a view layer shows in place of the full domain, in data * units; `null` shows it all. Continuous scales only. */ xView: Ref<[number, number] | null>; xScale: ComputedRef; yScale: ComputedRef; /** id of the plot-area clipPath series should reference. */ clipId: string; pointer: ChartPointer; container: Readonly>; /** Report a series' data extent; returns an unregister function. */ registerSeries: (extent: Ref) => () => void; /** Next categorical color slot as a theme-following var() reference. */ allocateColor: () => string; registerBar: (entry: BarSeriesEntry) => () => void; barLayout: ComputedRef; /** * Every x a mounted series has a datum at, in axis order: the band domain on * band scales, sorted distinct values on continuous ones. */ xStops: ComputedRef>; /** The stop drawn nearest a container x inside the current x domain, or `null`. */ nearestXStop: (px: number) => string | number | null; /** Add a key layer; returns an unregister function. */ registerKeyLayer: (layer: ChartKeyLayer) => () => void; /** Registered key layers, newest last. */ keyLayers: readonly ChartKeyLayer[]; /** * While true, series draw the current scales on the same frame instead of * morphing towards them: a pan or zoom moves the scales every frame. */ immediate: Ref; /** The view gesture in progress, if any. */ gesture: Ref; /** A view layer zooms this chart; its keyboard instructions say so. */ zoomable: Ref; /** Text for the chart's polite live region; layers write their keyboard readings here. */ announcement: Ref; } export declare const chartContextKey: InjectionKey; export declare function useChartContext(component: string): TxChartContext; export interface CreateChartContextInput { width: Ref; height: Ref; padding: ComputedRef; xType: Ref; xDomain: Ref | undefined>; yDomain: Ref<[number, number] | undefined>; yNice: Ref; container: Ref; } export declare function createChartContext(input: CreateChartContextInput): TxChartContext;