import { ComputedAnnotationValue } from './stats'; import { LayoutRect, ThemeContext } from '../../shared/kernel'; import { ColorValue, Datum, FontOptions, Pixels } from '../../shared/options'; import { AnyScale } from '../../shared/scale'; import { Group } from '../../shared/scene'; interface AnnotationLabel extends FontOptions { text?: string; } /** A line knows the number it ended up on, so its label can say it. */ interface LineAnnotationLabel extends AnnotationLabel { formatter?: (value: number) => string; } export type AnnotationOptions = { type: 'horizontal-line'; /** A level, or the statistic that decides it: `{ stat: 'mean', field: 'price' }`. */ value: number | ComputedAnnotationValue; stroke?: ColorValue; strokeWidth?: Pixels; lineDash?: Pixels[]; label?: LineAnnotationLabel; } | { type: 'vertical-line'; /** A category, a date, a number — or a statistic over a field. */ value: unknown | ComputedAnnotationValue; stroke?: ColorValue; strokeWidth?: Pixels; lineDash?: Pixels[]; label?: LineAnnotationLabel; } | { type: 'line'; start: { x: unknown; y: number; }; end: { x: unknown; y: number; }; stroke?: ColorValue; strokeWidth?: Pixels; lineDash?: Pixels[]; } | { type: 'text'; x: unknown; y: number; text: string; color?: ColorValue; fontSize?: Pixels; } | { type: 'range'; axis: 'x' | 'y'; /** Both ends take a statistic too: `[{ stat: 'percentile', percentile: 5, … }, …]`. */ range: [unknown | ComputedAnnotationValue, unknown | ComputedAnnotationValue]; fill?: ColorValue; fillOpacity?: number; label?: AnnotationLabel; }; export interface AnnotationsRenderArgs { layer: Group; plot: LayoutRect; xScale: AnyScale; yScale: AnyScale; theme: ThemeContext; /** Rows the computed values are taken over; without them only plain values draw. */ data?: Datum[]; } /** Declarative annotations in data coordinates (interactive drawing — later). */ export declare function renderAnnotations(annotations: AnnotationOptions[], args: AnnotationsRenderArgs): void; export { isComputedValue, computeStat, resolveValue } from './stats'; export type { AnnotationStat, ComputedAnnotationValue } from './stats'; /** Feature API for widgets (via registry.getFeature('annotations')). */ export declare const annotationsApi: { render: typeof renderAnnotations; }; export type AnnotationsApi = typeof annotationsApi; export declare const annotationsModule: { readonly kind: "feature"; readonly name: "annotations"; readonly api: { render: typeof renderAnnotations; }; };