UNPKG

3.77 kBTypeScriptView Raw
1/**
2 * @fileOverview Render sectors of a funnel
3 */
4import React, { PureComponent } from 'react';
5import { Props as TrapezoidProps } from '../shape/Trapezoid';
6import { LegendType, TooltipType, AnimationTiming, ChartOffset, DataKey, PresentationAttributesAdaptChildEvent, AnimationDuration, ActiveShape } from '../util/types';
7export interface FunnelTrapezoidItem extends TrapezoidProps {
8 value?: number | string;
9 payload?: any;
10 isActive: boolean;
11}
12interface InternalFunnelProps {
13 className?: string;
14 dataKey: DataKey<any>;
15 nameKey?: DataKey<any>;
16 data?: any[];
17 hide?: boolean;
18 shape?: ActiveShape<FunnelTrapezoidItem, SVGPathElement>;
19 activeShape?: ActiveShape<FunnelTrapezoidItem, SVGPathElement>;
20 legendType?: LegendType;
21 tooltipType?: TooltipType;
22 activeIndex?: number | number[];
23 lastShapeType?: 'triangle' | 'rectangle';
24 reversed?: boolean;
25 onAnimationStart?: () => void;
26 onAnimationEnd?: () => void;
27 isAnimationActive?: boolean;
28 animateNewValues?: boolean;
29 animationBegin?: number;
30 animationDuration?: AnimationDuration;
31 animationEasing?: AnimationTiming;
32 id?: string;
33 trapezoids?: FunnelTrapezoidItem[];
34 animationId?: number;
35}
36export type FunnelProps = PresentationAttributesAdaptChildEvent<any, SVGElement> & TrapezoidProps & InternalFunnelProps;
37interface State {
38 readonly prevTrapezoids?: FunnelTrapezoidItem[];
39 readonly curTrapezoids?: FunnelTrapezoidItem[];
40 readonly prevAnimationId?: number;
41 readonly isAnimationFinished?: boolean;
42}
43export declare class Funnel extends PureComponent<FunnelProps, State> {
44 static displayName: string;
45 static defaultProps: {
46 stroke: string;
47 fill: string;
48 legendType: string;
49 labelLine: boolean;
50 hide: boolean;
51 isAnimationActive: boolean;
52 animationBegin: number;
53 animationDuration: number;
54 animationEasing: string;
55 nameKey: string;
56 lastShapeType: string;
57 };
58 static getRealFunnelData: (item: Funnel) => any[];
59 static getRealWidthHeight: (item: Funnel, offset: ChartOffset) => {
60 realWidth: number;
61 realHeight: number;
62 offsetX: number;
63 offsetY: number;
64 };
65 static getComposedData: ({ item, offset }: {
66 item: Funnel;
67 offset: ChartOffset;
68 }) => {
69 trapezoids: {
70 payload: any;
71 parentViewBox: {
72 x: number;
73 y: number;
74 width: number;
75 height: number;
76 };
77 labelViewBox: {
78 x: number;
79 y: number;
80 width: number;
81 height: number;
82 };
83 x: number;
84 y: number;
85 width: number;
86 upperWidth: number;
87 lowerWidth: number;
88 height: number;
89 name: any;
90 val: any;
91 tooltipPayload: {
92 name: any;
93 value: any;
94 payload: any;
95 dataKey: DataKey<any>;
96 type: "none";
97 }[];
98 tooltipPosition: {
99 x: number;
100 y: number;
101 };
102 }[];
103 data: any[];
104 };
105 state: State;
106 static getDerivedStateFromProps(nextProps: FunnelProps, prevState: State): State;
107 handleAnimationEnd: () => void;
108 handleAnimationStart: () => void;
109 isActiveIndex(i: number): boolean;
110 renderTrapezoidsStatically(trapezoids: FunnelTrapezoidItem[]): React.JSX.Element[];
111 renderTrapezoidsWithAnimation(): React.JSX.Element;
112 renderTrapezoids(): React.JSX.Element | React.JSX.Element[];
113 render(): React.JSX.Element;
114}
115export {};