UNPKG

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