UNPKG

3.04 kBTypeScriptView Raw
1/**
2 * @fileOverview TreemapChart
3 */
4import React, { PureComponent } from 'react';
5import { AnimationDuration, AnimationTiming, DataKey, TreemapNode } from '../util/types';
6export interface Props {
7 width?: number;
8 height?: number;
9 data?: any[];
10 animationId?: number;
11 style?: any;
12 aspectRatio?: number;
13 content?: React.ReactElement;
14 fill?: string;
15 stroke?: string;
16 className?: string;
17 nameKey?: DataKey<any>;
18 dataKey?: DataKey<any>;
19 children?: any;
20 type?: 'flat' | 'nest';
21 colorPanel?: [];
22 nestIndexContent?: React.ReactElement | ((item: any, i: number) => any);
23 onAnimationStart?: () => void;
24 onAnimationEnd?: () => void;
25 onMouseEnter?: (node: TreemapNode, e: any) => void;
26 onMouseLeave?: (node: TreemapNode, e: any) => void;
27 onClick?: (node: TreemapNode) => void;
28 isAnimationActive?: boolean;
29 isUpdateAnimationActive?: boolean;
30 animationBegin?: number;
31 animationDuration?: AnimationDuration;
32 animationEasing?: AnimationTiming;
33}
34interface State {
35 isTooltipActive: boolean;
36 isAnimationFinished: boolean;
37 activeNode?: TreemapNode;
38 formatRoot?: TreemapNode;
39 currentRoot?: TreemapNode;
40 nestIndex?: TreemapNode[];
41 prevData?: any[];
42 prevType?: 'flat' | 'nest';
43 prevWidth?: number;
44 prevHeight?: number;
45 prevDataKey?: DataKey<any>;
46 prevAspectRatio?: number;
47}
48export declare class Treemap extends PureComponent<Props, State> {
49 static displayName: string;
50 static defaultProps: {
51 aspectRatio: number;
52 dataKey: string;
53 type: string;
54 isAnimationActive: boolean;
55 isUpdateAnimationActive: boolean;
56 animationBegin: number;
57 animationDuration: number;
58 animationEasing: string;
59 };
60 state: {
61 isTooltipActive: boolean;
62 isAnimationFinished: boolean;
63 activeNode?: TreemapNode;
64 formatRoot?: TreemapNode;
65 currentRoot?: TreemapNode;
66 nestIndex?: TreemapNode[];
67 prevData?: any[];
68 prevType?: "flat" | "nest";
69 prevWidth?: number;
70 prevHeight?: number;
71 prevDataKey?: DataKey<any>;
72 prevAspectRatio?: number;
73 };
74 static getDerivedStateFromProps(nextProps: Props, prevState: State): State;
75 handleMouseEnter(node: TreemapNode, e: any): void;
76 handleMouseLeave(node: TreemapNode, e: any): void;
77 handleAnimationEnd: () => void;
78 handleAnimationStart: () => void;
79 handleClick(node: TreemapNode): void;
80 handleNestIndex(node: TreemapNode, i: number): void;
81 renderItem(content: any, nodeProps: TreemapNode, isLeaf: boolean): React.ReactElement;
82 static renderContentItem(content: any, nodeProps: TreemapNode, type: string, colorPanel: string[]): React.ReactElement;
83 renderNode(root: TreemapNode, node: TreemapNode): React.ReactElement;
84 renderAllNodes(): React.ReactElement;
85 renderTooltip(): React.ReactElement;
86 renderNestIndex(): React.ReactElement;
87 render(): React.JSX.Element;
88}
89export {};