UNPKG

2.8 kBTypeScriptView Raw
1/**
2 * @file TreemapChart
3 */
4import React, { PureComponent, ReactElement, SVGProps } from 'react';
5import { Props as RectangleProps } from '../shape/Rectangle';
6import { Margin, DataKey, SankeyLink, SankeyNode } from '../util/types';
7interface LinkDataItem {
8 source: number;
9 target: number;
10 [key: string]: any;
11}
12interface SankeyData {
13 nodes: any[];
14 links: LinkDataItem[];
15}
16type SankeyNodeOptions = ReactElement<SVGElement> | ((props: any) => ReactElement<SVGElement>) | RectangleProps;
17type SankeyLinkOptions = ReactElement<SVGElement> | ((props: any) => ReactElement<SVGElement>) | SVGProps<SVGPathElement>;
18interface SankeyProps {
19 nameKey?: DataKey<any>;
20 dataKey?: DataKey<any>;
21 width?: number;
22 height?: number;
23 data: SankeyData;
24 nodePadding?: number;
25 nodeWidth?: number;
26 linkCurvature?: number;
27 iterations?: number;
28 node?: SankeyNodeOptions;
29 link?: SankeyLinkOptions;
30 style?: any;
31 className?: string;
32 children?: any;
33 margin?: Margin;
34 onClick?: any;
35 onMouseEnter?: any;
36 onMouseLeave?: any;
37 sort?: boolean;
38}
39type Props = SVGProps<SVGElement> & SankeyProps;
40interface State {
41 activeElement?: any;
42 activeElementType?: any;
43 isTooltipActive: boolean;
44 nodes: SankeyNode[];
45 links: SankeyLink[];
46 sort?: boolean;
47 prevData?: SankeyData;
48 prevWidth?: number;
49 prevHeight?: number;
50 prevMargin?: Margin;
51 prevIterations?: number;
52 prevNodeWidth?: number;
53 prevNodePadding?: number;
54 prevSort?: boolean;
55}
56export declare class Sankey extends PureComponent<Props, State> {
57 static displayName: string;
58 static defaultProps: {
59 nameKey: string;
60 dataKey: string;
61 nodePadding: number;
62 nodeWidth: number;
63 linkCurvature: number;
64 iterations: number;
65 margin: {
66 top: number;
67 right: number;
68 bottom: number;
69 left: number;
70 };
71 sort: boolean;
72 };
73 state: {
74 activeElement: any;
75 activeElementType: any;
76 isTooltipActive: boolean;
77 nodes: SankeyNode[];
78 links: SankeyLink[];
79 };
80 static getDerivedStateFromProps(nextProps: Props, prevState: State): State;
81 handleMouseEnter(el: React.ReactElement, type: string, e: any): void;
82 handleMouseLeave(el: React.ReactElement, type: string, e: any): void;
83 handleClick(el: React.ReactElement, type: string, e: any): void;
84 static renderLinkItem(option: any, props: any): any;
85 renderLinks(links: SankeyLink[], nodes: SankeyNode[]): React.JSX.Element;
86 static renderNodeItem(option: any, props: Props): any;
87 renderNodes(nodes: SankeyNode[]): React.JSX.Element;
88 renderTooltip(): ReactElement;
89 render(): React.JSX.Element;
90}
91export {};
92
\No newline at end of file