@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.
39 lines (38 loc) • 2.09 kB
TypeScript
import type { TransformLineage } from './transform.js';
import type { Channel, ChannelOutput, ChartKey, ChartMark, ChartMarkMotionOptions, ChartValue, VisualChannel } from './types.js';
export interface DensityContourDatum<TDatum> extends TransformLineage<TDatum> {
/** Weighted observations per CSS pixel squared at this contour level. */
readonly density: number;
readonly group: ChartKey | null;
}
export interface DensityContourOptions<TDatum> extends ChartMarkMotionOptions<never> {
id?: string;
x: Channel<TDatum, ChartValue | null | undefined>;
y: Channel<TDatum, ChartValue | null | undefined>;
/** Estimates a separate density field for each non-null group. */
z?: Channel<TDatum, ChartKey | null | undefined>;
weight?: Channel<TDatum, number | null | undefined>;
/** Gaussian-kernel bandwidth in final CSS pixels. Defaults to 20. */
bandwidth?: number;
/** Density-grid cell size in final CSS pixels. Defaults to 4. */
cellSize?: number;
/** Exact density levels or an approximate shared level count. Defaults to 20. */
thresholds?: number | Iterable<number>;
color?: Channel<DensityContourDatum<TDatum>, ChartKey | null | undefined>;
fill?: VisualChannel<DensityContourDatum<TDatum>, string>;
fillOpacity?: number;
stroke?: VisualChannel<DensityContourDatum<TDatum>, string>;
strokeOpacity?: number;
strokeWidth?: number;
strokeDasharray?: string;
opacity?: number;
}
type DensityXOutput<TDatum, TOptions> = ChannelOutput<TDatum, TOptions extends {
x: infer TChannel;
} ? TChannel : never, number>;
type DensityYOutput<TDatum, TOptions> = ChannelOutput<TDatum, TOptions extends {
y: infer TChannel;
} ? TChannel : never, number>;
/** Estimates filled density contours after x/y scales reach final screen space. */
export declare function densityContour<TDatum, const TOptions extends DensityContourOptions<NoInfer<TDatum>>>(source: Iterable<TDatum>, options: TOptions): ChartMark<never, never, never, DensityXOutput<TDatum, TOptions>, DensityYOutput<TDatum, TOptions>>;
export {};