react-plot
Version:
Library of React components to render SVG 2D plots.
51 lines • 2.31 kB
TypeScript
import type { CSSProperties } from 'react';
import type { Scales } from './components/Axis/types.js';
import type { PlotAxisContext } from './contexts/plotContext.js';
import type { CSSFuncProps, LabelFuncProps, SeriesPoint, SeriesPointError, Shape, ShapeFuncProps } from './types.js';
/**
* Creates autoincremental values, generally for series.
*/
export declare function getNextId(): number;
export declare function useId(id: string | undefined, prefix: string): string;
/**
* Validates that two positions are not orthogonal between them
*/
export declare function validatePosition(currPosition: string, position: string, id: string): void;
interface ValidateAxisOptions {
onlyOrthogonal?: boolean;
}
/**
* Validates that two axes are orthogonal between them
*/
export declare function validateAxis(axisContext: Record<string, PlotAxisContext>, xKey: string, yKey: string, options?: ValidateAxisOptions): [Scales, Scales] | [undefined, undefined];
/**
* Checks the style added to a component and if is a function, gets the resulting value
*/
export declare function functionalStyle<T>(defaultStyle: CSSProperties, elementStyle: CSSFuncProps<T>, point: T, index?: number, data?: readonly T[]): CSSProperties;
/**
* Checks the marker added to a component and if is a function, gets the resulting value
*/
export declare function functionalShape<T>(elementStyle: ShapeFuncProps<T>, point: T, index?: number, data?: readonly T[]): Shape;
/**
* Checks the label added to a component and if is a function, gets the resulting value
*/
export declare function functionalLabel<T>(elementStyle: LabelFuncProps<T>, point: T, index?: number, data?: readonly T[]): string;
/**
* validate series point Error
*/
export declare function validateSeriesPointError(error?: SeriesPointError): Exclude<SeriesPointError, number> | null;
export declare function closestPoint<T, R>(data: readonly T[], value: R, distanceFun: (a: T, b: R) => number): T;
export declare function dataConvertDate(data: Array<{
x: number | Date;
y: number | Date;
}>): {
x: number;
y: number;
}[];
export declare function toNumber(value: number | Date): number;
export declare function middlePoint(point1: SeriesPoint, point2: SeriesPoint): {
x: number;
y: number;
};
export {};
//# sourceMappingURL=utils.d.ts.map