import type { AxisConfig, D3Scale } from "../models/axis.js"; import type { OrdinalTimeTicks } from "../models/timeTicks.js"; export interface TickParams { /** * Maximal step between two ticks. * When using time data, the value is assumed to be in ms. * Not supported by categorical axis (band, points). */ tickMaxStep?: number; /** * Minimal step between two ticks. * When using time data, the value is assumed to be in ms. * Not supported by categorical axis (band, points). */ tickMinStep?: number; /** * The number of ticks. This number is not guaranteed. * Not supported by categorical axis (band, points). */ tickNumber?: number; /** * Defines which ticks are displayed. * Its value can be: * - 'auto' In such case the ticks are computed based on axis scale and other parameters. * - a filtering function of the form `(value, index) => boolean` which is available only if the axis has "point" scale. * - an array containing the values where ticks should be displayed. * @see See {@link https://mui.com/x/react-charts/axis/#fixed-tick-positions} * @default 'auto' */ tickInterval?: 'auto' | ((value: any, index: number) => boolean) | any[]; /** * The placement of ticks in regard to the band interval. * Only used if scale is 'band'. * @default 'extremities' */ tickPlacement?: 'start' | 'end' | 'middle' | 'extremities'; /** * The placement of ticks label. Can be the middle of the band, or the tick position. * Only used if scale is 'band'. * @default 'middle' */ tickLabelPlacement?: 'middle' | 'tick'; /** * The minimum space between ticks when using an ordinal scale. It defines the minimum distance in pixels between two ticks. * @default 0 */ tickSpacing?: number; } export type TickItem = { /** * The value of the tick. * It is only `undefined` if it's the tick closing the last band. */ value?: any; /** * The formatted value of the tick. * It is only `undefined` if it's the tick closing the last band. */ formattedValue?: string; /** * The offset in pixels relative to the SVG origin. * For an x-axis, it is relative to the left side of the SVG. * For a y-axis, it is relative to the top side of the SVG. */ offset: number; /** * The offset in pixels relative to the tick position. * For an x-axis, a positive value means the label is shifted to the right of the tick. * For a y-axis, a positive value means the label is shifted downwards from the tick. */ labelOffset: number; }; /** * Returns a new domain where each tick is at least {@link tickSpacing}px from the next one. * Assumes tick spacing is greater than 0. * @param domain Domain of the scale. * @param range Range of the scale. * @param tickSpacing Spacing in pixels. */ export declare function applyTickSpacing(domain: T[], range: [number, number], tickSpacing: number): T[]; interface GetTicksOptions extends Pick, Required> { scale: D3Scale; valueFormatter?: AxisConfig['valueFormatter']; isInside: (offset: number) => boolean; ordinalTimeTicks?: OrdinalTimeTicks; } export declare function getTicks(options: GetTicksOptions): TickItem[]; export declare function useTicks(options: Omit & { direction: 'x' | 'y' | 'rotation' | 'radius'; }): TickItem[]; export {};