@octanejs/recharts 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/animation/CSSTransitionAnimate.tsrx +142 -0
- package/src/cartesian/Area.tsrx +1096 -0
- package/src/cartesian/Area.tsrx.d.ts +340 -0
- package/src/cartesian/AreaRevealShape.tsrx +202 -0
- package/src/cartesian/CartesianGrid.tsrx +643 -0
- package/src/cartesian/CartesianGrid.tsrx.d.ts +219 -0
- package/src/cartesian/ErrorBar.tsrx +322 -0
- package/src/cartesian/ErrorBar.tsrx.d.ts +131 -0
- package/src/cartesian/Funnel.tsrx +833 -0
- package/src/cartesian/Funnel.tsrx.d.ts +274 -0
- package/src/cartesian/ReferenceLine.tsrx +452 -0
- package/src/cartesian/ReferenceLine.tsrx.d.ts +178 -0
- package/src/cartesian/Scatter.tsrx +1076 -0
- package/src/cartesian/Scatter.tsrx.d.ts +351 -0
- package/src/cartesian/ZAxis.tsrx +148 -0
- package/src/cartesian/ZAxis.tsrx.d.ts +102 -0
- package/src/chart/AreaChart.tsrx +22 -0
- package/src/chart/AreaChart.tsrx.d.ts +12 -0
- package/src/chart/ComposedChart.tsrx +22 -0
- package/src/chart/ComposedChart.tsrx.d.ts +12 -0
- package/src/chart/FunnelChart.tsrx +22 -0
- package/src/chart/FunnelChart.tsrx.d.ts +12 -0
- package/src/chart/PieChart.tsrx +31 -0
- package/src/chart/PieChart.tsrx.d.ts +31 -0
- package/src/chart/PolarChart.tsrx +121 -0
- package/src/chart/RadarChart.tsrx +53 -0
- package/src/chart/RadarChart.tsrx.d.ts +31 -0
- package/src/chart/RadialBarChart.tsrx +31 -0
- package/src/chart/RadialBarChart.tsrx.d.ts +31 -0
- package/src/chart/Sankey.tsrx +1542 -0
- package/src/chart/Sankey.tsrx.d.ts +253 -0
- package/src/chart/ScatterChart.tsrx +22 -0
- package/src/chart/ScatterChart.tsrx.d.ts +12 -0
- package/src/chart/SunburstChart.tsrx +495 -0
- package/src/chart/SunburstChart.tsrx.d.ts +146 -0
- package/src/chart/types.ts +19 -0
- package/src/component/Cursor.tsrx +157 -0
- package/src/component/DefaultLegendContent.tsrx +288 -0
- package/src/component/DefaultLegendContent.tsrx.d.ts +125 -0
- package/src/component/DefaultTooltipContent.tsrx +215 -0
- package/src/component/DefaultTooltipContent.tsrx.d.ts +87 -0
- package/src/component/Legend.tsrx +302 -0
- package/src/component/Legend.tsrx.d.ts +88 -0
- package/src/component/ResponsiveContainer.ts +1 -22
- package/src/component/ResponsiveContainer.tsrx +171 -0
- package/src/component/ResponsiveContainer.tsrx.d.ts +81 -0
- package/src/component/Tooltip.tsrx +425 -0
- package/src/component/Tooltip.tsrx.d.ts +246 -0
- package/src/component/TooltipBoundingBox.tsrx +135 -0
- package/src/context/CellsContext.ts +12 -0
- package/src/context/legendPayloadContext.tsrx +11 -0
- package/src/context/useTooltipAxis.ts +20 -0
- package/src/index.d.ts +236 -0
- package/src/index.ts +67 -0
- package/src/polar/Pie.tsrx +1224 -0
- package/src/polar/Pie.tsrx.d.ts +436 -0
- package/src/polar/PolarAngleAxis.tsrx +554 -0
- package/src/polar/PolarAngleAxis.tsrx.d.ts +215 -0
- package/src/polar/PolarGrid.tsrx +317 -0
- package/src/polar/PolarGrid.tsrx.d.ts +117 -0
- package/src/polar/PolarRadiusAxis.tsrx +463 -0
- package/src/polar/PolarRadiusAxis.tsrx.d.ts +209 -0
- package/src/polar/Radar.tsrx +696 -0
- package/src/polar/Radar.tsrx.d.ts +215 -0
- package/src/polar/RadialBar.tsrx +887 -0
- package/src/polar/RadialBar.tsrx.d.ts +340 -0
- package/src/state/ReportPolarOptions.tsrx +11 -0
- package/src/state/selectors/areaSelectors.ts +257 -0
- package/src/state/selectors/funnelSelectors.ts +86 -0
- package/src/state/selectors/pieSelectors.ts +134 -0
- package/src/state/selectors/polarGridSelectors.ts +43 -0
- package/src/state/selectors/polarScaleSelectors.ts +159 -0
- package/src/state/selectors/polarSelectors.ts +198 -0
- package/src/state/selectors/radarSelectors.ts +228 -0
- package/src/state/selectors/radialBarSelectors.ts +511 -0
- package/src/state/selectors/scatterSelectors.ts +168 -0
- package/src/util/FunnelUtils.tsrx +19 -0
- package/src/util/RadialBarUtils.tsrx +29 -0
- package/src/util/ScatterUtils.tsrx +34 -0
- package/src/util/cursor/getCursorPoints.ts +45 -0
- package/src/util/cursor/getCursorRectangle.ts +28 -0
- package/src/util/cursor/getRadialCursorPoints.ts +31 -0
- package/src/util/payload/getUniqPayload.ts +28 -0
- package/src/util/scale/CartesianScaleHelper.ts +71 -0
- package/src/util/tooltip/translate.ts +168 -0
- package/src/util/types.ts +3 -0
- package/src/util/useElementOffset.ts +147 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import * as React from 'octane';
|
|
2
|
+
import { ReactElement } from 'octane';
|
|
3
|
+
import { Props as TrapezoidProps } from '../shape/Trapezoid';
|
|
4
|
+
import { ImplicitLabelListType } from '../component/LabelList';
|
|
5
|
+
import {
|
|
6
|
+
ActiveShape,
|
|
7
|
+
AnimationDuration,
|
|
8
|
+
EasingInput,
|
|
9
|
+
CartesianViewBoxRequired,
|
|
10
|
+
ChartOffsetInternal,
|
|
11
|
+
Coordinate,
|
|
12
|
+
DataConsumer,
|
|
13
|
+
DataKey,
|
|
14
|
+
DataProvider,
|
|
15
|
+
LegendType,
|
|
16
|
+
PresentationAttributesAdaptChildEvent,
|
|
17
|
+
ShapeAnimationProps,
|
|
18
|
+
TooltipType,
|
|
19
|
+
TrapezoidViewBox,
|
|
20
|
+
CartesianLayout,
|
|
21
|
+
} from '../util/types';
|
|
22
|
+
import { TooltipPayload } from '../state/tooltipSlice';
|
|
23
|
+
import { Formatter } from '../component/DefaultTooltipContent';
|
|
24
|
+
import { AnimationInterpolateFn } from '../animation/AnimatedItems';
|
|
25
|
+
import { AnimationMatchByProp } from '../animation/matchBy';
|
|
26
|
+
import { GraphicalItemId } from '../state/graphicalItemsSlice';
|
|
27
|
+
export type FunnelTrapezoidItem = TrapezoidProps &
|
|
28
|
+
TrapezoidViewBox & {
|
|
29
|
+
value?: number | string;
|
|
30
|
+
payload?: any;
|
|
31
|
+
tooltipPosition: Coordinate;
|
|
32
|
+
name: string;
|
|
33
|
+
labelViewBox: TrapezoidViewBox;
|
|
34
|
+
parentViewBox: CartesianViewBoxRequired;
|
|
35
|
+
val: number | ReadonlyArray<number>;
|
|
36
|
+
tooltipPayload: TooltipPayload;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* External props, intended for end users to fill in
|
|
40
|
+
*/
|
|
41
|
+
interface FunnelProps<DataPointType = any, DataValueType = any>
|
|
42
|
+
extends DataProvider<DataPointType>, Required<DataConsumer<DataPointType, DataValueType>> {
|
|
43
|
+
/**
|
|
44
|
+
* This component is rendered when this graphical item is activated
|
|
45
|
+
* (could be by mouse hover, touch, keyboard, programmatically).
|
|
46
|
+
*/
|
|
47
|
+
activeShape?: ActiveShape<FunnelTrapezoidItem, SVGPathElement>;
|
|
48
|
+
/**
|
|
49
|
+
* Specifies when the animation should begin, the unit of this option is ms.
|
|
50
|
+
* @defaultValue 400
|
|
51
|
+
*/
|
|
52
|
+
animationBegin?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Specifies the duration of animation, the unit of this option is ms.
|
|
55
|
+
* @defaultValue 1500
|
|
56
|
+
*/
|
|
57
|
+
animationDuration?: AnimationDuration;
|
|
58
|
+
/**
|
|
59
|
+
* The type of easing function.
|
|
60
|
+
* @defaultValue ease
|
|
61
|
+
*/
|
|
62
|
+
animationEasing?: EasingInput;
|
|
63
|
+
/**
|
|
64
|
+
* Custom animation function for interpolating data items.
|
|
65
|
+
* When provided, this replaces the default animation interpolation.
|
|
66
|
+
*
|
|
67
|
+
* @param prevItems The items from the previous animation frame, or null on first render
|
|
68
|
+
* @param nextItems The target items to animate towards
|
|
69
|
+
* @param animationElapsedTime A normalized time value (0 = start, 1 = end)
|
|
70
|
+
* @returns The interpolated items at time animationElapsedTime
|
|
71
|
+
*
|
|
72
|
+
* @since 3.9
|
|
73
|
+
* @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
|
|
74
|
+
*/
|
|
75
|
+
animationInterpolateFn?: AnimationInterpolateFn<FunnelTrapezoidItem, CartesianLayout>;
|
|
76
|
+
/**
|
|
77
|
+
* Strategy for matching previous items to next items during animation.
|
|
78
|
+
* Determines how Recharts pairs old data points with new data points
|
|
79
|
+
* to create smooth transitions.
|
|
80
|
+
*
|
|
81
|
+
* - `matchAppend` (default): match sequentially by index and treat newly appended items as new
|
|
82
|
+
* - `matchByIndex`: match by array position with proportional stretching
|
|
83
|
+
* - `matchByDataKey('someKey')`: match by a data key from the payload
|
|
84
|
+
* - Custom function `(item, index) => key`: match by the returned key
|
|
85
|
+
*
|
|
86
|
+
* @defaultValue append
|
|
87
|
+
* @see matchByIndex
|
|
88
|
+
* @see matchByDataKey
|
|
89
|
+
* @see matchAppend
|
|
90
|
+
*
|
|
91
|
+
* @since 3.9
|
|
92
|
+
* @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
|
|
93
|
+
*/
|
|
94
|
+
animationMatchBy?: AnimationMatchByProp<FunnelTrapezoidItem>;
|
|
95
|
+
className?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Hides the whole graphical element when true.
|
|
98
|
+
*
|
|
99
|
+
* Hiding an element is different from removing it from the chart:
|
|
100
|
+
* Hidden graphical elements are still visible in Legend,
|
|
101
|
+
* and can be included in axis domain calculations,
|
|
102
|
+
* depending on `includeHidden` props of your XAxis/YAxis.
|
|
103
|
+
*
|
|
104
|
+
* @defaultValue false
|
|
105
|
+
*/
|
|
106
|
+
hide?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Unique identifier of this component.
|
|
109
|
+
* Used as an HTML attribute `id`, and also to identify this element internally.
|
|
110
|
+
*
|
|
111
|
+
* If undefined, Recharts will generate a unique ID automatically.
|
|
112
|
+
*/
|
|
113
|
+
id?: string;
|
|
114
|
+
/**
|
|
115
|
+
* If set false, animation of funnel will be disabled.
|
|
116
|
+
* If set "auto", the animation will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility.
|
|
117
|
+
* @defaultValue auto
|
|
118
|
+
*/
|
|
119
|
+
isAnimationActive?: boolean | 'auto';
|
|
120
|
+
label?: ImplicitLabelListType;
|
|
121
|
+
/**
|
|
122
|
+
* @defaultValue triangle
|
|
123
|
+
*/
|
|
124
|
+
lastShapeType?: 'triangle' | 'rectangle';
|
|
125
|
+
/**
|
|
126
|
+
* The type of icon in legend. If set to 'none', no legend item will be rendered.
|
|
127
|
+
* @defaultValue rect
|
|
128
|
+
*/
|
|
129
|
+
legendType?: LegendType;
|
|
130
|
+
/**
|
|
131
|
+
* Name represents each sector in the tooltip.
|
|
132
|
+
* This allows you to extract the name from the data:
|
|
133
|
+
*
|
|
134
|
+
* - `string`: the name of the field in the data object;
|
|
135
|
+
* - `number`: the index of the field in the data;
|
|
136
|
+
* - `function`: a function that receives the data object and returns the name.
|
|
137
|
+
*
|
|
138
|
+
* @defaultValue name
|
|
139
|
+
*/
|
|
140
|
+
nameKey?: DataKey<DataPointType, DataValueType>;
|
|
141
|
+
/**
|
|
142
|
+
* The customized event handler of animation end
|
|
143
|
+
*/
|
|
144
|
+
onAnimationEnd?: () => void;
|
|
145
|
+
/**
|
|
146
|
+
* The customized event handler of animation start
|
|
147
|
+
*/
|
|
148
|
+
onAnimationStart?: () => void;
|
|
149
|
+
reversed?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* If set a ReactElement, the shape of funnel can be customized.
|
|
152
|
+
* If set a function, the function will be called to render customized shape.
|
|
153
|
+
* During animations, the function shape also receives `animationElapsedTime`, `isAnimating`, and `isEntrance`.
|
|
154
|
+
* By default, renders a trapezoid.
|
|
155
|
+
*/
|
|
156
|
+
shape?: ActiveShape<FunnelTrapezoidItem & ShapeAnimationProps, SVGPathElement>;
|
|
157
|
+
tooltipType?: TooltipType;
|
|
158
|
+
/**
|
|
159
|
+
* Formats the value displayed in the tooltip for this Funnel.
|
|
160
|
+
* When set, takes precedence over the `formatter` prop on the Tooltip component.
|
|
161
|
+
*/
|
|
162
|
+
formatter?: Formatter;
|
|
163
|
+
/**
|
|
164
|
+
* The customized event handler of click on the area in this group
|
|
165
|
+
*/
|
|
166
|
+
onClick?: (data: FunnelTrapezoidItem, index: number, e: React.MouseEvent<SVGPathElement>) => void;
|
|
167
|
+
/**
|
|
168
|
+
* The customized event handler of mousedown on the area in this group
|
|
169
|
+
*/
|
|
170
|
+
onMouseDown?: (
|
|
171
|
+
data: FunnelTrapezoidItem,
|
|
172
|
+
index: number,
|
|
173
|
+
e: React.MouseEvent<SVGPathElement>,
|
|
174
|
+
) => void;
|
|
175
|
+
/**
|
|
176
|
+
* The customized event handler of mouseup on the area in this group
|
|
177
|
+
*/
|
|
178
|
+
onMouseUp?: (
|
|
179
|
+
data: FunnelTrapezoidItem,
|
|
180
|
+
index: number,
|
|
181
|
+
e: React.MouseEvent<SVGPathElement>,
|
|
182
|
+
) => void;
|
|
183
|
+
/**
|
|
184
|
+
* The customized event handler of mousemove on the area in this group
|
|
185
|
+
*/
|
|
186
|
+
onMouseMove?: (
|
|
187
|
+
data: FunnelTrapezoidItem,
|
|
188
|
+
index: number,
|
|
189
|
+
e: React.MouseEvent<SVGPathElement>,
|
|
190
|
+
) => void;
|
|
191
|
+
/**
|
|
192
|
+
* The customized event handler of mouseover on the area in this group
|
|
193
|
+
*/
|
|
194
|
+
onMouseOver?: (
|
|
195
|
+
data: FunnelTrapezoidItem,
|
|
196
|
+
index: number,
|
|
197
|
+
e: React.MouseEvent<SVGPathElement>,
|
|
198
|
+
) => void;
|
|
199
|
+
/**
|
|
200
|
+
* The customized event handler of mouseout on the area in this group
|
|
201
|
+
*/
|
|
202
|
+
onMouseOut?: (
|
|
203
|
+
data: FunnelTrapezoidItem,
|
|
204
|
+
index: number,
|
|
205
|
+
e: React.MouseEvent<SVGPathElement>,
|
|
206
|
+
) => void;
|
|
207
|
+
/**
|
|
208
|
+
* The customized event handler of mouseenter on the area in this group
|
|
209
|
+
*/
|
|
210
|
+
onMouseEnter?: (
|
|
211
|
+
data: FunnelTrapezoidItem,
|
|
212
|
+
index: number,
|
|
213
|
+
e: React.MouseEvent<SVGPathElement>,
|
|
214
|
+
) => void;
|
|
215
|
+
/**
|
|
216
|
+
* The customized event handler of mouseleave on the area in this group
|
|
217
|
+
*/
|
|
218
|
+
onMouseLeave?: (
|
|
219
|
+
data: FunnelTrapezoidItem,
|
|
220
|
+
index: number,
|
|
221
|
+
e: React.MouseEvent<SVGPathElement>,
|
|
222
|
+
) => void;
|
|
223
|
+
}
|
|
224
|
+
type FunnelSvgProps = Omit<
|
|
225
|
+
PresentationAttributesAdaptChildEvent<FunnelTrapezoidItem, SVGPathElement>,
|
|
226
|
+
'ref'
|
|
227
|
+
>;
|
|
228
|
+
export type Props<DataPointType = any, DataValueType = any> = FunnelSvgProps &
|
|
229
|
+
FunnelProps<DataPointType, DataValueType>;
|
|
230
|
+
type RealFunnelData = unknown;
|
|
231
|
+
export declare const defaultFunnelProps: {
|
|
232
|
+
readonly animationBegin: 400;
|
|
233
|
+
readonly animationDuration: 1500;
|
|
234
|
+
readonly animationEasing: 'ease';
|
|
235
|
+
readonly animationInterpolateFn: AnimationInterpolateFn<FunnelTrapezoidItem, CartesianLayout>;
|
|
236
|
+
readonly animationMatchBy: 'append';
|
|
237
|
+
readonly fill: '#808080';
|
|
238
|
+
readonly hide: false;
|
|
239
|
+
readonly isAnimationActive: 'auto';
|
|
240
|
+
readonly lastShapeType: 'triangle';
|
|
241
|
+
readonly legendType: 'rect';
|
|
242
|
+
readonly nameKey: 'name';
|
|
243
|
+
readonly reversed: false;
|
|
244
|
+
readonly shape: React.FC<TrapezoidProps>;
|
|
245
|
+
readonly stroke: '#fff';
|
|
246
|
+
};
|
|
247
|
+
export declare function computeFunnelTrapezoids({
|
|
248
|
+
dataKey,
|
|
249
|
+
nameKey,
|
|
250
|
+
displayedData,
|
|
251
|
+
tooltipType,
|
|
252
|
+
lastShapeType,
|
|
253
|
+
reversed,
|
|
254
|
+
offset,
|
|
255
|
+
customWidth,
|
|
256
|
+
graphicalItemId,
|
|
257
|
+
}: {
|
|
258
|
+
dataKey: Props['dataKey'];
|
|
259
|
+
nameKey: Props['nameKey'];
|
|
260
|
+
offset: ChartOffsetInternal;
|
|
261
|
+
displayedData: ReadonlyArray<RealFunnelData>;
|
|
262
|
+
tooltipType?: TooltipType;
|
|
263
|
+
lastShapeType?: Props['lastShapeType'];
|
|
264
|
+
reversed?: boolean;
|
|
265
|
+
customWidth: number | string | undefined;
|
|
266
|
+
graphicalItemId: GraphicalItemId;
|
|
267
|
+
}): ReadonlyArray<FunnelTrapezoidItem>;
|
|
268
|
+
export declare const Funnel: {
|
|
269
|
+
<DataPointType = any, DataValueType = any>(
|
|
270
|
+
outsideProps: Props<DataPointType, DataValueType>,
|
|
271
|
+
): ReactElement;
|
|
272
|
+
(outsideProps: Props<any, any>): ReactElement;
|
|
273
|
+
};
|
|
274
|
+
export {};
|