1 | import React, { PureComponent, ReactElement, ReactNode, SVGProps } from 'react';
|
2 | import { Props as SectorProps } from '../shape/Sector';
|
3 | import { LegendType, TooltipType, AnimationTiming, Coordinate, ChartOffset, DataKey, PresentationAttributesAdaptChildEvent, AnimationDuration, ActiveShape } from '../util/types';
|
4 | interface PieDef {
|
5 | cx?: number | string;
|
6 | cy?: number | string;
|
7 | startAngle?: number;
|
8 | endAngle?: number;
|
9 | paddingAngle?: number;
|
10 | innerRadius?: number | string;
|
11 | outerRadius?: number | string;
|
12 | cornerRadius?: number | string;
|
13 | }
|
14 | type PieLabelLine = ReactElement<SVGElement> | ((props: any) => ReactElement<SVGElement>) | SVGProps<SVGPathElement> | boolean;
|
15 | export type PieLabel<P = any> = ReactElement<SVGElement> | ((props: P) => ReactNode | ReactElement<SVGElement>) | (SVGProps<SVGTextElement> & {
|
16 | offsetRadius?: number;
|
17 | }) | boolean;
|
18 | export type PieSectorDataItem = SectorProps & {
|
19 | percent?: number;
|
20 | name?: string | number;
|
21 | midAngle?: number;
|
22 | middleRadius?: number;
|
23 | tooltipPosition?: Coordinate;
|
24 | value?: number;
|
25 | paddingAngle?: number;
|
26 | dataKey?: string;
|
27 | payload?: any[];
|
28 | };
|
29 | interface PieProps extends PieDef {
|
30 | className?: string;
|
31 | animationId?: number;
|
32 | dataKey: DataKey<any>;
|
33 | nameKey?: DataKey<any>;
|
34 | valueKey?: DataKey<any>;
|
35 | blendStroke?: boolean;
|
36 | minAngle?: number;
|
37 | legendType?: LegendType;
|
38 | tooltipType?: TooltipType;
|
39 | maxRadius?: number;
|
40 | hide?: boolean;
|
41 | data?: any[];
|
42 | sectors?: PieSectorDataItem[];
|
43 | activeShape?: ActiveShape<PieSectorDataItem>;
|
44 | inactiveShape?: ActiveShape<PieSectorDataItem>;
|
45 | labelLine?: PieLabelLine;
|
46 | label?: PieLabel;
|
47 | activeIndex?: number | number[];
|
48 | animationEasing?: AnimationTiming;
|
49 | isAnimationActive?: boolean;
|
50 | animationBegin?: number;
|
51 | animationDuration?: AnimationDuration;
|
52 | onAnimationEnd?: () => void;
|
53 | onAnimationStart?: () => void;
|
54 | id?: string;
|
55 | onMouseEnter?: (data: any, index: number, e: React.MouseEvent) => void;
|
56 | onMouseLeave?: (data: any, index: number, e: React.MouseEvent) => void;
|
57 | onClick?: (data: any, index: number, e: React.MouseEvent) => void;
|
58 | rootTabIndex?: number;
|
59 | }
|
60 | export interface PieLabelRenderProps extends PieDef {
|
61 | name: string;
|
62 | percent?: number;
|
63 | stroke: string;
|
64 | index?: number;
|
65 | textAnchor: string;
|
66 | x: number;
|
67 | y: number;
|
68 | [key: string]: any;
|
69 | }
|
70 | interface State {
|
71 | isAnimationFinished?: boolean;
|
72 | prevIsAnimationActive?: boolean;
|
73 | prevSectors?: PieSectorDataItem[];
|
74 | curSectors?: PieSectorDataItem[];
|
75 | prevAnimationId?: number;
|
76 | sectorToFocus?: number;
|
77 | }
|
78 | export type Props = PresentationAttributesAdaptChildEvent<any, SVGElement> & PieProps;
|
79 | export declare class Pie extends PureComponent<Props, State> {
|
80 | pieRef: HTMLElement;
|
81 | sectorRefs: HTMLElement[];
|
82 | static displayName: string;
|
83 | static defaultProps: {
|
84 | stroke: string;
|
85 | fill: string;
|
86 | legendType: string;
|
87 | cx: string;
|
88 | cy: string;
|
89 | startAngle: number;
|
90 | endAngle: number;
|
91 | innerRadius: number;
|
92 | outerRadius: string;
|
93 | paddingAngle: number;
|
94 | labelLine: boolean;
|
95 | hide: boolean;
|
96 | minAngle: number;
|
97 | isAnimationActive: boolean;
|
98 | animationBegin: number;
|
99 | animationDuration: number;
|
100 | animationEasing: string;
|
101 | nameKey: string;
|
102 | blendStroke: boolean;
|
103 | rootTabIndex: number;
|
104 | };
|
105 | static parseDeltaAngle: (startAngle: number, endAngle: number) => number;
|
106 | static getRealPieData: (item: Pie) => any[];
|
107 | static parseCoordinateOfPie: (item: Pie, offset: ChartOffset) => {
|
108 | cx: number;
|
109 | cy: number;
|
110 | innerRadius: number;
|
111 | outerRadius: number;
|
112 | maxRadius: number;
|
113 | };
|
114 | static getComposedData: ({ item, offset }: {
|
115 | item: Pie;
|
116 | offset: ChartOffset;
|
117 | }) => Omit<Props, 'dataKey'>;
|
118 | constructor(props: Props);
|
119 | state: State;
|
120 | static getDerivedStateFromProps(nextProps: Props, prevState: State): State;
|
121 | static getTextAnchor(x: number, cx: number): "middle" | "start" | "end";
|
122 | id: string;
|
123 | isActiveIndex(i: number): boolean;
|
124 | hasActiveIndex(): number | boolean;
|
125 | handleAnimationEnd: () => void;
|
126 | handleAnimationStart: () => void;
|
127 | static renderLabelLineItem(option: PieLabelLine, props: any): React.JSX.Element;
|
128 | static renderLabelItem(option: PieLabel, props: any, value: any): React.JSX.Element;
|
129 | renderLabels(sectors: PieSectorDataItem[]): React.JSX.Element;
|
130 | renderSectorsStatically(sectors: PieSectorDataItem[]): React.JSX.Element[];
|
131 | renderSectorsWithAnimation(): React.JSX.Element;
|
132 | attachKeyboardHandlers(pieRef: HTMLElement): void;
|
133 | renderSectors(): React.JSX.Element | React.JSX.Element[];
|
134 | componentDidMount(): void;
|
135 | render(): React.JSX.Element;
|
136 | }
|
137 | export {};
|