@octanejs/recharts 0.1.62 → 0.1.63

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 (73) hide show
  1. package/package.json +5 -5
  2. package/src/animation/AnimatedItems.tsrx +36 -31
  3. package/src/animation/CSSTransitionAnimate.tsrx +1 -2
  4. package/src/animation/JavascriptAnimate.tsrx +1 -2
  5. package/src/cartesian/Area.tsrx +414 -386
  6. package/src/cartesian/AreaRevealShape.tsrx +103 -84
  7. package/src/cartesian/Bar.tsrx +343 -317
  8. package/src/cartesian/BarStack.tsrx +33 -28
  9. package/src/cartesian/CartesianAxis.tsrx +168 -165
  10. package/src/cartesian/CartesianGrid.tsrx +256 -272
  11. package/src/cartesian/ErrorBar.tsrx +108 -104
  12. package/src/cartesian/Funnel.tsrx +405 -382
  13. package/src/cartesian/GraphicalItemClipPath.tsrx +4 -8
  14. package/src/cartesian/Line.tsrx +190 -177
  15. package/src/cartesian/LineDrawShape.tsrx +14 -15
  16. package/src/cartesian/ReferenceLine.tsrx +119 -105
  17. package/src/cartesian/Scatter.tsrx +416 -398
  18. package/src/cartesian/XAxis.tsrx +39 -32
  19. package/src/cartesian/YAxis.tsrx +47 -37
  20. package/src/cartesian/ZAxis.tsrx +76 -73
  21. package/src/chart/AreaChart.tsrx +15 -11
  22. package/src/chart/BarChart.tsrx +15 -11
  23. package/src/chart/CategoricalChart.tsrx +32 -26
  24. package/src/chart/ComposedChart.tsrx +15 -11
  25. package/src/chart/FunnelChart.tsrx +15 -11
  26. package/src/chart/LineChart.tsrx +15 -11
  27. package/src/chart/PieChart.tsrx +15 -11
  28. package/src/chart/PolarChart.tsrx +45 -48
  29. package/src/chart/RadarChart.tsrx +38 -32
  30. package/src/chart/RadialBarChart.tsrx +15 -11
  31. package/src/chart/RechartsWrapper.tsrx +214 -162
  32. package/src/chart/Sankey.tsrx +412 -378
  33. package/src/chart/ScatterChart.tsrx +15 -11
  34. package/src/chart/SunburstChart.tsrx +162 -155
  35. package/src/component/ActivePoints.tsrx +19 -13
  36. package/src/component/Cursor.tsrx +25 -18
  37. package/src/component/DefaultLegendContent.tsrx +131 -127
  38. package/src/component/DefaultTooltipContent.tsrx +46 -42
  39. package/src/component/Dots.tsrx +11 -5
  40. package/src/component/Label.tsrx +69 -55
  41. package/src/component/LabelList.tsrx +32 -27
  42. package/src/component/Legend.tsrx +120 -123
  43. package/src/component/ResponsiveContainer.tsrx +18 -11
  44. package/src/component/Text.tsrx +50 -43
  45. package/src/component/Tooltip.tsrx +234 -223
  46. package/src/component/TooltipBoundingBox.tsrx +34 -34
  47. package/src/container/ClipPathProvider.tsrx +1 -3
  48. package/src/container/Layer.tsrx +5 -1
  49. package/src/container/RootSurface.tsrx +31 -21
  50. package/src/container/Surface.tsrx +15 -13
  51. package/src/context/ErrorBarContext.tsrx +5 -5
  52. package/src/polar/Pie.tsrx +541 -487
  53. package/src/polar/PolarAngleAxis.tsrx +245 -227
  54. package/src/polar/PolarGrid.tsrx +139 -127
  55. package/src/polar/PolarRadiusAxis.tsrx +204 -185
  56. package/src/polar/Radar.tsrx +274 -264
  57. package/src/polar/RadialBar.tsrx +408 -361
  58. package/src/shape/Cross.tsrx +13 -7
  59. package/src/shape/Curve.tsrx +54 -44
  60. package/src/shape/Dot.tsrx +10 -8
  61. package/src/shape/Polygon.tsrx +38 -29
  62. package/src/shape/Rectangle.tsrx +73 -28
  63. package/src/shape/Sector.tsrx +30 -18
  64. package/src/shape/Symbols.tsrx +13 -11
  65. package/src/shape/Trapezoid.tsrx +16 -11
  66. package/src/state/RechartsStoreProvider.tsrx +5 -1
  67. package/src/synchronisation/useChartSynchronisation.tsrx +8 -7
  68. package/src/util/BarUtils.tsrx +43 -40
  69. package/src/util/FunnelUtils.tsrx +5 -5
  70. package/src/util/RadialBarUtils.tsrx +3 -4
  71. package/src/util/ScatterUtils.tsrx +13 -8
  72. package/src/zIndex/ZIndexLayer.tsrx +2 -2
  73. package/src/zIndex/ZIndexPortal.tsrx +2 -8
@@ -91,8 +91,9 @@ export type BaseValue = number | 'dataMin' | 'dataMax';
91
91
  /**
92
92
  * Our base value array has payload in it, and we expose it externally too.
93
93
  */
94
- type BaseValueCoordinate<DataPointType = any> =
95
- NullableCoordinate & { payload: DataPointType | undefined };
94
+ type BaseValueCoordinate<DataPointType = any> = NullableCoordinate & {
95
+ payload: DataPointType | undefined;
96
+ };
96
97
 
97
98
  /**
98
99
  * Internal props, combination of external props + defaultProps + private Recharts state
@@ -114,8 +115,8 @@ interface InternalAreaProps extends ZIndexable {
114
115
  height: number;
115
116
  hide: boolean;
116
117
  /**
117
- * ID is mandatory internally, but optional externally.
118
- */
118
+ * ID is mandatory internally, but optional externally.
119
+ */
119
120
  id: string;
120
121
  isAnimationActive: boolean | 'auto';
121
122
  isRange?: boolean;
