import { MeasureText, SelectionStyleContext, TooltipContentData } from '../kernel'; import { ColorValue, Datum, FontOptions, Formattable, Fraction, PartLabelLayout, Pixels, Switchable } from '../options'; import { Group } from '../scene'; /** Values of a part field, with everything that cannot be a share read as zero. */ export declare function partValues(data: Datum[], field: string): number[]; /** Whether a part is a big enough share of the total to be worth a label (label.minShare). */ export declare function worthLabelling(value: number, total: number, minShare: Fraction | undefined): boolean; /** * Which labels lose their spot with label.avoidOverlap on. The largest parts * ask first, so a crowded chart drops the labels of its slivers rather than * whichever ones happen to be drawn last. */ export declare function crowdedOut(entries: readonly T[], weight: (entry: T) => number, admits: (entry: T) => boolean): Set; export interface PartTooltipParams { /** Part name — the heading of the tooltip. */ heading: string; /** What the single row is called: the series name, or the value field. */ label: string; value: unknown; /** Share of the total, 0..1; undefined when there is no total to compare against. */ share?: number; color: ColorValue; } /** The default tooltip of a part: its name, its value and its share of the whole. */ export declare function partTooltip({ heading, label, value, share, color }: PartTooltipParams): TooltipContentData; /** What a tooltip renderer returned, as content: a bare string is the heading. */ export declare function tooltipContentOf(result: string | TooltipContentData): TooltipContentData; /** One styled run of a part label: the name, the value, or what separates them. */ export interface LabelPart { text: string; fontSize: Pixels; fontFamily: string; fontWeight?: string; color: ColorValue; } /** * What a format contract says about a value — the formatter first, then the * format string. Undefined when it says nothing, so the caller can fall back to * the next contract in line: the half of a label defers to the name format of * the series, which defers to the raw value. */ export declare function formattedText

(raw: unknown, options: Formattable

| undefined, params: P): string | undefined; /** * Text of one half of a label: the format contract, or the raw field value when * it has nothing to say. Both halves of a block answer the same way — a name * that comes out of a date or a coded field is formatted like the number * beside it. */ export declare function partText

(raw: unknown, options: Formattable

| undefined, params: P): string; /** The font every part of a label falls back to. */ export interface LabelPartDefaults { fontSize: Pixels; fontFamily: string; fontWeight?: string; color: ColorValue; } export declare function partFont(part: LabelPart): string; /** * The label of one part, run by run. Each run carries its own font and colour — * the name and the value are one label, styled separately — and an inline label * keeps the separator as a run of its own, so it picks up the font of the name * it follows. Runs given without a font of their own fall back to `defaults`. */ export declare function labelParts(entries: ReadonlyArray<{ text: string; font?: (Switchable & FontOptions) | undefined; }>, defaults: LabelPartDefaults, options?: { layout?: PartLabelLayout; separator?: string; }): LabelPart[]; /** Rows the runs are drawn in: one row per run when stacked, all in one when inline. */ export declare function labelRows(parts: readonly LabelPart[], layout: PartLabelLayout | undefined): LabelPart[][]; /** Size of the whole label block — what the layout has to find room for. */ export declare function labelBlockSize(parts: readonly LabelPart[], measureText: MeasureText, layout: PartLabelLayout | undefined): { width: number; height: number; }; /** * Draws the label block anchored at (x, y): `align` places the whole block * horizontally, the block is always centred on y. `outline` haloes the text * against the mark it sits on. */ export declare function drawLabelBlock(group: Group, parts: readonly LabelPart[], x: number, y: number, align: 'left' | 'right' | 'center', measureText: MeasureText, layout: PartLabelLayout | undefined, outline?: ColorValue): void; /** A mark the selection can style: whatever the shape, it has an outline and an opacity. */ export interface SelectableMark { stroke?: ColorValue; strokeWidth: Pixels; opacity: number; } /** What a series knows about the selection while it renders. */ export interface PartSelectionContext { selected?: ReadonlySet; selectionActive?: boolean; selectionStyle?: SelectionStyleContext; } /** * How a selection reads on a part: the picked-out ones are outlined, the rest * fade back while any selection is active. `fallback` is the outline the mark * carries on its own — a selected mark borrows the foreground colour instead. */ export declare function applySelection(mark: SelectableMark, index: number, ctx: PartSelectionContext, fallback: { stroke?: ColorValue; strokeWidth?: Pixels; foreground: ColorValue; }): boolean;