UNPKG

@adyen/lume

Version:

Lume is a Vue data visualization component library, built with Typescript and D3.

54 lines 2.08 kB
import { PropType, Ref } from 'vue'; import { ScaleBand, ScaleLinear } from 'd3'; import type { ContainerSize } from '@/types/size'; import type { InternalData } from '@/types/dataset'; import type { ChartOptions } from '@/types/options'; import type { Orientation } from '@/types/utils'; export interface ComputedScaleBand extends ScaleBand<string | number> { labels: Array<string | number>; } export type Scale = ScaleBand<string | number> | ScaleLinear<number, number>; export type ScaleGenerator<T extends Scale = Scale> = (data: InternalData, labels: Array<string>, size: ContainerSize) => T; export declare const withScales: () => { xScale: { type: PropType<ScaleGenerator | Scale>; default: any; }; yScale: { type: PropType<ScaleGenerator | Scale>; default: any; }; }; /** * Generates a reactive pair of scales with base settings. * * @param data The chart data. * @param labels The chart labels. * @param size The chart container size. * @returns A x-axis scale (band) and a y-axis scale (linear). */ export declare function useBaseScales(data: Ref<InternalData>, labels: Ref<Array<string | number>>, size: ContainerSize, orientation?: Ref<Orientation>, options?: Ref<ChartOptions>): { xScale: Ref<Scale>; yScale: Ref<Scale>; }; /** * Checks if a provided argument is an instance of Scale. * * @param arg The variable to test. * @returns `true` if it is a Scale, `false` otherwise. */ export declare function isScale(arg: unknown): arg is Scale; /** * Returns the `x` position of the provided index in the scale. * * @param scale A linear or band scale. * @param index The index to get the x position of. * @returns The x position */ export declare function getXByIndex(scale: Scale, index: number): number; export declare function getPaddedScale(scale: ScaleBand<string | number>, orientation?: Orientation, { padding, paddingInner, paddingOuter, }?: { padding?: number; paddingInner?: number; paddingOuter?: number; }): ScaleBand<string | number>; //# sourceMappingURL=scales.d.ts.map