1 |
|
2 |
|
3 |
|
4 | import React, { ReactElement, ReactNode, Component, SVGProps } from 'react';
|
5 | import { CartesianViewBox, PresentationAttributesAdaptChildEvent, CartesianTickItem, AxisInterval } from '../util/types';
|
6 |
|
7 | export type Orientation = 'top' | 'bottom' | 'left' | 'right';
|
8 |
|
9 | export type Unit = string | number;
|
10 |
|
11 | export type TickFormatter = (value: any, index: number) => string;
|
12 | export interface CartesianAxisProps {
|
13 | className?: string;
|
14 | x?: number;
|
15 | y?: number;
|
16 | width?: number;
|
17 | height?: number;
|
18 | unit?: Unit;
|
19 | orientation?: Orientation;
|
20 | viewBox?: CartesianViewBox;
|
21 | tick?: SVGProps<SVGTextElement> | ReactElement<SVGElement> | ((props: any) => ReactElement<SVGElement>) | boolean;
|
22 | axisLine?: boolean | SVGProps<SVGLineElement>;
|
23 | tickLine?: boolean | SVGProps<SVGLineElement>;
|
24 | mirror?: boolean;
|
25 | tickMargin?: number;
|
26 | hide?: boolean;
|
27 | label?: any;
|
28 | minTickGap?: number;
|
29 | ticks?: CartesianTickItem[];
|
30 | tickSize?: number;
|
31 | tickFormatter?: TickFormatter;
|
32 | ticksGenerator?: (props?: CartesianAxisProps) => CartesianTickItem[];
|
33 | interval?: AxisInterval;
|
34 |
|
35 | angle?: number;
|
36 | }
|
37 | interface IState {
|
38 | fontSize: string;
|
39 | letterSpacing: string;
|
40 | }
|
41 | export type Props = Omit<PresentationAttributesAdaptChildEvent<any, SVGElement>, 'viewBox'> & CartesianAxisProps;
|
42 | export declare class CartesianAxis extends Component<Props, IState> {
|
43 | static displayName: string;
|
44 | static defaultProps: {
|
45 | x: number;
|
46 | y: number;
|
47 | width: number;
|
48 | height: number;
|
49 | viewBox: {
|
50 | x: number;
|
51 | y: number;
|
52 | width: number;
|
53 | height: number;
|
54 | };
|
55 | orientation: string;
|
56 | ticks: CartesianTickItem[];
|
57 | stroke: string;
|
58 | tickLine: boolean;
|
59 | axisLine: boolean;
|
60 | tick: boolean;
|
61 | mirror: boolean;
|
62 | minTickGap: number;
|
63 | tickSize: number;
|
64 | tickMargin: number;
|
65 | interval: string;
|
66 | };
|
67 | private layerReference;
|
68 | constructor(props: Props);
|
69 | shouldComponentUpdate({ viewBox, ...restProps }: Props, nextState: IState): boolean;
|
70 | componentDidMount(): void;
|
71 | /**
|
72 | * Calculate the coordinates of endpoints in ticks
|
73 | * @param {Object} data The data of a simple tick
|
74 | * @return {Object} (x1, y1): The coordinate of endpoint close to tick text
|
75 | * (x2, y2): The coordinate of endpoint close to axis
|
76 | */
|
77 | getTickLineCoord(data: CartesianTickItem): {
|
78 | line: {
|
79 | x1: number;
|
80 | y1: number;
|
81 | x2: number;
|
82 | y2: number;
|
83 | };
|
84 | tick: {
|
85 | x: number;
|
86 | y: number;
|
87 | };
|
88 | };
|
89 | getTickTextAnchor(): string;
|
90 | getTickVerticalAnchor(): string;
|
91 | renderAxisLine(): React.JSX.Element;
|
92 | static renderTickItem(option: Props['tick'], props: any, value: ReactNode): React.JSX.Element;
|
93 | |
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 | renderTicks(ticks: CartesianTickItem[], fontSize: string, letterSpacing: string): React.JSX.Element;
|
101 | render(): React.JSX.Element;
|
102 | }
|
103 | export {};
|