@@ -143,235 +144,237 @@ interface InternalAreaProps extends ZIndexable {
143
144
  /**
144
145
  * External props, intended for end users to fill in
145
146
  */
146
- interface AreaProps<DataPointType = any, DataValueType = any> extends DataProvider<
147
- DataPointType
148
- >, Required<DataConsumer<DataPointType, DataValueType>>, ZIndexable {
147
+ interface AreaProps<DataPointType = any, DataValueType = any>
148
+ extends
149
+ DataProvider<DataPointType>,
150
+ Required<DataConsumer<DataPointType, DataValueType>>,
151
+ ZIndexable {
149
152
  /**
150
- * The active dot is rendered on the closest data point when user interacts with the chart. Options:
151
- *
152
- * - `false`: dots do not change on user activity; both active and inactive dots follow the `dot` prop (see below)
153
- * - `true`: renders the active dot with default settings
154
- * - `object`: the props of the active dot. This will be merged with the internal calculated props of the active dot
155
- * - `OctaneElement`: the custom active dot element
156
- * - `function`: a render function of the custom active dot
157
- *
158
- * @defaultValue true
159
- * @example <Area dataKey="value" activeDot={false} />
160
- * @example <Area dataKey="value" activeDot={{ stroke: 'red', strokeWidth: 2, r: 10 }} />
161
- * @example <Area dataKey="value" activeDot={CustomizedActiveDot} />
162
- *
163
- * @see {@link https://recharts.github.io/en-US/examples/SimpleLineChart/ A line chart with customized active dot}
164
- */
153
+ * The active dot is rendered on the closest data point when user interacts with the chart. Options:
154
+ *
155
+ * - `false`: dots do not change on user activity; both active and inactive dots follow the `dot` prop (see below)
156
+ * - `true`: renders the active dot with default settings
157
+ * - `object`: the props of the active dot. This will be merged with the internal calculated props of the active dot
158
+ * - `OctaneElement`: the custom active dot element
159
+ * - `function`: a render function of the custom active dot
160
+ *
161
+ * @defaultValue true
162
+ * @example <Area dataKey="value" activeDot={false} />
163
+ * @example <Area dataKey="value" activeDot={{ stroke: 'red', strokeWidth: 2, r: 10 }} />
164
+ * @example <Area dataKey="value" activeDot={CustomizedActiveDot} />
165
+ *
166
+ * @see {@link https://recharts.github.io/en-US/examples/SimpleLineChart/ A line chart with customized active dot}
167
+ */
165
168
  activeDot?: ActiveDotType;
166
169
  /**
167
- * Specifies when the animation should begin, the unit of this option is ms.
168
- * @defaultValue 0
169
- */
170
+ * Specifies when the animation should begin, the unit of this option is ms.
171
+ * @defaultValue 0
172
+ */
170
173
  animationBegin?: number;
171
174
  /**
172
- * Specifies the duration of animation, the unit of this option is ms.
173
- * @defaultValue 1500
174
- */
175
+ * Specifies the duration of animation, the unit of this option is ms.
176
+ * @defaultValue 1500
177
+ */
175
178
  animationDuration?: AnimationDuration;
176
179
  /**
177
- * The type of easing function.
178
- * @defaultValue 'ease'
179
- */
180
+ * The type of easing function.
181
+ * @defaultValue 'ease'
182
+ */
180
183
  animationEasing?: EasingInput;
181
184
  /**
182
- * Custom animation function for interpolating data items.
183
- * When provided, this replaces the default animation interpolation.
184
- *
185
- * @param prevItems The items from the previous animation frame, or null on first render
186
- * @param nextItems The target items to animate towards
187
- * @param animationElapsedTime A normalized time value (0 = start, 1 = end)
188
- * @returns The interpolated items at time animationElapsedTime
189
- *
190
- * @since 3.9
191
- * @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
192
- */
185
+ * Custom animation function for interpolating data items.
186
+ * When provided, this replaces the default animation interpolation.
187
+ *
188
+ * @param prevItems The items from the previous animation frame, or null on first render
189
+ * @param nextItems The target items to animate towards
190
+ * @param animationElapsedTime A normalized time value (0 = start, 1 = end)
191
+ * @returns The interpolated items at time animationElapsedTime
192
+ *
193
+ * @since 3.9
194
+ * @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
195
+ */
193
196
  animationInterpolateFn?: AnimationInterpolateFn<AreaPointItem, CartesianLayout>;
194
197
  /**
195
- * Strategy for matching previous items to next items during animation.
196
- * Determines how Recharts pairs old data points with new data points
197
- * to create smooth transitions.
198
- *
199
- * - `matchByIndex` (default): match by array position with proportional stretching
200
- * - `matchAppend`: match sequentially by index and treat newly appended items as new
201
- * - `matchByDataKey('someKey')`: match by a data key from the payload
202
- * - Custom function `(item, index) => key`: match by the returned key
203
- *
204
- * @defaultValue index
205
- * @see matchByIndex
206
- * @see matchByDataKey
207
- * @see matchAppend
208
- *
209
- * @since 3.9
210
- * @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
211
- */
198
+ * Strategy for matching previous items to next items during animation.
199
+ * Determines how Recharts pairs old data points with new data points
200
+ * to create smooth transitions.
201
+ *
202
+ * - `matchByIndex` (default): match by array position with proportional stretching
203
+ * - `matchAppend`: match sequentially by index and treat newly appended items as new
204
+ * - `matchByDataKey('someKey')`: match by a data key from the payload
205
+ * - Custom function `(item, index) => key`: match by the returned key
206
+ *
207
+ * @defaultValue index
208
+ * @see matchByIndex
209
+ * @see matchByDataKey
210
+ * @see matchAppend
211
+ *
212
+ * @since 3.9
213
+ * @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
214
+ */
212
215
  animationMatchBy?: AnimationMatchByProp<AreaPointItem>;
213
216
  /**
214
- * Configures the starting value used to build the internal baseline for non-ranged, non-stacked areas.
215
- *
216
- * WARNING despite the name `dataMin`|`dataMax` this actually reads the domain instead, so it should rather be
217
- * `domainMin`|`domainMax`. This looks like a small detail,
218
- * but it's actually important because domains are usually extended automatically.
219
- * For example the default numerical domain starts from 0.
220
- *
221
- * - `number`: uses the corresponding axis value as a flat baseline
222
- * - `dataMin`: uses the minimum of the value-axis domain
223
- * - `dataMax`: uses the maximum of the value-axis domain
224
- *
225
- * Ignored when the area is stacked or when `dataKey` already returns `[min, max]` tuples.
226
- *
227
- * Note that the baseValue does not interact with `animationInterpolateFn`;
228
- * baseValue is always animated by linear interpolation.
229
- * If you want a custom animation then have your `dataKey` return a tuple of two values instead of a single number
230
- * which will also render a ranged Area, and that does work with your custom `animationInterpolateFn`.
231
- */
217
+ * Configures the starting value used to build the internal baseline for non-ranged, non-stacked areas.
218
+ *
219
+ * WARNING despite the name `dataMin`|`dataMax` this actually reads the domain instead, so it should rather be
220
+ * `domainMin`|`domainMax`. This looks like a small detail,
221
+ * but it's actually important because domains are usually extended automatically.
222
+ * For example the default numerical domain starts from 0.
223
+ *
224
+ * - `number`: uses the corresponding axis value as a flat baseline
225
+ * - `dataMin`: uses the minimum of the value-axis domain
226
+ * - `dataMax`: uses the maximum of the value-axis domain
227
+ *
228
+ * Ignored when the area is stacked or when `dataKey` already returns `[min, max]` tuples.
229
+ *
230
+ * Note that the baseValue does not interact with `animationInterpolateFn`;
231
+ * baseValue is always animated by linear interpolation.
232
+ * If you want a custom animation then have your `dataKey` return a tuple of two values instead of a single number
233
+ * which will also render a ranged Area, and that does work with your custom `animationInterpolateFn`.
234
+ */
232
235
  baseValue?: BaseValue;
233
236
  className?: string;
234
237
  /**
235
- * Whether to connect the area across null points.
236
- *
237
- * @defaultValue false
238
- * @see {@link https://recharts.github.io/en-US/examples/AreaChartConnectNulls/ AreaChart with connectNull true and false}
239
- */
238
+ * Whether to connect the area across null points.
239
+ *
240
+ * @defaultValue false
241
+ * @see {@link https://recharts.github.io/en-US/examples/AreaChartConnectNulls/ AreaChart with connectNull true and false}
242
+ */
240
243
  connectNulls?: boolean;
241
244
  /**
242
- * Renders a circle element at each data point. Options:
243
- *
244
- * - `false`: no dots are drawn;
245
- * - `true`: renders the dots with default settings;
246
- * - `object`: the props of the dot. This will be merged with the internal calculated props of each dot;
247
- * - `OctaneElement`: the custom dot element;
248
- * - `function`: a render function of the custom dot.
249
- *
250
- * @defaultValue false
251
- */
245
+ * Renders a circle element at each data point. Options:
246
+ *
247
+ * - `false`: no dots are drawn;
248
+ * - `true`: renders the dots with default settings;
249
+ * - `object`: the props of the dot. This will be merged with the internal calculated props of each dot;
250
+ * - `OctaneElement`: the custom dot element;
251
+ * - `function`: a render function of the custom dot.
252
+ *
253
+ * @defaultValue false
254
+ */
252
255
  dot?: DotType;
253
256
  /**
254
- * Hides the whole graphical element when true.
255
- *
256
- * Hiding an element is different from removing it from the chart:
257
- * Hidden graphical elements are still visible in Legend,
258
- * and can be included in axis domain calculations,
259
- * depending on `includeHidden` props of your XAxis/YAxis.
260
- *
261
- * @defaultValue false
262
- */
257
+ * Hides the whole graphical element when true.
258
+ *
259
+ * Hiding an element is different from removing it from the chart:
260
+ * Hidden graphical elements are still visible in Legend,
261
+ * and can be included in axis domain calculations,
262
+ * depending on `includeHidden` props of your XAxis/YAxis.
263
+ *
264
+ * @defaultValue false
265
+ */
263
266
  hide?: boolean;
264
267
  /**
265
- * Unique identifier of this component.
266
- * Used as an HTML attribute `id`, and also to identify this element internally.
267
- *
268
- * If undefined, Recharts will generate a unique ID automatically.
269
- */
268
+ * Unique identifier of this component.
269
+ * Used as an HTML attribute `id`, and also to identify this element internally.
270
+ *
271
+ * If undefined, Recharts will generate a unique ID automatically.
272
+ */
270
273
  id?: string;
271
274
  /**
272
- * If set false, animation of area will be disabled.
273
- * If set "auto", will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility.
274
- * @defaultValue 'auto'
275
- */
275
+ * If set false, animation of area will be disabled.
276
+ * If set "auto", will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility.
277
+ * @defaultValue 'auto'
278
+ */
276
279
  isAnimationActive?: boolean | 'auto';
277
280
  /**
278
- * Renders one label for each data point. Options:
279
- *
280
- * - `true`: renders default labels
281
- * - `false`: no labels are rendered
282
- * - `object`: the props of LabelList component
283
- * - `OctaneElement`: a custom SVG label element, such as `<text>` or `<g>`.
284
- * HTML elements such as `<div>` are not valid inside the chart SVG and may trigger React DOM warnings.
285
- * - `function`: a render function of custom label
286
- *
287
- * @defaultValue false
288
- */
281
+ * Renders one label for each data point. Options:
282
+ *
283
+ * - `true`: renders default labels
284
+ * - `false`: no labels are rendered
285
+ * - `object`: the props of LabelList component
286
+ * - `OctaneElement`: a custom SVG label element, such as `<text>` or `<g>`.
287
+ * HTML elements such as `<div>` are not valid inside the chart SVG and may trigger React DOM warnings.
288
+ * - `function`: a render function of custom label
289
+ *
290
+ * @defaultValue false
291
+ */
289
292
  label?: ImplicitLabelListType;
290
293
  /**
291
- * The type of icon in legend.
292
- * If set to 'none', no legend item will be rendered.
293
- * @defaultValue 'line'
294
- */
294
+ * The type of icon in legend.
295
+ * If set to 'none', no legend item will be rendered.
296
+ * @defaultValue 'line'
297
+ */
295
298
  legendType?: LegendType;
296
299
  /**
297
- * The name of data.
298
- * This option will be used in tooltip and legend to represent this graphical item.
299
- * If no value was set to this option, the value of dataKey will be used alternatively.
300
- */
300
+ * The name of data.
301
+ * This option will be used in tooltip and legend to represent this graphical item.
302
+ * If no value was set to this option, the value of dataKey will be used alternatively.
303
+ */
301
304
  name?: string | number;
302
305
  /**
303
- * The customized event handler of animation end
304
- */
306
+ * The customized event handler of animation end
307
+ */
305
308
  onAnimationEnd?: () => void;
306
309
  /**
307
- * The customized event handler of animation start
308
- */
310
+ * The customized event handler of animation start
311
+ */
309
312
  onAnimationStart?: () => void;
310
313
  /**
311
- * If set a OctaneElement, the shape of area can be customized.
312
- * If set a function, the function will be called to render customized shape.
313
- * By default, renders a filled curve path with a clipPath entrance animation.
314
- *
315
- * During animations the shape receives additional props: `animationElapsedTime`, `isAnimating`, and `isEntrance`.
316
- * When a custom shape is provided, the built-in clipPath entrance animation is skipped.
317
- *
318
- * @see AreaRevealShape — the default entrance animation, available for import from recharts
319
- * @example <Area dataKey="value" shape={CustomizedShapeComponent} />
320
- * @example <Area dataKey="value" shape={renderShapeFunction} />
321
- */
314
+ * If set a OctaneElement, the shape of area can be customized.
315
+ * If set a function, the function will be called to render customized shape.
316
+ * By default, renders a filled curve path with a clipPath entrance animation.
317
+ *
318
+ * During animations the shape receives additional props: `animationElapsedTime`, `isAnimating`, and `isEntrance`.
319
+ * When a custom shape is provided, the built-in clipPath entrance animation is skipped.
320
+ *
321
+ * @see AreaRevealShape — the default entrance animation, available for import from recharts
322
+ * @example <Area dataKey="value" shape={CustomizedShapeComponent} />
323
+ * @example <Area dataKey="value" shape={renderShapeFunction} />
324
+ */
322
325
  shape?: ActiveShape<AreaRevealShapeProps, SVGPathElement>;
323
326
  /**
324
- * When two Areas have the same axisId and same stackId, then the two Areas are stacked in the chart.
325
- */
327
+ * When two Areas have the same axisId and same stackId, then the two Areas are stacked in the chart.
328
+ */
326
329
  stackId?: StackId;
327
330
  /**
328
- * The stroke color. If "none", no line will be drawn.
329
- * @defaultValue '#3182bd'
330
- */
331
+ * The stroke color. If "none", no line will be drawn.
332
+ * @defaultValue '#3182bd'
333
+ */
331
334
  stroke?: string;
332
335
  /**
333
- * The width of the stroke
334
- * @defaultValue 1
335
- */
336
+ * The width of the stroke
337
+ * @defaultValue 1
338
+ */
336
339
  strokeWidth?: string | number;
337
340
  tooltipType?: TooltipType;
338
341
  /**
339
- * The interpolation type of curve. Allows custom interpolation function.
340
- *
341
- * @defaultValue linear
342
- * @link https://d3js.org/d3-shape/curve
343
- * @see {@link https://recharts.github.io/en-US/examples/CardinalAreaChart/ An AreaChart which has two area with different interpolation.}
344
- */
342
+ * The interpolation type of curve. Allows custom interpolation function.
343
+ *
344
+ * @defaultValue linear
345
+ * @link https://d3js.org/d3-shape/curve
346
+ * @see {@link https://recharts.github.io/en-US/examples/CardinalAreaChart/ An AreaChart which has two area with different interpolation.}
347
+ */
345
348
  type?: CurveType;
346
349
  /**
347
- * The unit of data. This option will be used in tooltip.
348
- */
350
+ * The unit of data. This option will be used in tooltip.
351
+ */
349
352
  unit?: string | number;
350
353
  /**
351
- * Formats the value displayed in the tooltip for this Area.
352
- * When set, takes precedence over the `formatter` prop on the Tooltip component.
353
- */
354
+ * Formats the value displayed in the tooltip for this Area.
355
+ * When set, takes precedence over the `formatter` prop on the Tooltip component.
356
+ */
354
357
  formatter?: Formatter;
355
358
  /**
356
- * The id of XAxis which is corresponding to the data. Required when there are multiple XAxes.
357
- * @defaultValue 0
358
- */
359
+ * The id of XAxis which is corresponding to the data. Required when there are multiple XAxes.
360
+ * @defaultValue 0
361
+ */
359
362
  xAxisId?: AxisId;
360
363
  /**
361
- * The id of YAxis which is corresponding to the data. Required when there are multiple YAxes.
362
- * @defaultValue 0
363
- */
364
+ * The id of YAxis which is corresponding to the data. Required when there are multiple YAxes.
365
+ * @defaultValue 0
366
+ */
364
367
  yAxisId?: AxisId;
365
368
  /**
366
- * Z-Index of this component and its children. The higher the value,
367
- * the more on top it will be rendered.
368
- * Components with higher zIndex will appear in front of components with lower zIndex.
369
- * If undefined or 0, the content is rendered in the default layer without portals.
370
- *
371
- * @since 3.4
372
- * @defaultValue 100
373
- * @see {@link https://recharts.github.io/en-US/guide/zIndex/ Z-Index and layers guide}
374
- */
369
+ * Z-Index of this component and its children. The higher the value,
370
+ * the more on top it will be rendered.
371
+ * Components with higher zIndex will appear in front of components with lower zIndex.
372
+ * If undefined or 0, the content is rendered in the default layer without portals.
373
+ *
374
+ * @since 3.4
375
+ * @defaultValue 100
376
+ * @see {@link https://recharts.github.io/en-US/guide/zIndex/ Z-Index and layers guide}
377
+ */
375
378
  zIndex?: number;
376
379
  }
377
380
 
@@ -398,10 +401,10 @@ const defaultAreaAnimateItems: AnimationInterpolateFn<AreaPointItem, CartesianLa
398
401
  }
399
402
  if (item.status === 'added') {
400
403
  /*
401
- * Here we just return the final position without interpolating
402
- * so that we can allow the default initial animation that is done by clipPath in AreaRevealShape.
403
- * If you want your own custom animations then you may want to interpolate this one as well.
404
- */
404
+ * Here we just return the final position without interpolating
405
+ * so that we can allow the default initial animation that is done by clipPath in AreaRevealShape.
406
+ * If you want your own custom animations then you may want to interpolate this one as well.
407
+ */
405
408
  return [item.next];
406
409
  }
407
410
  // removed: drop
@@ -436,21 +439,19 @@ export const defaultAreaProps = {
436
439
  /**
437
440
  * Because of naming conflict, we are forced to ignore certain (valid) SVG attributes.
438
441
  */
439
- type AreaSvgProps =
440
- Omit<
441
- CurveProps,
442
- 'points' | 'ref' | 'layout' | 'path' | 'pathRef' | 'baseLine' | 'dangerouslySetInnerHTML'
443
- >;
442
+ type AreaSvgProps = Omit<
443
+ CurveProps,
444
+ 'points' | 'ref' | 'layout' | 'path' | 'pathRef' | 'baseLine' | 'dangerouslySetInnerHTML'
445
+ >;
444
446
 
445
447
  type InternalProps = AreaSvgProps & InternalAreaProps;
446
448
 
447
- export type Props<DataPointType, ValueAxisType> =
448
- AreaSvgProps & AreaProps<DataPointType, ValueAxisType>;
449
+ export type Props<DataPointType, ValueAxisType> = AreaSvgProps &
450
+ AreaProps<DataPointType, ValueAxisType>;
449
451
 
450
- type PropsWithDefaults<DataPointType, ValueAxisType> =
451
- WithIdRequired<
452
- RequiresDefaultProps<Props<DataPointType, ValueAxisType>, typeof defaultAreaProps>
453
- >;
452
+ type PropsWithDefaults<DataPointType, ValueAxisType> = WithIdRequired<
453
+ RequiresDefaultProps<Props<DataPointType, ValueAxisType>, typeof defaultAreaProps>
454
+ >;
454
455
 
455
456
  function getLegendItemColor(
456
457
  stroke: string | undefined,
@@ -538,16 +539,18 @@ function AreaDotsWrapper({
538
539
  const { needClip, dot, dataKey } = props;
539
540
  const areaProps: DotsDotProps = svgPropertiesNoEvents(props);
540
541
 
541
- return <Dots
542
- points={points}
543
- dot={dot}
544
- className="recharts-area-dots"
545
- dotClassName="recharts-area-dot"
546
- dataKey={dataKey}
547
- baseProps={areaProps}
548
- needClip={needClip}
549
- clipPathId={clipPathId}
550
- />;
542
+ return (
543
+ <Dots
544
+ points={points}
545
+ dot={dot}
546
+ className="recharts-area-dots"
547
+ dotClassName="recharts-area-dot"
548
+ dataKey={dataKey}
549
+ baseProps={areaProps}
550
+ needClip={needClip}
551
+ clipPathId={clipPathId}
552
+ />
553
+ );
551
554
  }
552
555
 
553
556
  function AreaLabelListProvider({
@@ -559,30 +562,32 @@ function AreaLabelListProvider({
559
562
  children: OctaneNode;
560
563
  points: ReadonlyArray<AreaPointItem>;
561
564
  }) {
562
- const labelListEntries: ReadonlyArray<CartesianLabelListEntry> = points.map((
563
- point,
564
- ): CartesianLabelListEntry => {
565
- const viewBox: TrapezoidViewBox = {
566
- x: point.x ?? 0,
567
- y: point.y ?? 0,
568
- width: 0,
569
- lowerWidth: 0,
570
- upperWidth: 0,
571
- height: 0,
572
- };
573
- return {
574
- ...viewBox,
575
- value: point.value,
576
- payload: point.payload,
577
- parentViewBox: undefined,
578
- viewBox,
579
- fill: undefined,
580
- };
581
- });
565
+ const labelListEntries: ReadonlyArray<CartesianLabelListEntry> = points.map(
566
+ (point): CartesianLabelListEntry => {
567
+ const viewBox: TrapezoidViewBox = {
568
+ x: point.x ?? 0,
569
+ y: point.y ?? 0,
570
+ width: 0,
571
+ lowerWidth: 0,
572
+ upperWidth: 0,
573
+ height: 0,
574
+ };
575
+ return {
576
+ ...viewBox,
577
+ value: point.value,
578
+ payload: point.payload,
579
+ parentViewBox: undefined,
580
+ viewBox,
581
+ fill: undefined,
582
+ };
583
+ },
584
+ );
582
585
 
583
- return <CartesianLabelListContextProvider
584
- value={showLabels ? labelListEntries : undefined}
585
- >{children}</CartesianLabelListContextProvider>;
586
+ return (
587
+ <CartesianLabelListContextProvider value={showLabels ? labelListEntries : undefined}>
588
+ {children}
589
+ </CartesianLabelListContextProvider>
590
+ );
586
591
  }
587
592
 
588
593
  function StaticArea({
@@ -624,13 +629,16 @@ function StaticArea({
624
629
  isEntrance,
625
630
  };
626
631
 
627
- return <>
628
- {points?.length > 1 &&
629
- <Layer clipPath={needClip ? `url(#clipPath-${clipPathId})` : undefined}>
630
- <Shape option={shape} DefaultShape={defaultAreaProps.shape} shapeProps={curveProps} />
631
- </Layer>}
632
- <AreaDotsWrapper points={points} props={propsWithoutId} clipPathId={clipPathId} />
633
- </>;
632
+ return (
633
+ <>
634
+ {points?.length > 1 && (
635
+ <Layer clipPath={needClip ? `url(#clipPath-${clipPathId})` : undefined}>
636
+ <Shape option={shape} DefaultShape={defaultAreaProps.shape} shapeProps={curveProps} />
637
+ </Layer>
638
+ )}
639
+ <AreaDotsWrapper points={points} props={propsWithoutId} clipPathId={clipPathId} />
640
+ </>
641
+ );
634
642
  }
635
643
 
636
644
  function interpolateScalarBaseLine(
@@ -696,49 +704,57 @@ function AreaWithAnimation({
696
704
  baseLineAnimationItems = null;
697
705
  }
698
706
 
699
- return <AnimatedItems
700
- animationInput={animationInput}
701
- animationIdPrefix="recharts-area-"
702
- items={points}
703
- previousItemsRef={previousPointsRef}
704
- isAnimationActive={isAnimationActive}
705
- animationBegin={animationBegin}
706
- animationDuration={animationDuration}
707
- animationEasing={animationEasing}
708
- onAnimationStart={handleAnimationStart}
709
- onAnimationEnd={handleAnimationEnd}
710
- animationInterpolateFn={animationInterpolateFn}
711
- animationMatchBy={animationMatchBy}
712
- layout={layout}
713
- >
714
- {(stepPoints, animationElapsedTime, isEntrance) => {
715
- let stepBaseLine: number | ReadonlyArray<NullableCoordinate> | undefined;
716
- if (animationElapsedTime === 1) {
717
- stepBaseLine = baseLine;
718
- } else if (Array.isArray(baseLine)) {
719
- stepBaseLine = animationInterpolateFn(baseLineAnimationItems, animationElapsedTime, layout);
720
- } else {
721
- stepBaseLine = isEntrance
722
- ? baseLine
723
- : interpolateScalarBaseLine(baseLine, prevBaseLine, animationElapsedTime);
724
- }
725
- baseLineAnimationState.syncStepValue(stepBaseLine, animationElapsedTime);
726
- return <AreaLabelListProvider showLabels={!isAnimating} points={points}>
727
- {props.children}
728
- <StaticArea
729
- points={stepPoints}
730
- baseLine={stepBaseLine}
731
- needClip={needClip}
732
- clipPathId={clipPathId}
733
- props={props}
734
- animationElapsedTime={animationElapsedTime}
735
- isAnimating={isAnimating || animationElapsedTime < 1}
736
- isEntrance={isEntrance}
737
- />
738
- <LabelListFromLabelProp label={props.label} />
739
- </AreaLabelListProvider>;
740
- }}
741
- </AnimatedItems>;
707
+ return (
708
+ <AnimatedItems
709
+ animationInput={animationInput}
710
+ animationIdPrefix="recharts-area-"
711
+ items={points}
712
+ previousItemsRef={previousPointsRef}
713
+ isAnimationActive={isAnimationActive}
714
+ animationBegin={animationBegin}
715
+ animationDuration={animationDuration}
716
+ animationEasing={animationEasing}
717
+ onAnimationStart={handleAnimationStart}
718
+ onAnimationEnd={handleAnimationEnd}
719
+ animationInterpolateFn={animationInterpolateFn}
720
+ animationMatchBy={animationMatchBy}
721
+ layout={layout}
722
+ >
723
+ {(stepPoints, animationElapsedTime, isEntrance) => {
724
+ let stepBaseLine: number | ReadonlyArray<NullableCoordinate> | undefined;
725
+ if (animationElapsedTime === 1) {
726
+ stepBaseLine = baseLine;
727
+ } else if (Array.isArray(baseLine)) {
728
+ stepBaseLine = animationInterpolateFn(
729
+ baseLineAnimationItems,
730
+ animationElapsedTime,
731
+ layout,
732
+ );
733
+ } else {
734
+ stepBaseLine = isEntrance
735
+ ? baseLine
736
+ : interpolateScalarBaseLine(baseLine, prevBaseLine, animationElapsedTime);
737
+ }
738
+ baseLineAnimationState.syncStepValue(stepBaseLine, animationElapsedTime);
739
+ return (
740
+ <AreaLabelListProvider showLabels={!isAnimating} points={points}>
741
+ {props.children}
742
+ <StaticArea
743
+ points={stepPoints}
744
+ baseLine={stepBaseLine}
745
+ needClip={needClip}
746
+ clipPathId={clipPathId}
747
+ props={props}
748
+ animationElapsedTime={animationElapsedTime}
749
+ isAnimating={isAnimating || animationElapsedTime < 1}
750
+ isEntrance={isEntrance}
751
+ />
752
+ <LabelListFromLabelProp label={props.label} />
753
+ </AreaLabelListProvider>
754
+ );
755
+ }}
756
+ </AnimatedItems>
757
+ );
742
758
  }
743
759
 
744
760
  /*
@@ -755,23 +771,25 @@ function RenderArea({
755
771
  props: InternalProps;
756
772
  }) {
757
773
  /*
758
- * These two must be refs, not state!
759
- * Because we want to store the most recent shape of the animation in case we have to interrupt the animation;
760
- * that happens when user initiates another animation before the current one finishes.
761
- *
762
- * If this was a useState, then every step in the animation would trigger a re-render.
763
- * So, useRef it is.
764
- */
774
+ * These two must be refs, not state!
775
+ * Because we want to store the most recent shape of the animation in case we have to interrupt the animation;
776
+ * that happens when user initiates another animation before the current one finishes.
777
+ *
778
+ * If this was a useState, then every step in the animation would trigger a re-render.
779
+ * So, useRef it is.
780
+ */
765
781
  const previousPointsRef = useRef<ReadonlyArray<AreaPointItem> | null>(null);
766
782
  const previousBaselineRef = useRef<BaseLineType | undefined>(undefined);
767
783
 
768
- return <AreaWithAnimation
769
- needClip={needClip}
770
- clipPathId={clipPathId}
771
- props={props}
772
- previousPointsRef={previousPointsRef}
773
- previousBaselineRef={previousBaselineRef}
774
- />;
784
+ return (
785
+ <AreaWithAnimation
786
+ needClip={needClip}
787
+ clipPathId={clipPathId}
788
+ props={props}
789
+ previousPointsRef={previousPointsRef}
790
+ previousBaselineRef={previousBaselineRef}
791
+ />
792
+ );
775
793
  }
776
794
 
777
795
  function AreaWithState(props: InternalProps) {
@@ -805,39 +823,44 @@ function AreaWithState(props: InternalProps) {
805
823
  ? `url(#clipPath-${clipDot ? '' : 'dots-'}${clipPathId})`
806
824
  : undefined;
807
825
 
808
- return <ZIndexLayer zIndex={zIndex}>
809
- <Layer className={layerClass}>
810
- {needClip &&
811
- <defs>
812
- <GraphicalItemClipPath clipPathId={clipPathId} xAxisId={xAxisId} yAxisId={yAxisId} />
813
- {!clipDot &&
814
- <clipPath id={`clipPath-dots-${clipPathId}`}>
815
- <rect
816
- x={left - dotSize / 2}
817
- y={top - dotSize / 2}
818
- width={width + dotSize}
819
- height={height + dotSize}
820
- />
821
- </clipPath>}
822
- </defs>}
823
- <RenderArea needClip={needClip} clipPathId={clipPathId} props={props} />
824
- </Layer>
825
- <ActivePoints
826
- points={points}
827
- mainColor={getLegendItemColor(props.stroke, props.fill)}
828
- itemDataKey={props.dataKey}
829
- activeDot={props.activeDot}
830
- clipPath={activePointsClipPath}
831
- />
832
- {props.isRange && Array.isArray(baseLine) &&
826
+ return (
827
+ <ZIndexLayer zIndex={zIndex}>
828
+ <Layer className={layerClass}>
829
+ {needClip && (
830
+ <defs>
831
+ <GraphicalItemClipPath clipPathId={clipPathId} xAxisId={xAxisId} yAxisId={yAxisId} />
832
+ {!clipDot && (
833
+ <clipPath id={`clipPath-dots-${clipPathId}`}>
834
+ <rect
835
+ x={left - dotSize / 2}
836
+ y={top - dotSize / 2}
837
+ width={width + dotSize}
838
+ height={height + dotSize}
839
+ />
840
+ </clipPath>
841
+ )}
842
+ </defs>
843
+ )}
844
+ <RenderArea needClip={needClip} clipPathId={clipPathId} props={props} />
845
+ </Layer>
833
846
  <ActivePoints
834
- points={baseLine}
847
+ points={points}
835
848
  mainColor={getLegendItemColor(props.stroke, props.fill)}
836
849
  itemDataKey={props.dataKey}
837
850
  activeDot={props.activeDot}
838
851
  clipPath={activePointsClipPath}
839
- />}
840
- </ZIndexLayer>;
852
+ />
853
+ {props.isRange && Array.isArray(baseLine) && (
854
+ <ActivePoints
855
+ points={baseLine}
856
+ mainColor={getLegendItemColor(props.stroke, props.fill)}
857
+ itemDataKey={props.dataKey}
858
+ activeDot={props.activeDot}
859
+ clipPath={activePointsClipPath}
860
+ />
861
+ )}
862
+ </ZIndexLayer>
863
+ );
841
864
  }
842
865
 
843
866
  function AreaImpl<DataPointType, ValueAxisType>(
@@ -869,7 +892,7 @@ function AreaImpl<DataPointType, ValueAxisType>(
869
892
  useAppSelector((state) => selectArea(state, props.id, isPanorama)) ?? {};
870
893
  const plotArea = usePlotArea();
871
894
 
872
- if (layout !== 'horizontal' && layout !== 'vertical' || plotArea == null) {
895
+ if ((layout !== 'horizontal' && layout !== 'vertical') || plotArea == null) {
873
896
  // Can't render Area in an unsupported layout
874
897
  return null;
875
898
  }
@@ -885,32 +908,34 @@ function AreaImpl<DataPointType, ValueAxisType>(
885
908
  return null;
886
909
  }
887
910
 
888
- return <AreaWithState
889
- {...everythingElse}
890
- activeDot={activeDot}
891
- animationBegin={animationBegin}
892
- animationDuration={animationDuration}
893
- animationEasing={animationEasing}
894
- baseLine={baseLine}
895
- connectNulls={connectNulls}
896
- dot={dot}
897
- fill={fill}
898
- fillOpacity={fillOpacity}
899
- height={height}
900
- hide={hide}
901
- layout={layout}
902
- isAnimationActive={isAnimationActive}
903
- isRange={isRange}
904
- legendType={legendType}
905
- needClip={needClip}
906
- points={points}
907
- stroke={stroke}
908
- width={width}
909
- left={left}
910
- top={top}
911
- xAxisId={xAxisId}
912
- yAxisId={yAxisId}
913
- />;
911
+ return (
912
+ <AreaWithState
913
+ {...everythingElse}
914
+ activeDot={activeDot}
915
+ animationBegin={animationBegin}
916
+ animationDuration={animationDuration}
917
+ animationEasing={animationEasing}
918
+ baseLine={baseLine}
919
+ connectNulls={connectNulls}
920
+ dot={dot}
921
+ fill={fill}
922
+ fillOpacity={fillOpacity}
923
+ height={height}
924
+ hide={hide}
925
+ layout={layout}
926
+ isAnimationActive={isAnimationActive}
927
+ isRange={isRange}
928
+ legendType={legendType}
929
+ needClip={needClip}
930
+ points={points}
931
+ stroke={stroke}
932
+ width={width}
933
+ left={left}
934
+ top={top}
935
+ xAxisId={xAxisId}
936
+ yAxisId={yAxisId}
937
+ />
938
+ );
914
939
  }
915
940
 
916
941
  export const getBaseValue = (
@@ -928,8 +953,7 @@ export const getBaseValue = (
928
953
  return baseValue;
929
954
  }
930
955
 
931
- const numericAxis =
932
- layout === 'horizontal' ? yAxis : xAxis;
956
+ const numericAxis = layout === 'horizontal' ? yAxis : xAxis;
933
957
  const domain = numericAxis.scale.domain() as readonly [number, number];
934
958
 
935
959
  if (numericAxis.type === 'number') {
@@ -1005,19 +1029,19 @@ export function computeArea({
1005
1029
  const value1 = valueAsArray?.[1] ?? null;
1006
1030
 
1007
1031
  const isBreakPoint =
1008
- value1 == null || hasStack && !connectNulls && getValueByDataKey(entry, dataKey) == null;
1032
+ value1 == null || (hasStack && !connectNulls && getValueByDataKey(entry, dataKey) == null);
1009
1033
 
1010
1034
  if (isHorizontalLayout) {
1011
1035
  return {
1012
1036
  x: getCateCoordinateOfLine({ axis: xAxis, ticks: xAxisTicks, bandSize, entry, index }),
1013
- y: isBreakPoint ? null : yAxis.scale.map(value1) ?? null,
1037
+ y: isBreakPoint ? null : (yAxis.scale.map(value1) ?? null),
1014
1038
  value: valueAsArray,
1015
1039
  payload: entry,
1016
1040
  };
1017
1041
  }
1018
1042
 
1019
1043
  return {
1020
- x: isBreakPoint ? null : xAxis.scale.map(value1) ?? null,
1044
+ x: isBreakPoint ? null : (xAxis.scale.map(value1) ?? null),
1021
1045
  y: getCateCoordinateOfLine({ axis: yAxis, ticks: yAxisTicks, bandSize, entry, index }),
1022
1046
  value: valueAsArray,
1023
1047
  payload: entry,
@@ -1031,12 +1055,12 @@ export function computeArea({
1031
1055
  if (isHorizontalLayout) {
1032
1056
  return {
1033
1057
  x: entry.x,
1034
- y: x != null && entry.y != null ? yAxis.scale.map(x) ?? null : null,
1058
+ y: x != null && entry.y != null ? (yAxis.scale.map(x) ?? null) : null,
1035
1059
  payload: entry.payload,
1036
1060
  };
1037
1061
  }
1038
1062
  return {
1039
- x: x != null ? xAxis.scale.map(x) ?? null : null,
1063
+ x: x != null ? (xAxis.scale.map(x) ?? null) : null,
1040
1064
  y: entry.y,
1041
1065
  payload: entry.payload,
1042
1066
  };
@@ -1058,40 +1082,44 @@ function AreaFn<DataPointType = any, ValueAxisType = any>(
1058
1082
  const props = resolveDefaultProps(outsideProps, defaultAreaProps);
1059
1083
  const isPanorama = useIsPanorama();
1060
1084
  // Report all props to Redux store first, before calling hooks, to avoid circular dependencies.
1061
- return <RegisterGraphicalItemId id={props.id} type="area">
1062
- {(id) => <>
1063
- <SetLegendPayload legendPayload={computeLegendPayloadFromAreaData(props)} />
1064
- <SetAreaTooltipEntrySettings
1065
- dataKey={props.dataKey}
1066
- data={props.data}
1067
- stroke={props.stroke}
1068
- strokeWidth={props.strokeWidth}
1069
- fill={props.fill}
1070
- name={props.name}
1071
- hide={props.hide}
1072
- unit={props.unit}
1073
- formatter={props.formatter}
1074
- tooltipType={props.tooltipType}
1075
- id={id}
1076
- />
1077
- <SetCartesianGraphicalItem
1078
- type="area"
1079
- id={id}
1080
- data={props.data}
1081
- dataKey={props.dataKey}
1082
- xAxisId={props.xAxisId}
1083
- yAxisId={props.yAxisId}
1084
- zAxisId={0}
1085
- stackId={getNormalizedStackId(props.stackId)}
1086
- hide={props.hide}
1087
- barSize={undefined}
1088
- baseValue={props.baseValue}
1089
- isPanorama={isPanorama}
1090
- connectNulls={props.connectNulls}
1091
- />
1092
- <AreaImpl {...props} id={id} />
1093
- </>}
1094
- </RegisterGraphicalItemId>;
1085
+ return (
1086
+ <RegisterGraphicalItemId id={props.id} type="area">
1087
+ {(id) => (
1088
+ <>
1089
+ <SetLegendPayload legendPayload={computeLegendPayloadFromAreaData(props)} />
1090
+ <SetAreaTooltipEntrySettings
1091
+ dataKey={props.dataKey}
1092
+ data={props.data}
1093
+ stroke={props.stroke}
1094
+ strokeWidth={props.strokeWidth}
1095
+ fill={props.fill}
1096
+ name={props.name}
1097
+ hide={props.hide}
1098
+ unit={props.unit}
1099
+ formatter={props.formatter}
1100
+ tooltipType={props.tooltipType}
1101
+ id={id}
1102
+ />
1103
+ <SetCartesianGraphicalItem
1104
+ type="area"
1105
+ id={id}
1106
+ data={props.data}
1107
+ dataKey={props.dataKey}
1108
+ xAxisId={props.xAxisId}
1109
+ yAxisId={props.yAxisId}
1110
+ zAxisId={0}
1111
+ stackId={getNormalizedStackId(props.stackId)}
1112
+ hide={props.hide}
1113
+ barSize={undefined}
1114
+ baseValue={props.baseValue}
1115
+ isPanorama={isPanorama}
1116
+ connectNulls={props.connectNulls}
1117
+ />
1118
+ <AreaImpl {...props} id={id} />
1119
+ </>
1120
+ )}
1121
+ </RegisterGraphicalItemId>
1122
+ );
1095
1123
  }
1096
1124
 
1097
1125
  /**