@tanstack/charts
Version:
A chart grammar for TypeScript and JavaScript. Marks consume your data directly, channels describe visual encodings, and the engine compiles them into a renderer-neutral keyed scene. TanStack's compact scales cover common numeric and categorical mappings.
27 lines (26 loc) • 1.8 kB
TypeScript
import { resolveDotLayout } from './dot-layout.js';
import type { DotLayout } from './dot-layout.js';
import type { ChartValue } from './types.js';
export type { DotLayout, DotLayoutResolveContext } from './dot-layout.js';
export interface CreateDotLayoutOptions<TAxis extends 'x' | 'y', TAnchor extends ChartValue> {
readonly axis: TAxis;
readonly anchor: TAnchor;
readonly resolve: DotLayout<TAxis, TAnchor>[typeof resolveDotLayout];
}
export type DodgeXAnchor = 'left' | 'middle' | 'right';
export type DodgeYAnchor = 'top' | 'middle' | 'bottom';
export interface DodgeOptions<TAnchor extends string> {
anchor?: TAnchor;
/** Empty pixels between neighboring circle edges. Defaults to 1. */
padding?: number;
}
export type DodgeXOptions<TAnchor extends DodgeXAnchor = DodgeXAnchor> = DodgeOptions<TAnchor>;
export type DodgeYOptions<TAnchor extends DodgeYAnchor = DodgeYAnchor> = DodgeOptions<TAnchor>;
export type DodgeXLayout<TAnchor extends DodgeXAnchor = DodgeXAnchor> = DotLayout<'x', TAnchor>;
export type DodgeYLayout<TAnchor extends DodgeYAnchor = DodgeYAnchor> = DotLayout<'y', TAnchor>;
/** Creates a responsive final-pixel layout for one derived dot coordinate. */
export declare function createDotLayout<const TAxis extends 'x' | 'y', const TAnchor extends ChartValue>(options: CreateDotLayoutOptions<TAxis, TAnchor>): DotLayout<TAxis, TAnchor>;
/** Derives collision-free pixel x positions while preserving scaled y. */
export declare function dodgeX<const TAnchor extends DodgeXAnchor = 'left'>(options?: DodgeXOptions<TAnchor>): DodgeXLayout<TAnchor>;
/** Derives collision-free pixel y positions while preserving scaled x. */
export declare function dodgeY<const TAnchor extends DodgeYAnchor = 'bottom'>(options?: DodgeYOptions<TAnchor>): DodgeYLayout<TAnchor>;