UNPKG

2.96 kBTypeScriptView Raw
1import { ReactElement, ReactNode, Component, SVGProps } from 'react';
2import { CartesianViewBox, TickItem, PresentationAttributesAdaptChildEvent } from '../util/types';
3interface CartesianTickItem extends TickItem {
4 tickCoord?: number;
5 tickSize?: number;
6 isShow?: boolean;
7}
8export interface CartesianAxisProps {
9 className?: string;
10 x?: number;
11 y?: number;
12 width?: number;
13 height?: number;
14 unit?: string | number;
15 orientation?: 'top' | 'bottom' | 'left' | 'right';
16 viewBox?: CartesianViewBox;
17 tick?: SVGProps<SVGTextElement> | ReactElement<SVGElement> | ((props: any) => ReactElement<SVGElement>) | boolean;
18 axisLine?: boolean | SVGProps<SVGLineElement>;
19 tickLine?: boolean | SVGProps<SVGLineElement>;
20 mirror?: boolean;
21 tickMargin?: number;
22 hide?: boolean;
23 label?: any;
24 minTickGap?: number;
25 ticks?: CartesianTickItem[];
26 tickSize?: number;
27 tickFormatter?: (value: any, index: number) => string;
28 ticksGenerator?: (props?: CartesianAxisProps) => CartesianTickItem[];
29 interval?: number | 'preserveStart' | 'preserveEnd' | 'preserveStartEnd';
30}
31export declare type Props = Omit<PresentationAttributesAdaptChildEvent<any, SVGElement>, 'viewBox'> & CartesianAxisProps;
32export declare class CartesianAxis extends Component<Props> {
33 static displayName: string;
34 static defaultProps: {
35 x: number;
36 y: number;
37 width: number;
38 height: number;
39 viewBox: {
40 x: number;
41 y: number;
42 width: number;
43 height: number;
44 };
45 orientation: string;
46 ticks: CartesianTickItem[];
47 stroke: string;
48 tickLine: boolean;
49 axisLine: boolean;
50 tick: boolean;
51 mirror: boolean;
52 minTickGap: number;
53 tickSize: number;
54 tickMargin: number;
55 interval: string;
56 };
57 static getTicks(props: Props): any[];
58 static getNumberIntervalTicks(ticks: CartesianTickItem[], interval: number): CartesianTickItem[];
59 static getTicksStart({ ticks, tickFormatter, viewBox, orientation, minTickGap, unit }: Omit<Props, 'tickMargin'>, preserveEnd?: boolean): CartesianTickItem[];
60 static getTicksEnd({ ticks, tickFormatter, viewBox, orientation, minTickGap, unit }: Omit<Props, 'tickMargin'>): CartesianTickItem[];
61 shouldComponentUpdate({ viewBox, ...restProps }: Props): boolean;
62 getTickLineCoord(data: CartesianTickItem): {
63 line: {
64 x1: number;
65 y1: number;
66 x2: number;
67 y2: number;
68 };
69 tick: {
70 x: number;
71 y: number;
72 };
73 };
74 getTickTextAnchor(): string;
75 getTickVerticalAnchor(): string;
76 renderAxisLine(): JSX.Element;
77 static renderTickItem(option: Props['tick'], props: any, value: ReactNode): JSX.Element;
78 renderTicks(ticks: CartesianTickItem[]): JSX.Element;
79 render(): JSX.Element;
80}
81export {};