@octanejs/recharts 0.1.16 → 0.1.18

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.
Files changed (88) hide show
  1. package/package.json +4 -4
  2. package/src/animation/CSSTransitionAnimate.tsrx +142 -0
  3. package/src/cartesian/Area.tsrx +1096 -0
  4. package/src/cartesian/Area.tsrx.d.ts +340 -0
  5. package/src/cartesian/AreaRevealShape.tsrx +202 -0
  6. package/src/cartesian/CartesianGrid.tsrx +643 -0
  7. package/src/cartesian/CartesianGrid.tsrx.d.ts +219 -0
  8. package/src/cartesian/ErrorBar.tsrx +322 -0
  9. package/src/cartesian/ErrorBar.tsrx.d.ts +131 -0
  10. package/src/cartesian/Funnel.tsrx +833 -0
  11. package/src/cartesian/Funnel.tsrx.d.ts +274 -0
  12. package/src/cartesian/ReferenceLine.tsrx +452 -0
  13. package/src/cartesian/ReferenceLine.tsrx.d.ts +178 -0
  14. package/src/cartesian/Scatter.tsrx +1076 -0
  15. package/src/cartesian/Scatter.tsrx.d.ts +351 -0
  16. package/src/cartesian/ZAxis.tsrx +148 -0
  17. package/src/cartesian/ZAxis.tsrx.d.ts +102 -0
  18. package/src/chart/AreaChart.tsrx +22 -0
  19. package/src/chart/AreaChart.tsrx.d.ts +12 -0
  20. package/src/chart/ComposedChart.tsrx +22 -0
  21. package/src/chart/ComposedChart.tsrx.d.ts +12 -0
  22. package/src/chart/FunnelChart.tsrx +22 -0
  23. package/src/chart/FunnelChart.tsrx.d.ts +12 -0
  24. package/src/chart/PieChart.tsrx +31 -0
  25. package/src/chart/PieChart.tsrx.d.ts +31 -0
  26. package/src/chart/PolarChart.tsrx +121 -0
  27. package/src/chart/RadarChart.tsrx +53 -0
  28. package/src/chart/RadarChart.tsrx.d.ts +31 -0
  29. package/src/chart/RadialBarChart.tsrx +31 -0
  30. package/src/chart/RadialBarChart.tsrx.d.ts +31 -0
  31. package/src/chart/Sankey.tsrx +1542 -0
  32. package/src/chart/Sankey.tsrx.d.ts +253 -0
  33. package/src/chart/ScatterChart.tsrx +22 -0
  34. package/src/chart/ScatterChart.tsrx.d.ts +12 -0
  35. package/src/chart/SunburstChart.tsrx +495 -0
  36. package/src/chart/SunburstChart.tsrx.d.ts +146 -0
  37. package/src/chart/types.ts +19 -0
  38. package/src/component/Cursor.tsrx +157 -0
  39. package/src/component/DefaultLegendContent.tsrx +288 -0
  40. package/src/component/DefaultLegendContent.tsrx.d.ts +125 -0
  41. package/src/component/DefaultTooltipContent.tsrx +215 -0
  42. package/src/component/DefaultTooltipContent.tsrx.d.ts +87 -0
  43. package/src/component/Legend.tsrx +302 -0
  44. package/src/component/Legend.tsrx.d.ts +88 -0
  45. package/src/component/ResponsiveContainer.ts +1 -22
  46. package/src/component/ResponsiveContainer.tsrx +171 -0
  47. package/src/component/ResponsiveContainer.tsrx.d.ts +81 -0
  48. package/src/component/Tooltip.tsrx +425 -0
  49. package/src/component/Tooltip.tsrx.d.ts +246 -0
  50. package/src/component/TooltipBoundingBox.tsrx +135 -0
  51. package/src/context/CellsContext.ts +12 -0
  52. package/src/context/legendPayloadContext.tsrx +11 -0
  53. package/src/context/useTooltipAxis.ts +20 -0
  54. package/src/index.d.ts +236 -0
  55. package/src/index.ts +67 -0
  56. package/src/polar/Pie.tsrx +1224 -0
  57. package/src/polar/Pie.tsrx.d.ts +436 -0
  58. package/src/polar/PolarAngleAxis.tsrx +554 -0
  59. package/src/polar/PolarAngleAxis.tsrx.d.ts +215 -0
  60. package/src/polar/PolarGrid.tsrx +317 -0
  61. package/src/polar/PolarGrid.tsrx.d.ts +117 -0
  62. package/src/polar/PolarRadiusAxis.tsrx +463 -0
  63. package/src/polar/PolarRadiusAxis.tsrx.d.ts +209 -0
  64. package/src/polar/Radar.tsrx +696 -0
  65. package/src/polar/Radar.tsrx.d.ts +215 -0
  66. package/src/polar/RadialBar.tsrx +887 -0
  67. package/src/polar/RadialBar.tsrx.d.ts +340 -0
  68. package/src/state/ReportPolarOptions.tsrx +11 -0
  69. package/src/state/selectors/areaSelectors.ts +257 -0
  70. package/src/state/selectors/funnelSelectors.ts +86 -0
  71. package/src/state/selectors/pieSelectors.ts +134 -0
  72. package/src/state/selectors/polarGridSelectors.ts +43 -0
  73. package/src/state/selectors/polarScaleSelectors.ts +159 -0
  74. package/src/state/selectors/polarSelectors.ts +198 -0
  75. package/src/state/selectors/radarSelectors.ts +228 -0
  76. package/src/state/selectors/radialBarSelectors.ts +511 -0
  77. package/src/state/selectors/scatterSelectors.ts +168 -0
  78. package/src/util/FunnelUtils.tsrx +19 -0
  79. package/src/util/RadialBarUtils.tsrx +29 -0
  80. package/src/util/ScatterUtils.tsrx +34 -0
  81. package/src/util/cursor/getCursorPoints.ts +45 -0
  82. package/src/util/cursor/getCursorRectangle.ts +28 -0
  83. package/src/util/cursor/getRadialCursorPoints.ts +31 -0
  84. package/src/util/payload/getUniqPayload.ts +28 -0
  85. package/src/util/scale/CartesianScaleHelper.ts +71 -0
  86. package/src/util/tooltip/translate.ts +168 -0
  87. package/src/util/types.ts +3 -0
  88. package/src/util/useElementOffset.ts +147 -0
