UNPKG

4.46 kBTypeScriptView Raw
1/**
2 * @fileOverview Render a group of scatters
3 */
4import React, { PureComponent, ReactElement } from 'react';
5import { ImplicitLabelListType } from '../component/LabelList';
6import { Props as ZAxisProps } from './ZAxis';
7import { Props as CurveProps, CurveType } from '../shape/Curve';
8import { Props as ErrorBarProps } from './ErrorBar';
9import { LegendType, AnimationTiming, D3Scale, ChartOffset, DataKey, TickItem, PresentationAttributesAdaptChildEvent, AnimationDuration, ActiveShape, SymbolType } from '../util/types';
10import { TooltipType } from '../component/DefaultTooltipContent';
11import { Props as XAxisProps } from './XAxis';
12import { Props as YAxisProps } from './YAxis';
13import { InnerSymbolsProp } from '../shape/Symbols';
14interface ScattterPointNode {
15 x?: number | string;
16 y?: number | string;
17 z?: number | string;
18}
19export interface ScatterPointItem {
20 cx?: number;
21 cy?: number;
22 size?: number;
23 node?: ScattterPointNode;
24 payload?: any;
25}
26export type ScatterCustomizedShape = ActiveShape<ScatterPointItem, SVGPathElement & InnerSymbolsProp> | SymbolType;
27interface ScatterProps {
28 data?: any[];
29 xAxisId?: string | number;
30 yAxisId?: string | number;
31 zAxisId?: string | number;
32 left?: number;
33 top?: number;
34 width?: number;
35 height?: number;
36 xAxis?: Omit<XAxisProps, 'scale'> & {
37 scale: D3Scale<string | number>;
38 };
39 yAxis?: Omit<YAxisProps, 'scale'> & {
40 scale: D3Scale<string | number>;
41 };
42 zAxis?: Omit<ZAxisProps, 'scale'> & {
43 scale: D3Scale<string | number>;
44 };
45 dataKey?: DataKey<any>;
46 line?: ReactElement<SVGElement> | ((props: any) => ReactElement<SVGElement>) | CurveProps | boolean;
47 lineType?: 'fitting' | 'joint';
48 lineJointType?: CurveType;
49 legendType?: LegendType;
50 tooltipType?: TooltipType;
51 className?: string;
52 name?: string | number;
53 activeIndex?: number;
54 activeShape?: ScatterCustomizedShape;
55 shape?: ScatterCustomizedShape;
56 points?: ScatterPointItem[];
57 hide?: boolean;
58 label?: ImplicitLabelListType<any>;
59 isAnimationActive?: boolean;
60 animationId?: number;
61 animationBegin?: number;
62 animationDuration?: AnimationDuration;
63 animationEasing?: AnimationTiming;
64}
65export type Props = PresentationAttributesAdaptChildEvent<any, SVGElement> & ScatterProps;
66interface State {
67 isAnimationFinished?: boolean;
68 prevPoints?: ScatterPointItem[];
69 curPoints?: ScatterPointItem[];
70 prevAnimationId?: number;
71}
72export declare class Scatter extends PureComponent<Props, State> {
73 static displayName: string;
74 static defaultProps: {
75 xAxisId: number;
76 yAxisId: number;
77 zAxisId: number;
78 legendType: string;
79 lineType: string;
80 lineJointType: string;
81 data: any[];
82 shape: string;
83 hide: boolean;
84 isAnimationActive: boolean;
85 animationBegin: number;
86 animationDuration: number;
87 animationEasing: string;
88 };
89 /**
90 * Compose the data of each group
91 * @param {Object} xAxis The configuration of x-axis
92 * @param {Object} yAxis The configuration of y-axis
93 * @param {String} dataKey The unique key of a group
94 * @return {Array} Composed data
95 */
96 static getComposedData: ({ xAxis, yAxis, zAxis, item, displayedData, xAxisTicks, yAxisTicks, offset, }: {
97 props: Props;
98 xAxis: Props['xAxis'];
99 yAxis: Props['yAxis'];
100 zAxis: Props['zAxis'];
101 xAxisTicks: TickItem[];
102 yAxisTicks: TickItem[];
103 item: Scatter;
104 bandSize: number;
105 displayedData: any[];
106 offset: ChartOffset;
107 }) => {
108 top?: number;
109 bottom?: number;
110 left?: number;
111 right?: number;
112 width?: number;
113 height?: number;
114 brushBottom?: number;
115 points: any[];
116 };
117 state: State;
118 static getDerivedStateFromProps(nextProps: Props, prevState: State): State;
119 handleAnimationEnd: () => void;
120 handleAnimationStart: () => void;
121 id: string;
122 renderSymbolsStatically(points: ScatterPointItem[]): React.JSX.Element[];
123 renderSymbolsWithAnimation(): React.JSX.Element;
124 renderSymbols(): React.JSX.Element | React.JSX.Element[];
125 renderErrorBar(): React.ReactElement<ErrorBarProps, string | React.JSXElementConstructor<any>>[];
126 renderLine(): React.JSX.Element;
127 render(): React.JSX.Element;
128}
129export {};