/** * A calendar interval unit for range buttons. */ export type RangeButtonIntervalUnit = 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'; /** * Parameters passed to a range button function value. */ export interface RangeButtonFunctionParams { /** * The scale type of the axis (e.g., `'time'`, `'band'`, `'linear'`). */ scaleType: string; /** * The axis data values. Available for ordinal (band/point) axes. */ data: readonly unknown[] | undefined; /** * The full domain bounds, ignoring any current zoom. * For time axes, these are timestamps. For ordinal axes, these are indices. */ domain: { min: number; max: number; }; } /** * Defines the value of a range button. * * - `{ unit, step }` — A calendar interval from the end of the data. * @example { unit: 'month', step: 3 } // Last 3 months * @example { unit: 'year' } // Last year (step defaults to 1) * - `[start, end]` — An absolute date range. * @example [new Date(2024, 0, 1), new Date(2024, 6, 1)] // Jan–Jul 2024 * - `(params) => { start, end }` — A function that receives axis context (`scaleType`, `data`, `domain`) and returns zoom percentages (0-100). * @example ({ domain }) => ({ start: 0, end: 50 }) // First half of data * @example ({ data }) => { * const lastFive = Math.max(0, data.length - 5); * return { start: (lastFive / (data.length - 1)) * 100, end: 100 }; * } // Last 5 items on an ordinal axis * - `null` — Resets zoom to show all data. * @example null // Show all data */ export type RangeButtonValue = { unit: RangeButtonIntervalUnit; step?: number; } | [Date, Date] | ((params: RangeButtonFunctionParams) => { start: number; end: number; }) | null; /** * Converts a range button value to zoom start/end percentages. * * The range is calculated from the end of the axis domain. * For example, `{ unit: 'month', step: 3 }` will zoom to show the last 3 months of data. * * @param value The range button value. * @param params The axis context passed to function values. * @param params.scaleType The scale type of the axis. * @param params.data The axis data values (for ordinal axes). * @param params.domain The full domain bounds. * @returns The zoom start and end percentages (0-100). */ export declare function rangeButtonValueToZoom(value: RangeButtonValue, params: RangeButtonFunctionParams): { start: number; end: number; };