victory-native
Version:
A charting library for React Native with a focus on performance and customization.
25 lines (24 loc) • 2.13 kB
TypeScript
import type { AxisProps, FrameInputProps, FramePropsWithDefaults, InputFields, NumericalFields, XAxisInputProps, XAxisPropsWithDefaults, YAxisInputProps, YAxisPropsWithDefaults } from "../../types";
/**
* This hook builds the chart axes + the surrounding frame based on either the new x, y, frame props, or via backwards compatibility for the older axisOptions props and the associated default values it had. The defaults for the former are the new XAxisDefaults, YAxisDefaults, and FrameDefaults, while the defaults for the latter come from the older CartesianAxisDefaultProps.
*
* The hook returns a normalized object of `xAxis, yAxes, and frame` objects that are used to determine the axes to render and in the transformInputData function.
*/
export declare const useBuildChartAxis: <RawData extends Record<string, unknown>, XK extends keyof InputFields<RawData>, YK extends keyof NumericalFields<RawData>, XLabel = InputFields<RawData>[XK], YLabel = RawData[YK]>(args: BuildChartAxisArgs<RawData, XK, YK, XLabel, YLabel>) => {
xAxis: XAxisPropsWithDefaults<RawData, XK, XLabel>;
yAxes: YAxisPropsWithDefaults<RawData, YK, YLabel>[];
frame: FramePropsWithDefaults;
};
type BuildChartAxisArgs<RawData extends Record<string, unknown>, XK extends keyof InputFields<RawData>, YK extends keyof NumericalFields<RawData>, XLabel = InputFields<RawData>[XK], YLabel = RawData[YK]> = {
axisOptions?: Partial<Omit<AxisProps<RawData, XK, YK, XLabel, YLabel>, "xScale" | "yScale">>;
xAxis?: XAxisInputProps<RawData, XK, XLabel>;
yAxis?: YAxisInputProps<RawData, YK, YLabel>[];
frame?: FrameInputProps;
yKeys: YK[];
};
export declare const buildChartAxis: <RawData extends Record<string, unknown>, XK extends keyof InputFields<RawData>, YK extends keyof NumericalFields<RawData>, XLabel = InputFields<RawData>[XK], YLabel = RawData[YK]>({ axisOptions, xAxis, yAxis, frame, yKeys, }: BuildChartAxisArgs<RawData, XK, YK, XLabel, YLabel>) => {
xAxis: XAxisPropsWithDefaults<RawData, XK, XLabel>;
yAxes: YAxisPropsWithDefaults<RawData, YK, YLabel>[];
frame: FramePropsWithDefaults;
};
export {};