@@ -0,0 +1,340 @@
1
+ import { ReactElement } from 'octane';
2
+ import { CurveType, Props as CurveProps } from '../shape/Curve';
3
+ import { ImplicitLabelListType } from '../component/LabelList';
4
+ import { StackId } from '../util/ChartUtils';
5
+ import {
6
+ ActiveDotType,
7
+ ActiveShape,
8
+ AnimationDuration,
9
+ CartesianLayout,
10
+ DataConsumer,
11
+ DataProvider,
12
+ DotType,
13
+ EasingInput,
14
+ LegendType,
15
+ TickItem,
16
+ TooltipType,
17
+ } from '../util/types';
18
+ import { Formatter } from '../component/DefaultTooltipContent';
19
+ import { BaseAxisWithScale } from '../state/selectors/axisSelectors';
20
+ import { ChartData } from '../state/chartDataSlice';
21
+ import { AreaPointItem, ComputedArea } from '../state/selectors/areaSelectors';
22
+ import { AnimationInterpolateFn } from '../animation/AnimatedItems';
23
+ import { AnimationMatchByProp } from '../animation/matchBy';
24
+ import { AreaSettings } from '../state/types/AreaSettings';
25
+ import { ZIndexable } from '../zIndex/ZIndexLayer';
26
+ import { AxisId } from '../state/cartesianAxisSlice';
27
+ import { StackDataPoint } from '../util/stacks/stackTypes';
28
+ import { AreaRevealShape, AreaRevealShapeProps } from './AreaRevealShape';
29
+ /**
30
+ * @inline
31
+ */
32
+ export type BaseValue = number | 'dataMin' | 'dataMax';
33
+ /**
34
+ * External props, intended for end users to fill in
35
+ */
36
+ interface AreaProps<DataPointType = any, DataValueType = any>
37
+ extends
38
+ DataProvider<DataPointType>,
39
+ Required<DataConsumer<DataPointType, DataValueType>>,
40
+ ZIndexable {
41
+ /**
42
+ * The active dot is rendered on the closest data point when user interacts with the chart. Options:
43
+ *
44
+ * - `false`: dots do not change on user activity; both active and inactive dots follow the `dot` prop (see below)
45
+ * - `true`: renders the active dot with default settings
46
+ * - `object`: the props of the active dot. This will be merged with the internal calculated props of the active dot
47
+ * - `ReactElement`: the custom active dot element
48
+ * - `function`: a render function of the custom active dot
49
+ *
50
+ * @defaultValue true
51
+ * @example <Area dataKey="value" activeDot={false} />
52
+ * @example <Area dataKey="value" activeDot={{ stroke: 'red', strokeWidth: 2, r: 10 }} />
53
+ * @example <Area dataKey="value" activeDot={CustomizedActiveDot} />
54
+ *
55
+ * @see {@link https://recharts.github.io/en-US/examples/SimpleLineChart/ A line chart with customized active dot}
56
+ */
57
+ activeDot?: ActiveDotType;
58
+ /**
59
+ * Specifies when the animation should begin, the unit of this option is ms.
60
+ * @defaultValue 0
61
+ */
62
+ animationBegin?: number;
63
+ /**
64
+ * Specifies the duration of animation, the unit of this option is ms.
65
+ * @defaultValue 1500
66
+ */
67
+ animationDuration?: AnimationDuration;
68
+ /**
69
+ * The type of easing function.
70
+ * @defaultValue 'ease'
71
+ */
72
+ animationEasing?: EasingInput;
73
+ /**
74
+ * Custom animation function for interpolating data items.
75
+ * When provided, this replaces the default animation interpolation.
76
+ *
77
+ * @param prevItems The items from the previous animation frame, or null on first render
78
+ * @param nextItems The target items to animate towards
79
+ * @param animationElapsedTime A normalized time value (0 = start, 1 = end)
80
+ * @returns The interpolated items at time animationElapsedTime
81
+ *
82
+ * @since 3.9
83
+ * @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
84
+ */
85
+ animationInterpolateFn?: AnimationInterpolateFn<AreaPointItem, CartesianLayout>;
86
+ /**
87
+ * Strategy for matching previous items to next items during animation.
88
+ * Determines how Recharts pairs old data points with new data points
89
+ * to create smooth transitions.
90
+ *
91
+ * - `matchByIndex` (default): match by array position with proportional stretching
92
+ * - `matchAppend`: match sequentially by index and treat newly appended items as new
93
+ * - `matchByDataKey('someKey')`: match by a data key from the payload
94
+ * - Custom function `(item, index) => key`: match by the returned key
95
+ *
96
+ * @defaultValue index
97
+ * @see matchByIndex
98
+ * @see matchByDataKey
99
+ * @see matchAppend
100
+ *
101
+ * @since 3.9
102
+ * @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
103
+ */
104
+ animationMatchBy?: AnimationMatchByProp<AreaPointItem>;
105
+ /**
106
+ * Configures the starting value used to build the internal baseline for non-ranged, non-stacked areas.
107
+ *
108
+ * WARNING despite the name `dataMin`|`dataMax` this actually reads the domain instead, so it should rather be
109
+ * `domainMin`|`domainMax`. This looks like a small detail,
110
+ * but it's actually important because domains are usually extended automatically.
111
+ * For example the default numerical domain starts from 0.
112
+ *
113
+ * - `number`: uses the corresponding axis value as a flat baseline
114
+ * - `dataMin`: uses the minimum of the value-axis domain
115
+ * - `dataMax`: uses the maximum of the value-axis domain
116
+ *
117
+ * Ignored when the area is stacked or when `dataKey` already returns `[min, max]` tuples.
118
+ *
119
+ * Note that the baseValue does not interact with `animationInterpolateFn`;
120
+ * baseValue is always animated by linear interpolation.
121
+ * If you want a custom animation then have your `dataKey` return a tuple of two values instead of a single number
122
+ * which will also render a ranged Area, and that does work with your custom `animationInterpolateFn`.
123
+ */
124
+ baseValue?: BaseValue;
125
+ className?: string;
126
+ /**
127
+ * Whether to connect the area across null points.
128
+ *
129
+ * @defaultValue false
130
+ * @see {@link https://recharts.github.io/en-US/examples/AreaChartConnectNulls/ AreaChart with connectNull true and false}
131
+ */
132
+ connectNulls?: boolean;
133
+ /**
134
+ * Renders a circle element at each data point. Options:
135
+ *
136
+ * - `false`: no dots are drawn;
137
+ * - `true`: renders the dots with default settings;
138
+ * - `object`: the props of the dot. This will be merged with the internal calculated props of each dot;
139
+ * - `ReactElement`: the custom dot element;
140
+ * - `function`: a render function of the custom dot.
141
+ *
142
+ * @defaultValue false
143
+ */
144
+ dot?: DotType;
145
+ /**
146
+ * Hides the whole graphical element when true.
147
+ *
148
+ * Hiding an element is different from removing it from the chart:
149
+ * Hidden graphical elements are still visible in Legend,
150
+ * and can be included in axis domain calculations,
151
+ * depending on `includeHidden` props of your XAxis/YAxis.
152
+ *
153
+ * @defaultValue false
154
+ */
155
+ hide?: boolean;
156
+ /**
157
+ * Unique identifier of this component.
158
+ * Used as an HTML attribute `id`, and also to identify this element internally.
159
+ *
160
+ * If undefined, Recharts will generate a unique ID automatically.
161
+ */
162
+ id?: string;
163
+ /**
164
+ * If set false, animation of area will be disabled.
165
+ * If set "auto", will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility.
166
+ * @defaultValue 'auto'
167
+ */
168
+ isAnimationActive?: boolean | 'auto';
169
+ /**
170
+ * Renders one label for each data point. Options:
171
+ *
172
+ * - `true`: renders default labels
173
+ * - `false`: no labels are rendered
174
+ * - `object`: the props of LabelList component
175
+ * - `ReactElement`: a custom SVG label element, such as `<text>` or `<g>`.
176
+ * HTML elements such as `<div>` are not valid inside the chart SVG and may trigger React DOM warnings.
177
+ * - `function`: a render function of custom label
178
+ *
179
+ * @defaultValue false
180
+ */
181
+ label?: ImplicitLabelListType;
182
+ /**
183
+ * The type of icon in legend.
184
+ * If set to 'none', no legend item will be rendered.
185
+ * @defaultValue 'line'
186
+ */
187
+ legendType?: LegendType;
188
+ /**
189
+ * The name of data.
190
+ * This option will be used in tooltip and legend to represent this graphical item.
191
+ * If no value was set to this option, the value of dataKey will be used alternatively.
192
+ */
193
+ name?: string | number;
194
+ /**
195
+ * The customized event handler of animation end
196
+ */
197
+ onAnimationEnd?: () => void;
198
+ /**
199
+ * The customized event handler of animation start
200
+ */
201
+ onAnimationStart?: () => void;
202
+ /**
203
+ * If set a ReactElement, the shape of area can be customized.
204
+ * If set a function, the function will be called to render customized shape.
205
+ * By default, renders a filled curve path with a clipPath entrance animation.
206
+ *
207
+ * During animations the shape receives additional props: `animationElapsedTime`, `isAnimating`, and `isEntrance`.
208
+ * When a custom shape is provided, the built-in clipPath entrance animation is skipped.
209
+ *
210
+ * @see AreaRevealShape — the default entrance animation, available for import from recharts
211
+ * @example <Area dataKey="value" shape={CustomizedShapeComponent} />
212
+ * @example <Area dataKey="value" shape={renderShapeFunction} />
213
+ */
214
+ shape?: ActiveShape<AreaRevealShapeProps, SVGPathElement>;
215
+ /**
216
+ * When two Areas have the same axisId and same stackId, then the two Areas are stacked in the chart.
217
+ */
218
+ stackId?: StackId;
219
+ /**
220
+ * The stroke color. If "none", no line will be drawn.
221
+ * @defaultValue '#3182bd'
222
+ */
223
+ stroke?: string;
224
+ /**
225
+ * The width of the stroke
226
+ * @defaultValue 1
227
+ */
228
+ strokeWidth?: string | number;
229
+ tooltipType?: TooltipType;
230
+ /**
231
+ * The interpolation type of curve. Allows custom interpolation function.
232
+ *
233
+ * @defaultValue linear
234
+ * @link https://d3js.org/d3-shape/curve
235
+ * @see {@link https://recharts.github.io/en-US/examples/CardinalAreaChart/ An AreaChart which has two area with different interpolation.}
236
+ */
237
+ type?: CurveType;
238
+ /**
239
+ * The unit of data. This option will be used in tooltip.
240
+ */
241
+ unit?: string | number;
242
+ /**
243
+ * Formats the value displayed in the tooltip for this Area.
244
+ * When set, takes precedence over the `formatter` prop on the Tooltip component.
245
+ */
246
+ formatter?: Formatter;
247
+ /**
248
+ * The id of XAxis which is corresponding to the data. Required when there are multiple XAxes.
249
+ * @defaultValue 0
250
+ */
251
+ xAxisId?: AxisId;
252
+ /**
253
+ * The id of YAxis which is corresponding to the data. Required when there are multiple YAxes.
254
+ * @defaultValue 0
255
+ */
256
+ yAxisId?: AxisId;
257
+ /**
258
+ * Z-Index of this component and its children. The higher the value,
259
+ * the more on top it will be rendered.
260
+ * Components with higher zIndex will appear in front of components with lower zIndex.
261
+ * If undefined or 0, the content is rendered in the default layer without portals.
262
+ *
263
+ * @since 3.4
264
+ * @defaultValue 100
265
+ * @see {@link https://recharts.github.io/en-US/guide/zIndex/ Z-Index and layers guide}
266
+ */
267
+ zIndex?: number;
268
+ }
269
+ export declare const defaultAreaProps: {
270
+ readonly activeDot: true;
271
+ readonly animationBegin: 0;
272
+ readonly animationDuration: 1500;
273
+ readonly animationEasing: 'ease';
274
+ readonly animationMatchBy: 'index';
275
+ readonly animationInterpolateFn: AnimationInterpolateFn<AreaPointItem, CartesianLayout>;
276
+ readonly connectNulls: false;
277
+ readonly dot: false;
278
+ readonly fill: '#3182bd';
279
+ readonly fillOpacity: 0.6;
280
+ readonly hide: false;
281
+ readonly isAnimationActive: 'auto';
282
+ readonly legendType: 'line';
283
+ readonly stroke: '#3182bd';
284
+ readonly strokeWidth: 1;
285
+ readonly type: 'linear';
286
+ readonly label: false;
287
+ readonly shape: typeof AreaRevealShape;
288
+ readonly xAxisId: 0;
289
+ readonly yAxisId: 0;
290
+ readonly zIndex: 100;
291
+ };
292
+ /**
293
+ * Because of naming conflict, we are forced to ignore certain (valid) SVG attributes.
294
+ */
295
+ type AreaSvgProps = Omit<
296
+ CurveProps,
297
+ 'points' | 'ref' | 'layout' | 'path' | 'pathRef' | 'baseLine' | 'dangerouslySetInnerHTML'
298
+ >;
299
+ export type Props<DataPointType, ValueAxisType> = AreaSvgProps &
300
+ AreaProps<DataPointType, ValueAxisType>;
301
+ export declare const getBaseValue: (
302
+ layout: 'horizontal' | 'vertical',
303
+ chartBaseValue: BaseValue | undefined,
304
+ itemBaseValue: BaseValue | undefined,
305
+ xAxis: BaseAxisWithScale,
306
+ yAxis: BaseAxisWithScale,
307
+ ) => number;
308
+ export declare function computeArea({
309
+ areaSettings: { connectNulls, baseValue: itemBaseValue, dataKey },
310
+ stackedData,
311
+ layout,
312
+ chartBaseValue,
313
+ xAxis,
314
+ yAxis,
315
+ displayedData,
316
+ dataStartIndex,
317
+ xAxisTicks,
318
+ yAxisTicks,
319
+ bandSize,
320
+ }: {
321
+ areaSettings: AreaSettings;
322
+ stackedData: ReadonlyArray<StackDataPoint> | undefined;
323
+ layout: 'horizontal' | 'vertical';
324
+ chartBaseValue: BaseValue | undefined;
325
+ xAxis: BaseAxisWithScale;
326
+ yAxis: BaseAxisWithScale;
327
+ displayedData: ChartData;
328
+ dataStartIndex: number;
329
+ xAxisTicks: TickItem[];
330
+ yAxisTicks: TickItem[];
331
+ bandSize: number;
332
+ }): ComputedArea;
333
+ /**
334
+ * @provides LabelListContext
335
+ * @consumes CartesianChartContext
336
+ */
337
+ export declare const Area: <DataPointType = any, ValueAxisType = any>(
338
+ props: Props<DataPointType, ValueAxisType>,
339
+ ) => ReactElement;
340
+ export {};
@@ -0,0 +1,202 @@
1
+ import * as React from 'octane';
2
+ import { isNumber } from '../util/DataUtils';
3
+ import { Curve, BaseLineType, Props as CurveProps } from '../shape/Curve';
4
+ import { CartesianLayout, LayoutType, ShapeAnimationProps } from '../util/types';
5
+ import { isWellBehavedNumber } from '../util/isWellBehavedNumber';
6
+ import { Layer } from '../container/Layer';
7
+ import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
8
+ import { useId } from '../util/useId';
9
+
10
+ /**
11
+ * Props for the clip-path rect computation.
12
+ * @internal
13
+ */
14
+ interface ClipRectProps {
15
+ alpha: number;
16
+ points: ReadonlyArray<{ x?: number | null; y?: number | null }>;
17
+ baseLine: BaseLineType | undefined;
18
+ strokeWidth: string | number | undefined;
19
+ }
20
+
21
+ function HorizontalClipRect({ alpha, baseLine, points, strokeWidth }: ClipRectProps) {
22
+ const startX = points[0]?.x;
23
+ const endX = points[points.length - 1]?.x;
24
+ if (!isWellBehavedNumber(startX) || !isWellBehavedNumber(endX)) {
25
+ return null;
26
+ }
27
+ const width = alpha * Math.abs(startX - endX);
28
+ let maxY = Math.max(...points.map((entry) => entry.y || 0));
29
+
30
+ if (isNumber(baseLine)) {
31
+ maxY = Math.max(baseLine, maxY);
32
+ } else if (baseLine && Array.isArray(baseLine) && baseLine.length) {
33
+ maxY = Math.max(...baseLine.map((entry) => entry.y || 0), maxY);
34
+ }
35
+
36
+ if (isNumber(maxY)) {
37
+ return <rect
38
+ x={startX < endX ? startX : startX - width}
39
+ y={0}
40
+ width={width}
41
+ height={Math.floor(maxY + (strokeWidth ? parseInt(`${strokeWidth}`, 10) : 1))}
42
+ />;
43
+ }
44
+
45
+ return null;
46
+ }
47
+
48
+ function VerticalClipRect({ alpha, baseLine, points, strokeWidth }: ClipRectProps) {
49
+ const startY = points[0]?.y;
50
+ const endY = points[points.length - 1]?.y;
51
+ if (!isWellBehavedNumber(startY) || !isWellBehavedNumber(endY)) {
52
+ return null;
53
+ }
54
+ const height = alpha * Math.abs(startY - endY);
55
+ let maxX = Math.max(...points.map((entry) => entry.x || 0));
56
+
57
+ if (isNumber(baseLine)) {
58
+ maxX = Math.max(baseLine, maxX);
59
+ } else if (baseLine && Array.isArray(baseLine) && baseLine.length) {
60
+ maxX = Math.max(...baseLine.map((entry) => entry.x || 0), maxX);
61
+ }
62
+
63
+ if (isNumber(maxX)) {
64
+ return <rect
65
+ x={0}
66
+ y={startY < endY ? startY : startY - height}
67
+ width={maxX + (strokeWidth ? parseInt(`${strokeWidth}`, 10) : 1)}
68
+ height={Math.floor(height)}
69
+ />;
70
+ }
71
+
72
+ return null;
73
+ }
74
+
75
+ function RevealClipRect({ alpha, layout, points, baseLine, strokeWidth }: ClipRectProps & {
76
+ layout: CartesianLayout;
77
+ }) {
78
+ if (layout === 'vertical') {
79
+ return <VerticalClipRect
80
+ alpha={alpha}
81
+ points={points}
82
+ baseLine={baseLine}
83
+ strokeWidth={strokeWidth}
84
+ />;
85
+ }
86
+
87
+ return <HorizontalClipRect
88
+ alpha={alpha}
89
+ points={points}
90
+ baseLine={baseLine}
91
+ strokeWidth={strokeWidth}
92
+ />;
93
+ }
94
+
95
+ export type AreaRevealShapeProps =
96
+ CurveProps & ShapeAnimationProps & { layout?: LayoutType; isRange?: boolean };
97
+
98
+ /**
99
+ * The default shape for Area that reveals the chart with a left-to-right (or top-to-bottom)
100
+ * clip-path animation on entrance, and renders the plain curve otherwise.
101
+ *
102
+ * This component renders the complete Area visual: the filled area curve, the stroke curve,
103
+ * and (for range areas) the baseline stroke curve. During entrance animation, all curves are
104
+ * wrapped in a clip-path that progressively reveals the area.
105
+ *
106
+ * This is the built-in entrance animation for Area. It is automatically used when no custom
107
+ * `shape` prop is provided. You can import and reuse it as a starting point for custom shapes.
108
+ *
109
+ * @example
110
+ * ```tsx
111
+ * import { Area, AreaRevealShape } from 'recharts';
112
+ *
113
+ * // Use the default shape explicitly (same as providing no shape prop)
114
+ * <Area dataKey="value" shape={AreaRevealShape} />
115
+ * ```
116
+ *
117
+ * @see {@link https://recharts.github.io/en-US/guide/animations Animation guide}
118
+ *
119
+ * @since 3.9
120
+ */
121
+ export function AreaRevealShape(props: AreaRevealShapeProps): React.ReactElement | null {
122
+ const {
123
+ animationElapsedTime = 1,
124
+ isAnimating = false,
125
+ isEntrance = false,
126
+ layout: layoutProp,
127
+ isRange,
128
+ stroke,
129
+ connectNulls,
130
+ ...restProps
131
+ } = props;
132
+ const layout: CartesianLayout =
133
+ layoutProp === 'vertical' ? 'vertical' : 'horizontal';
134
+ const finalConnectNulls = connectNulls ?? false;
135
+ const clipId = useId();
136
+
137
+ const { id, baseLine, ...propsWithoutIdBaseline } = restProps;
138
+ const strokeSvgProps = svgPropertiesNoEvents(propsWithoutIdBaseline);
139
+
140
+ const fillCurve = <Curve
141
+ {...restProps}
142
+ id={id}
143
+ baseLine={baseLine}
144
+ connectNulls={finalConnectNulls}
145
+ stroke="none"
146
+ className="recharts-area-area"
147
+ layout={layout}
148
+ />;
149
+
150
+ const strokeCurve =
151
+ stroke !== 'none' &&
152
+ <Curve
153
+ {...strokeSvgProps}
154
+ className="recharts-area-curve"
155
+ layout={layout}
156
+ type={restProps.type}
157
+ connectNulls={finalConnectNulls}
158
+ fill="none"
159
+ stroke={stroke}
160
+ points={restProps.points}
161
+ />;
162
+
163
+ const baselineCurve =
164
+ stroke !== 'none' && isRange && Array.isArray(baseLine) &&
165
+ <Curve
166
+ {...strokeSvgProps}
167
+ className="recharts-area-curve"
168
+ layout={layout}
169
+ type={restProps.type}
170
+ connectNulls={finalConnectNulls}
171
+ fill="none"
172
+ stroke={stroke}
173
+ points={baseLine}
174
+ />;
175
+
176
+ if (isEntrance && (isAnimating || animationElapsedTime < 1)) {
177
+ return <Layer>
178
+ <defs>
179
+ <clipPath id={clipId}>
180
+ <RevealClipRect
181
+ alpha={animationElapsedTime}
182
+ points={restProps.points ?? []}
183
+ baseLine={baseLine}
184
+ layout={layout}
185
+ strokeWidth={restProps.strokeWidth}
186
+ />
187
+ </clipPath>
188
+ </defs>
189
+ <Layer clipPath={`url(#${clipId})`}>
190
+ {fillCurve}
191
+ {strokeCurve}
192
+ {baselineCurve}
193
+ </Layer>
194
+ </Layer>;
195
+ }
196
+
197
+ return <>
198
+ {fillCurve}
199
+ {strokeCurve}
200
+ {baselineCurve}
201
+ </>;
202
+ }