UNPKG

4.77 kBTypeScriptView Raw
1/**
2 * @fileOverview Area
3 */
4import React, { PureComponent, ReactElement, SVGProps } from 'react';
5import { CurveType, Point as CurvePoint } from '../shape/Curve';
6import { Props as DotProps } from '../shape/Dot';
7import { Props as XAxisProps } from './XAxis';
8import { Props as YAxisProps } from './YAxis';
9import { D3Scale, LegendType, TooltipType, AnimationTiming, ChartOffset, Coordinate, DataKey, TickItem, AnimationDuration } from '../util/types';
10export type AreaDot = ReactElement<SVGElement> | ((props: any) => ReactElement<SVGElement>) | DotProps | boolean;
11interface AreaPointItem extends CurvePoint {
12 value?: number | number[];
13 payload?: any;
14}
15interface InternalAreaProps {
16 xAxis?: Omit<XAxisProps, 'scale'> & {
17 scale: D3Scale<string | number>;
18 };
19 yAxis?: Omit<YAxisProps, 'scale'> & {
20 scale: D3Scale<string | number>;
21 };
22 top?: number;
23 left?: number;
24 width?: number;
25 height?: number;
26 points?: AreaPointItem[];
27 baseLine?: number | Coordinate[];
28}
29interface AreaProps extends InternalAreaProps {
30 className?: string;
31 dataKey: DataKey<any>;
32 data?: any[];
33 type?: CurveType;
34 unit?: string | number;
35 name?: string | number;
36 xAxisId?: string | number;
37 yAxisId?: string | number;
38 stackId?: string | number;
39 legendType?: LegendType;
40 tooltipType?: TooltipType;
41 connectNulls?: boolean;
42 activeDot?: AreaDot;
43 dot?: AreaDot;
44 label?: any;
45 layout?: 'horizontal' | 'vertical';
46 hide?: boolean;
47 baseValue?: number | 'dataMin' | 'dataMax';
48 isRange?: boolean;
49 onAnimationStart?: () => void;
50 onAnimationEnd?: () => void;
51 isAnimationActive?: boolean;
52 animateNewValues?: boolean;
53 animationBegin?: number;
54 animationDuration?: AnimationDuration;
55 animationEasing?: AnimationTiming;
56 animationId?: number;
57 id?: string;
58}
59export type Props = Omit<SVGProps<SVGElement>, 'type' | 'points'> & AreaProps;
60interface State {
61 prevAnimationId?: number;
62 prevPoints?: AreaPointItem[];
63 prevBaseLine?: number | Coordinate[];
64 curPoints?: AreaPointItem[];
65 curBaseLine?: number | Coordinate[];
66 isAnimationFinished?: boolean;
67 totalLength?: number;
68}
69export declare class Area extends PureComponent<Props, State> {
70 static displayName: string;
71 static defaultProps: {
72 stroke: string;
73 fill: string;
74 fillOpacity: number;
75 xAxisId: number;
76 yAxisId: number;
77 legendType: string;
78 connectNulls: boolean;
79 points: AreaPointItem[];
80 dot: boolean;
81 activeDot: boolean;
82 hide: boolean;
83 isAnimationActive: boolean;
84 animationBegin: number;
85 animationDuration: number;
86 animationEasing: string;
87 };
88 static getBaseValue: (props: Props, item: Area, xAxis: Props['xAxis'], yAxis: Props['yAxis']) => number;
89 static getComposedData: ({ props, item, xAxis, yAxis, xAxisTicks, yAxisTicks, bandSize, dataKey, stackedData, dataStartIndex, displayedData, offset, }: {
90 props: Props;
91 item: Area;
92 bandSize: number;
93 xAxis: InternalAreaProps['xAxis'];
94 yAxis: InternalAreaProps['yAxis'];
95 xAxisTicks: TickItem[];
96 yAxisTicks: TickItem[];
97 stackedData: number[][];
98 dataStartIndex: number;
99 offset: ChartOffset;
100 displayedData: any[];
101 dataKey: Props['dataKey'];
102 }) => {
103 top?: number;
104 bottom?: number;
105 left?: number;
106 right?: number;
107 width?: number;
108 height?: number;
109 brushBottom?: number;
110 points: {
111 x: number;
112 y: number;
113 value: any[];
114 payload: any;
115 }[];
116 baseLine: number | {
117 x: number;
118 y: number;
119 }[];
120 layout: "horizontal" | "vertical";
121 isRange: boolean;
122 };
123 static renderDotItem: (option: AreaDot, props: any) => React.JSX.Element;
124 state: State;
125 static getDerivedStateFromProps(nextProps: Props, prevState: State): State;
126 id: string;
127 handleAnimationEnd: () => void;
128 handleAnimationStart: () => void;
129 renderDots(needClip: boolean, clipDot: boolean, clipPathId: string): React.JSX.Element;
130 renderHorizontalRect(alpha: number): React.JSX.Element;
131 renderVerticalRect(alpha: number): React.JSX.Element;
132 renderClipRect(alpha: number): React.JSX.Element;
133 renderAreaStatically(points: AreaPointItem[], baseLine: Props['baseLine'], needClip: boolean, clipPathId: string): React.JSX.Element;
134 renderAreaWithAnimation(needClip: boolean, clipPathId: string): React.JSX.Element;
135 renderArea(needClip: boolean, clipPathId: string): React.JSX.Element;
136 render(): React.JSX.Element;
137}
138export {};