UNPKG

3.38 kBTypeScriptView Raw
1import React, { PureComponent, ReactElement, MouseEvent, SVGProps } from 'react';
2import { Props as DotProps } from '../shape/Dot';
3import { LegendType, TooltipType, AnimationTiming, DataKey, AnimationDuration } from '../util/types';
4import { Props as PolarAngleAxisProps } from './PolarAngleAxis';
5import { Props as PolarRadiusAxisProps } from './PolarRadiusAxis';
6interface RadarPoint {
7 x: number;
8 y: number;
9 cx?: number;
10 cy?: number;
11 angle?: number;
12 radius?: number;
13 value?: number;
14 payload?: any;
15 name?: string;
16}
17type RadarDot = ReactElement<SVGElement> | ((props: any) => ReactElement<SVGElement>) | DotProps | boolean;
18interface RadarProps {
19 className?: string;
20 dataKey: DataKey<any>;
21 angleAxisId?: string | number;
22 radiusAxisId?: string | number;
23 points?: RadarPoint[];
24 baseLinePoints?: RadarPoint[];
25 isRange?: boolean;
26 shape?: ReactElement<SVGElement> | ((props: any) => ReactElement<SVGElement>);
27 activeDot?: RadarDot;
28 dot?: RadarDot;
29 legendType?: LegendType;
30 tooltipType?: TooltipType;
31 hide?: boolean;
32 connectNulls?: boolean;
33 label?: any;
34 onAnimationStart?: () => void;
35 onAnimationEnd?: () => void;
36 animationBegin?: number;
37 animationDuration?: AnimationDuration;
38 isAnimationActive?: boolean;
39 animationId?: number;
40 animationEasing?: AnimationTiming;
41 onMouseEnter?: (props: any, e: MouseEvent<SVGPolygonElement>) => void;
42 onMouseLeave?: (props: any, e: MouseEvent<SVGPolygonElement>) => void;
43}
44type RadiusAxis = PolarRadiusAxisProps & {
45 scale: (value: any) => number;
46};
47type AngleAxis = PolarAngleAxisProps & {
48 scale: (value: any) => number;
49};
50export type Props = Omit<SVGProps<SVGElement>, 'onMouseEnter' | 'onMouseLeave' | 'points'> & RadarProps;
51interface State {
52 isAnimationFinished?: boolean;
53 prevPoints?: RadarPoint[];
54 curPoints?: RadarPoint[];
55 prevAnimationId?: number;
56}
57export declare class Radar extends PureComponent<Props, State> {
58 static displayName: string;
59 static defaultProps: {
60 angleAxisId: number;
61 radiusAxisId: number;
62 hide: boolean;
63 activeDot: boolean;
64 dot: boolean;
65 legendType: string;
66 isAnimationActive: boolean;
67 animationBegin: number;
68 animationDuration: number;
69 animationEasing: string;
70 };
71 static getComposedData: ({ radiusAxis, angleAxis, displayedData, dataKey, bandSize, }: {
72 radiusAxis: RadiusAxis;
73 angleAxis: AngleAxis;
74 displayedData: any[];
75 dataKey: RadarProps['dataKey'];
76 bandSize: number;
77 }) => {
78 points: RadarPoint[];
79 isRange: boolean;
80 baseLinePoints: RadarPoint[];
81 };
82 state: State;
83 static getDerivedStateFromProps(nextProps: Props, prevState: State): State;
84 handleAnimationEnd: () => void;
85 handleAnimationStart: () => void;
86 handleMouseEnter: (e: MouseEvent<SVGPolygonElement>) => void;
87 handleMouseLeave: (e: MouseEvent<SVGPolygonElement>) => void;
88 static renderDotItem(option: RadarDot, props: any): React.JSX.Element;
89 renderDots(points: RadarPoint[]): React.JSX.Element;
90 renderPolygonStatically(points: RadarPoint[]): React.JSX.Element;
91 renderPolygonWithAnimation(): React.JSX.Element;
92 renderPolygon(): React.JSX.Element;
93 render(): React.JSX.Element;
94}
95export {};