@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,38 +91,38 @@ import { CellsContext, useCellRegistry } from '../context/CellsContext';
91
91
 
92
92
  interface PieDef {
93
93
  /**
94
- * The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width.
95
- */
94
+ * The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container width.
95
+ */
96
96
  cx?: number | string;
97
97
  /**
98
- * The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height.
99
- */
98
+ * The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of container height.
99
+ */
100
100
  cy?: number | string;
101
101
  /**
102
- * Angle in degrees from which the chart should start.
103
- */
102
+ * Angle in degrees from which the chart should start.
103
+ */
104
104
  startAngle?: number;
105
105
  /**
106
- * Angle, in degrees, at which the chart should end.
107
- */
106
+ * Angle, in degrees, at which the chart should end.
107
+ */
108
108
  endAngle?: number;
109
109
  /**
110
- * The angle between two sectors.
111
- *
112
- * @example <Pie paddingAngle={5} />
113
- * @example https://recharts.github.io/examples/PieChartWithPaddingAngle
114
- */
110
+ * The angle between two sectors.
111
+ *
112
+ * @example <Pie paddingAngle={5} />
113
+ * @example https://recharts.github.io/examples/PieChartWithPaddingAngle
114
+ */
115
115
  paddingAngle?: number;
116
116
  /**
117
- * The inner radius of the sectors.
118
- * If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy.
119
- */
117
+ * The inner radius of the sectors.
118
+ * If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy.
119
+ */
120
120
  innerRadius?: number | string;
121
121
  /**
122
- * The outer radius of the sectors.
123
- * If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy.
124
- * Function should return a string percentage or number.
125
- */
122
+ * The outer radius of the sectors.
123
+ * If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy.
124
+ * Function should return a string percentage or number.
125
+ */
126
126
  outerRadius?: number | string | ((dataPoint: any) => number | string);
127
127
  cornerRadius?: number | string;
128
128
  }
@@ -139,14 +139,14 @@ interface PieLabelExtraProps {
139
139
  textAnchor: TextAnchor;
140
140
  }
141
141
 
142
- export type PieLabelRenderProps =
143
- Omit<SVGPropsNoEvents<PieSvgAttributes>, 'offset'> & Omit<
144
- PieSectorDataItem,
145
- 'offset' | 'ref'
146
- > & Pick<SVGProps<SVGTextElement>, 'ref'> & PieLabelExtraProps & Coordinate;
142
+ export type PieLabelRenderProps = Omit<SVGPropsNoEvents<PieSvgAttributes>, 'offset'> &
143
+ Omit<PieSectorDataItem, 'offset' | 'ref'> &
144
+ Pick<SVGProps<SVGTextElement>, 'ref'> &
145
+ PieLabelExtraProps &
146
+ Coordinate;
147
147
 
148
- export type LabelListPropsWithPosition =
149
- Omit<LabelListProps, keyof PieCoordinate> & Partial<PieCoordinate> & {
148
+ export type LabelListPropsWithPosition = Omit<LabelListProps, keyof PieCoordinate> &
149
+ Partial<PieCoordinate> & {
150
150
  position: LabelListProps['position'];
151
151
  };
152
152
 
@@ -155,34 +155,30 @@ export type LabelListPropsWithPosition =
155
155
  */
156
156
  export type PieLabel =
157
157
  /*
158
- * If label prop is false, labels don't show.
159
- * If label prop is true, labels will be rendered with default props.
160
- */
161
- | boolean
162
- | /*
163
- * If label prop is an object, and it contains a `position` prop,
164
- * the object will become props to a <LabelList /> component.
165
- */
166
- LabelListPropsWithPosition
167
- | /*
168
- * If label prop is an object, and it does not have a `position` prop,
169
- * this renders a special Pie label that is similar to <Label position="outside"> and supports an optional labelLine.
170
- * labelLine is a small line connecting the sector to the label.
171
- */
172
- Partial<PieLabelRenderProps>
173
- | /*
174
- * If label prop is a function, or a React component, it will be called once for each label.
175
- * The result of each call will be rendered.
176
- */
177
- ((props: PieLabelRenderProps) => RenderableText | OctaneElement<PieLabelRenderProps>)
178
- | /*
179
- * If label prop is a OctaneElement, it will get cloned and receive brand-new surprise props.
180
- * I do not recommend this variant
181
- */
182
- OctaneElement<PieLabelRenderProps>;
183
-
184
- export type PieSectorData =
185
- GeometrySector & TooltipTriggerInfo & {
158
+ * If label prop is false, labels don't show.
159
+ * If label prop is true, labels will be rendered with default props.
160
+ */
161
+ | boolean /*
162
+ * If label prop is an object, and it contains a `position` prop,
163
+ * the object will become props to a <LabelList /> component.
164
+ */
165
+ | LabelListPropsWithPosition /*
166
+ * If label prop is an object, and it does not have a `position` prop,
167
+ * this renders a special Pie label that is similar to <Label position="outside"> and supports an optional labelLine.
168
+ * labelLine is a small line connecting the sector to the label.
169
+ */
170
+ | Partial<PieLabelRenderProps> /*
171
+ * If label prop is a function, or a React component, it will be called once for each label.
172
+ * The result of each call will be rendered.
173
+ */
174
+ | ((props: PieLabelRenderProps) => RenderableText | OctaneElement<PieLabelRenderProps>) /*
175
+ * If label prop is a OctaneElement, it will get cloned and receive brand-new surprise props.
176
+ * I do not recommend this variant
177
+ */
178
+ | OctaneElement<PieLabelRenderProps>;
179
+
180
+ export type PieSectorData = GeometrySector &
181
+ TooltipTriggerInfo & {
186
182
  dataKey?: DataKey<any>;
187
183
  midAngle?: number;
188
184
  middleRadius?: number;
@@ -203,13 +199,14 @@ export type PieSectorData =
203
199
  * https://github.com/recharts/recharts/issues/6380
204
200
  * https://github.com/recharts/recharts/discussions/6375
205
201
  */
206
- export type PieSectorDataItem =
207
- PiePresentationProps & PieCoordinate & PieSectorData & {
202
+ export type PieSectorDataItem = PiePresentationProps &
203
+ PieCoordinate &
204
+ PieSectorData & {
208
205
  cornerRadius: number | undefined;
209
206
  };
210
207
 
211
- export type PieSectorShapeProps =
212
- PieSectorDataItem & ShapeAnimationProps & {
208
+ export type PieSectorShapeProps = PieSectorDataItem &
209
+ ShapeAnimationProps & {
213
210
  [DATA_ITEM_INDEX_ATTRIBUTE_NAME]: number;
214
211
  [DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME]: GraphicalItemId;
215
212
  isActive: boolean;
@@ -219,62 +216,84 @@ export type PieShape = ActiveShape<PieSectorShapeProps, SVGPathElement>;
219
216
 
220
217
  interface PieEvents {
221
218
  /**
222
- * The customized event handler of click on the sectors in this group.
223
- */
224
- onClick?: (data: PieSectorDataItem, index: number, e: NativeMouseEvent<
225
- SVGGraphicsElement
226
- >) => void;
219
+ * The customized event handler of click on the sectors in this group.
220
+ */
221
+ onClick?: (
222
+ data: PieSectorDataItem,
223
+ index: number,
224
+ e: NativeMouseEvent<SVGGraphicsElement>,
225
+ ) => void;
227
226
  /**
228
- * The customized event handler of mousedown on the sectors in this group.
229
- */
230
- onMouseDown?: (data: PieSectorDataItem, index: number, e: NativeMouseEvent<
231
- SVGGraphicsElement
232
- >) => void;
227
+ * The customized event handler of mousedown on the sectors in this group.
228
+ */
229
+ onMouseDown?: (
230
+ data: PieSectorDataItem,
231
+ index: number,
232
+ e: NativeMouseEvent<SVGGraphicsElement>,
233
+ ) => void;
233
234
  /**
234
- * The customized event handler of mouseup on the sectors in this group.
235
- */
236
- onMouseUp?: (data: PieSectorDataItem, index: number, e: NativeMouseEvent<
237
- SVGGraphicsElement
238
- >) => void;
235
+ * The customized event handler of mouseup on the sectors in this group.
236
+ */
237
+ onMouseUp?: (
238
+ data: PieSectorDataItem,
239
+ index: number,
240
+ e: NativeMouseEvent<SVGGraphicsElement>,
241
+ ) => void;
239
242
  /**
240
- * The customized event handler of mousemove on the sectors in this group.
241
- */
242
- onMouseMove?: (data: PieSectorDataItem, index: number, e: NativeMouseEvent<
243
- SVGGraphicsElement
244
- >) => void;
243
+ * The customized event handler of mousemove on the sectors in this group.
244
+ */
245
+ onMouseMove?: (
246
+ data: PieSectorDataItem,
247
+ index: number,
248
+ e: NativeMouseEvent<SVGGraphicsElement>,
249
+ ) => void;
245
250
  /**
246
- * The customized event handler of mouseover on the sectors in this group.
247
- */
248
- onMouseOver?: (data: PieSectorDataItem, index: number, e: NativeMouseEvent<
249
- SVGGraphicsElement
250
- >) => void;
251
+ * The customized event handler of mouseover on the sectors in this group.
252
+ */
253
+ onMouseOver?: (
254
+ data: PieSectorDataItem,
255
+ index: number,
256
+ e: NativeMouseEvent<SVGGraphicsElement>,
257
+ ) => void;
251
258
  /**
252
- * The customized event handler of mouseout on the sectors in this group.
253
- */
254
- onMouseOut?: (data: PieSectorDataItem, index: number, e: NativeMouseEvent<
255
- SVGGraphicsElement
256
- >) => void;
259
+ * The customized event handler of mouseout on the sectors in this group.
260
+ */
261
+ onMouseOut?: (
262
+ data: PieSectorDataItem,
263
+ index: number,
264
+ e: NativeMouseEvent<SVGGraphicsElement>,
265
+ ) => void;
257
266
  /**
258
- * The customized event handler of mouseenter on the sectors in this group.
259
- */
260
- onMouseEnter?: (data: PieSectorDataItem, index: number, e: NativeMouseEvent<
261
- SVGGraphicsElement
262
- >) => void;
267
+ * The customized event handler of mouseenter on the sectors in this group.
268
+ */
269
+ onMouseEnter?: (
270
+ data: PieSectorDataItem,
271
+ index: number,
272
+ e: NativeMouseEvent<SVGGraphicsElement>,
273
+ ) => void;
263
274
  /**
264
- * The customized event handler of mouseleave on the sectors in this group.
265
- */
266
- onMouseLeave?: (data: PieSectorDataItem, index: number, e: NativeMouseEvent<
267
- SVGGraphicsElement
268
- >) => void;
269
- onTouchStart?: (data: PieSectorDataItem, index: number, e: NativeTouchEvent<
270
- SVGGraphicsElement
271
- >) => void;
272
- onTouchMove?: (data: PieSectorDataItem, index: number, e: NativeTouchEvent<
273
- SVGGraphicsElement
274
- >) => void;
275
- onTouchEnd?: (data: PieSectorDataItem, index: number, e: NativeTouchEvent<
276
- SVGGraphicsElement
277
- >) => void;
275
+ * The customized event handler of mouseleave on the sectors in this group.
276
+ */
277
+ onMouseLeave?: (
278
+ data: PieSectorDataItem,
279
+ index: number,
280
+ e: NativeMouseEvent<SVGGraphicsElement>,
281
+ ) => void;
282
+ onTouchStart?: (
283
+ data: PieSectorDataItem,
284
+ index: number,
285
+ e: NativeTouchEvent<SVGGraphicsElement>,
286
+ ) => void;
287
+ onTouchMove?: (
288
+ data: PieSectorDataItem,
289
+ index: number,
290
+ e: NativeTouchEvent<SVGGraphicsElement>,
291
+ ) => void;
292
+ onTouchEnd?: (
293
+ data: PieSectorDataItem,
294
+ index: number,
295
+ e: NativeTouchEvent<SVGGraphicsElement>,
296
+ ) => void;
278
297
  }
279
298
 
280
299
  /**
@@ -285,178 +304,184 @@ interface InternalPieProps extends PropsWithResolvedDefaults {
285
304
  sectors: ReadonlyArray<PieSectorDataItem>;
286
305
  }
287
306
 
288
- interface PieProps<DataPointType = any, DataValueType = any> extends DataProvider<
289
- DataPointType
290
- >, DataConsumer<DataPointType, DataValueType>, PieDef, PieEvents, ZIndexable {
307
+ interface PieProps<DataPointType = any, DataValueType = any>
308
+ extends
309
+ DataProvider<DataPointType>,
310
+ DataConsumer<DataPointType, DataValueType>,
311
+ PieDef,
312
+ PieEvents,
313
+ ZIndexable {
291
314
  /**
292
- * This component is rendered when this graphical item is activated
293
- * (could be by mouse hover, touch, keyboard, programmatically).
294
- *
295
- * @deprecated Use the `shape` prop to create each sector. `isActive` designates the "active" shape.
296
- * @example <Pie activeShape={<CustomActiveShape />} />
297
- * @example https://recharts.github.io/examples/CustomActiveShapePieChart
298
- */
315
+ * This component is rendered when this graphical item is activated
316
+ * (could be by mouse hover, touch, keyboard, programmatically).
317
+ *
318
+ * @deprecated Use the `shape` prop to create each sector. `isActive` designates the "active" shape.
319
+ * @example <Pie activeShape={<CustomActiveShape />} />
320
+ * @example https://recharts.github.io/examples/CustomActiveShapePieChart
321
+ */
299
322
  activeShape?: ActiveShape<PieSectorDataItem, SVGPathElement>;
300
323
  /**
301
- * Specifies when the animation should begin, the unit of this option is ms.
302
- * @defaultValue 400
303
- */
324
+ * Specifies when the animation should begin, the unit of this option is ms.
325
+ * @defaultValue 400
326
+ */
304
327
  animationBegin?: number;
305
328
  /**
306
- * Specifies the duration of animation, the unit of this option is ms.
307
- * @defaultValue 1500
308
- */
329
+ * Specifies the duration of animation, the unit of this option is ms.
330
+ * @defaultValue 1500
331
+ */
309
332
  animationDuration?: AnimationDuration;
310
333
  /**
311
- * The type of easing function.
312
- * @defaultValue ease
313
- */
334
+ * The type of easing function.
335
+ * @defaultValue ease
336
+ */
314
337
  animationEasing?: EasingInput;
315
338
  /**
316
- * Custom animation function for interpolating data items.
317
- * When provided, this replaces the default animation interpolation.
318
- *
319
- * @param prevItems The items from the previous animation frame, or null on first render
320
- * @param nextItems The target items to animate towards
321
- * @param animationElapsedTime A normalized time value (0 = start, 1 = end)
322
- * @returns The interpolated items at time animationElapsedTime
323
- *
324
- * @since 3.9
325
- * @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
326
- */
339
+ * Custom animation function for interpolating data items.
340
+ * When provided, this replaces the default animation interpolation.
341
+ *
342
+ * @param prevItems The items from the previous animation frame, or null on first render
343
+ * @param nextItems The target items to animate towards
344
+ * @param animationElapsedTime A normalized time value (0 = start, 1 = end)
345
+ * @returns The interpolated items at time animationElapsedTime
346
+ *
347
+ * @since 3.9
348
+ * @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
349
+ */
327
350
  animationInterpolateFn?: AnimationInterpolateFn<PieSectorDataItem, PolarLayout>;
328
351
  /**
329
- * Strategy for matching previous items to next items during animation.
330
- * Determines how Recharts pairs old data points with new data points
331
- * to create smooth transitions.
332
- *
333
- * - `matchAppend` (default): match sequentially by index and treat newly appended items as new
334
- * - `matchByIndex`: match by array position with proportional stretching
335
- * - `matchByDataKey('someKey')`: match by a data key from the payload
336
- * - Custom function `(item, index) => key`: match by the returned key
337
- *
338
- * @defaultValue append
339
- * @see matchByIndex
340
- * @see matchByDataKey
341
- * @see matchAppend
342
- *
343
- * @since 3.9
344
- * @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
345
- */
352
+ * Strategy for matching previous items to next items during animation.
353
+ * Determines how Recharts pairs old data points with new data points
354
+ * to create smooth transitions.
355
+ *
356
+ * - `matchAppend` (default): match sequentially by index and treat newly appended items as new
357
+ * - `matchByIndex`: match by array position with proportional stretching
358
+ * - `matchByDataKey('someKey')`: match by a data key from the payload
359
+ * - Custom function `(item, index) => key`: match by the returned key
360
+ *
361
+ * @defaultValue append
362
+ * @see matchByIndex
363
+ * @see matchByDataKey
364
+ * @see matchAppend
365
+ *
366
+ * @since 3.9
367
+ * @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
368
+ */
346
369
  animationMatchBy?: AnimationMatchByProp<PieSectorDataItem>;
347
370
  className?: string;
348
371
  /**
349
- * Hides the whole graphical element when true.
350
- *
351
- * Hiding an element is different from removing it from the chart:
352
- * Hidden graphical elements are still visible in Legend,
353
- * and can be included in axis domain calculations,
354
- * depending on `includeHidden` props of your XAxis/YAxis.
355
- *
356
- * @defaultValue false
357
- */
372
+ * Hides the whole graphical element when true.
373
+ *
374
+ * Hiding an element is different from removing it from the chart:
375
+ * Hidden graphical elements are still visible in Legend,
376
+ * and can be included in axis domain calculations,
377
+ * depending on `includeHidden` props of your XAxis/YAxis.
378
+ *
379
+ * @defaultValue false
380
+ */
358
381
  hide?: boolean;
359
382
  id?: string;
360
383
  /**
361
- * The shape of inactive sector.
362
- * @deprecated Use the `shape` prop to modify each sector.
363
- */
384
+ * The shape of inactive sector.
385
+ * @deprecated Use the `shape` prop to modify each sector.
386
+ */
364
387
  inactiveShape?: ActiveShape<PieSectorDataItem, SVGPathElement>;
365
388
  /**
366
- * If set false, animation will be disabled.
367
- * If set "auto", the animation will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility.
368
- * @defaultValue auto
369
- */
389
+ * If set false, animation will be disabled.
390
+ * If set "auto", the animation will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility.
391
+ * @defaultValue auto
392
+ */
370
393
  isAnimationActive?: boolean | 'auto';
371
394
  /**
372
- * Renders one label for each pie sector. Options:
373
- * - `true`: renders default labels;
374
- * - `false`: no labels are rendered;
375
- * - `object` that has `position` prop: the props of LabelList component;
376
- * - `object` that does not have `position` prop: the props of a custom Pie label (similar to Label with position "outside"); this variant supports `labelLine`
377
- * - `OctaneElement`: a custom SVG label element, such as `<text>` or `<g>`.
378
- * HTML elements such as `<div>` are not valid inside the chart SVG and may trigger React DOM warnings.
379
- * - `function`: a render function of custom label.
380
- *
381
- * Also see the `labelLine` prop that draws a line connecting each label to the corresponding sector.
382
- *
383
- * @defaultValue false
384
- * @example <Pie label={<CustomizedLabel />} />
385
- * @example https://recharts.github.io/examples/PieChartWithCustomizedLabel
386
- */
395
+ * Renders one label for each pie sector. Options:
396
+ * - `true`: renders default labels;
397
+ * - `false`: no labels are rendered;
398
+ * - `object` that has `position` prop: the props of LabelList component;
399
+ * - `object` that does not have `position` prop: the props of a custom Pie label (similar to Label with position "outside"); this variant supports `labelLine`
400
+ * - `OctaneElement`: a custom SVG label element, such as `<text>` or `<g>`.
401
+ * HTML elements such as `<div>` are not valid inside the chart SVG and may trigger React DOM warnings.
402
+ * - `function`: a render function of custom label.
403
+ *
404
+ * Also see the `labelLine` prop that draws a line connecting each label to the corresponding sector.
405
+ *
406
+ * @defaultValue false
407
+ * @example <Pie label={<CustomizedLabel />} />
408
+ * @example https://recharts.github.io/examples/PieChartWithCustomizedLabel
409
+ */
387
410
  label?: PieLabel;
388
411
  /**
389
- * If false set, label lines will not be drawn. If true set, label lines will be drawn which have the props calculated internally.
390
- * If object set, label lines will be drawn which have the props merged by the internal calculated props and the option.
391
- * If OctaneElement set, the option can be the custom label line element.
392
- * If set a function, the function will be called to render customized label line.
393
- * @defaultValue true
394
- * @example <Pie labelLine={<CustomizedLabelLine />} />
395
- * @example https://recharts.github.io/examples/PieChartWithCustomizedLabel
396
- */
412
+ * If false set, label lines will not be drawn. If true set, label lines will be drawn which have the props calculated internally.
413
+ * If object set, label lines will be drawn which have the props merged by the internal calculated props and the option.
414
+ * If OctaneElement set, the option can be the custom label line element.
415
+ * If set a function, the function will be called to render customized label line.
416
+ * @defaultValue true
417
+ * @example <Pie labelLine={<CustomizedLabelLine />} />
418
+ * @example https://recharts.github.io/examples/PieChartWithCustomizedLabel
419
+ */
397
420
  labelLine?: PieLabelLine;
398
421
  /**
399
- * The type of icon in legend. If set to 'none', no legend item will be rendered.
400
- * @defaultValue rect
401
- */
422
+ * The type of icon in legend. If set to 'none', no legend item will be rendered.
423
+ * @defaultValue rect
424
+ */
402
425
  legendType?: LegendType;
403
426
  /** the max radius of pie */
404
427
  maxRadius?: number;
405
428
  /**
406
- * The minimum angle of each unzero data.
407
- * @defaultValue 0
408
- */
429
+ * The minimum angle of each unzero data.
430
+ * @defaultValue 0
431
+ */
409
432
  minAngle?: number;
410
433
  /**
411
- * Name represents each sector in the tooltip, and legend.
412
- * This allows you to extract the name from the data:
413
- *
414
- * - `string`: the name of the field in the data object;
415
- * - `number`: the index of the field in the data;
416
- * - `function`: a function that receives the data object and returns the name.
417
- *
418
- * @defaultValue name
419
- */
434
+ * Name represents each sector in the tooltip, and legend.
435
+ * This allows you to extract the name from the data:
436
+ *
437
+ * - `string`: the name of the field in the data object;
438
+ * - `number`: the index of the field in the data;
439
+ * - `function`: a function that receives the data object and returns the name.
440
+ *
441
+ * @defaultValue name
442
+ */
420
443
  nameKey?: DataKey<DataPointType, DataValueType>;
421
444
  /**
422
- * The customized event handler of animation end.
423
- */
445
+ * The customized event handler of animation end.
446
+ */
424
447
  onAnimationEnd?: () => void;
425
448
  /**
426
- * The customized event handler of animation start.
427
- */
449
+ * The customized event handler of animation start.
450
+ */
428
451
  onAnimationStart?: () => void;
429
452
  /**
430
- * The tabindex of wrapper surrounding the cells.
431
- * @defaultValue 0
432
- */
453
+ * The tabindex of wrapper surrounding the cells.
454
+ * @defaultValue 0
455
+ */
433
456
  rootTabIndex?: number;
434
457
  /**
435
- * The custom shape of a Pie Sector.
436
- * Can also be used to render active sector by checking isActive.
437
- * During animations, the function shape also receives `animationElapsedTime`, `isAnimating`, and `isEntrance`.
438
- * If undefined, renders {@link Sector} shape.
439
- */
458
+ * The custom shape of a Pie Sector.
459
+ * Can also be used to render active sector by checking isActive.
460
+ * During animations, the function shape also receives `animationElapsedTime`, `isAnimating`, and `isEntrance`.
461
+ * If undefined, renders {@link Sector} shape.
462
+ */
440
463
  shape?: PieShape;
441
464
  tooltipType?: TooltipType;
442
465
  /**
443
- * Formats the value displayed in the tooltip for this Pie.
444
- * When set, takes precedence over the `formatter` prop on the Tooltip component.
445
- */
466
+ * Formats the value displayed in the tooltip for this Pie.
467
+ * When set, takes precedence over the `formatter` prop on the Tooltip component.
468
+ */
446
469
  formatter?: Formatter;
447
470
  /**
448
- * @defaultValue 100
449
- */
471
+ * @defaultValue 100
472
+ */
450
473
  zIndex?: number;
451
474
  }
452
475
 
453
- type PieSvgAttributes =
454
- Omit<PresentationAttributesAdaptChildEvent<any, SVGElement>, 'ref' | keyof PieEvents>;
476
+ type PieSvgAttributes = Omit<
477
+ PresentationAttributesAdaptChildEvent<any, SVGElement>,
478
+ 'ref' | keyof PieEvents
479
+ >;
455
480
 
456
481
  type InternalProps = PieSvgAttributes & InternalPieProps;
457
482
 
458
- export type Props<DataPointType = any, DataValueType = any> =
459
- PieSvgAttributes & PieProps<DataPointType, DataValueType>;
483
+ export type Props<DataPointType = any, DataValueType = any> = PieSvgAttributes &
484
+ PieProps<DataPointType, DataValueType>;
460
485
 
461
486
  type RealPieData = Record<string, unknown>;
462
487
 
@@ -482,28 +507,29 @@ function SetPiePayloadLegend(props: {
482
507
  return <SetPolarLegendPayload legendPayload={legendPayload} />;
483
508
  }
484
509
 
485
- type PieSectorsProps =
486
- ShapeAnimationProps & {
487
- sectors: Readonly<PieSectorDataItem[]>;
488
- /**
489
- * @deprecated
490
- */
491
- activeShape: ActiveShape<Readonly<PieSectorDataItem>, SVGPathElement> | undefined;
492
- /**
493
- * @deprecated
494
- */
495
- inactiveShape: ActiveShape<Readonly<PieSectorDataItem>, SVGPathElement> | undefined;
496
- shape: PieShape;
497
- allOtherPieProps: WithoutId<InternalProps>;
498
- id: GraphicalItemId;
499
- };
510
+ type PieSectorsProps = ShapeAnimationProps & {
511
+ sectors: Readonly<PieSectorDataItem[]>;
512
+ /**
513
+ * @deprecated
514
+ */
515
+ activeShape: ActiveShape<Readonly<PieSectorDataItem>, SVGPathElement> | undefined;
516
+ /**
517
+ * @deprecated
518
+ */
519
+ inactiveShape: ActiveShape<Readonly<PieSectorDataItem>, SVGPathElement> | undefined;
520
+ shape: PieShape;
521
+ allOtherPieProps: WithoutId<InternalProps>;
522
+ id: GraphicalItemId;
523
+ };
500
524
 
501
525
  function getActiveShapeFill(
502
526
  activeShape: ActiveShape<Readonly<PieSectorDataItem>, SVGPathElement> | undefined,
503
527
  ): string | undefined {
504
528
  // activeShape can be boolean/function/element/object; only element/object can carry a static fill value.
505
529
  if (
506
- activeShape == null || typeof activeShape === 'boolean' || typeof activeShape === 'function'
530
+ activeShape == null ||
531
+ typeof activeShape === 'boolean' ||
532
+ typeof activeShape === 'function'
507
533
  ) {
508
534
  return undefined;
509
535
  }
@@ -522,71 +548,71 @@ function getActiveShapeFill(
522
548
  return typeof fill === 'string' ? fill : undefined;
523
549
  }
524
550
 
525
- const SetPieTooltipEntrySettings = React.memo(({
526
- dataKey,
527
- nameKey,
528
- sectors,
529
- stroke,
530
- strokeWidth,
531
- fill,
532
- name,
533
- hide,
534
- tooltipType,
535
- formatter,
536
- id,
537
- activeShape,
538
- }: Pick<
539
- InternalProps,
540
- | 'dataKey'
541
- | 'nameKey'
542
- | 'sectors'
543
- | 'stroke'
544
- | 'strokeWidth'
545
- | 'fill'
546
- | 'name'
547
- | 'hide'
548
- | 'tooltipType'
549
- | 'formatter'
550
- | 'id'
551
- | 'activeShape'
552
- >) => {
553
- const activeShapeFill = getActiveShapeFill(activeShape);
554
-
555
- const tooltipDataDefinedOnItem = sectors.map((sector) => {
556
- const sectorTooltipPayload = sector.tooltipPayload;
557
- if (activeShapeFill == null || sectorTooltipPayload == null) {
558
- return sectorTooltipPayload;
559
- }
551
+ const SetPieTooltipEntrySettings = React.memo(
552
+ ({
553
+ dataKey,
554
+ nameKey,
555
+ sectors,
556
+ stroke,
557
+ strokeWidth,
558
+ fill,
559
+ name,
560
+ hide,
561
+ tooltipType,
562
+ formatter,
563
+ id,
564
+ activeShape,
565
+ }: Pick<
566
+ InternalProps,
567
+ | 'dataKey'
568
+ | 'nameKey'
569
+ | 'sectors'
570
+ | 'stroke'
571
+ | 'strokeWidth'
572
+ | 'fill'
573
+ | 'name'
574
+ | 'hide'
575
+ | 'tooltipType'
576
+ | 'formatter'
577
+ | 'id'
578
+ | 'activeShape'
579
+ >) => {
580
+ const activeShapeFill = getActiveShapeFill(activeShape);
581
+
582
+ const tooltipDataDefinedOnItem = sectors.map((sector) => {
583
+ const sectorTooltipPayload = sector.tooltipPayload;
584
+ if (activeShapeFill == null || sectorTooltipPayload == null) {
585
+ return sectorTooltipPayload;
586
+ }
560
587
 
561
- return sectorTooltipPayload.map(
562
- (item) => ({
588
+ return sectorTooltipPayload.map((item) => ({
563
589
  ...item,
564
590
  color: activeShapeFill,
565
591
  fill: activeShapeFill,
566
- }),
567
- );
568
- });
592
+ }));
593
+ });
569
594
 
570
- const tooltipEntrySettings: TooltipPayloadConfiguration = {
571
- dataDefinedOnItem: tooltipDataDefinedOnItem,
572
- getPosition: (index) => sectors[Number(index)]?.tooltipPosition,
573
- settings: {
574
- stroke,
575
- strokeWidth,
576
- fill,
577
- dataKey,
578
- nameKey,
579
- name: getTooltipNameProp(name, dataKey),
580
- hide,
581
- type: tooltipType,
582
- color: fill,
583
- unit: '', // why doesn't Pie support unit?
584
- formatter,
585
- graphicalItemId: id,
586
- },
587
- };
588
- return <SetTooltipEntrySettings tooltipEntrySettings={tooltipEntrySettings} />;
589
- });
595
+ const tooltipEntrySettings: TooltipPayloadConfiguration = {
596
+ dataDefinedOnItem: tooltipDataDefinedOnItem,
597
+ getPosition: (index) => sectors[Number(index)]?.tooltipPosition,
598
+ settings: {
599
+ stroke,
600
+ strokeWidth,
601
+ fill,
602
+ dataKey,
603
+ nameKey,
604
+ name: getTooltipNameProp(name, dataKey),
605
+ hide,
606
+ type: tooltipType,
607
+ color: fill,
608
+ unit: '', // why doesn't Pie support unit?
609
+ formatter,
610
+ graphicalItemId: id,
611
+ },
612
+ };
613
+ return <SetTooltipEntrySettings tooltipEntrySettings={tooltipEntrySettings} />;
614
+ },
615
+ );
590
616
 
591
617
  const getTextAnchor = (x: number, cx: number) => {
592
618
  if (x > cx) {
@@ -665,7 +691,11 @@ const renderLabelItem = (option: PieLabel, props: PieLabelRenderProps, value: Re
665
691
  }
666
692
 
667
693
  const className = clsx('recharts-pie-label-text', getClassNameFromUnknown(option));
668
- return <Text {...props} alignmentBaseline="middle" className={className}>{label}</Text>;
694
+ return (
695
+ <Text {...props} alignmentBaseline="middle" className={className}>
696
+ {label}
697
+ </Text>
698
+ );
669
699
  };
670
700
 
671
701
  function PieLabels({
@@ -685,10 +715,11 @@ function PieLabels({
685
715
  const customLabelProps = svgPropertiesNoEventsFromUnknown(label);
686
716
  const customLabelLineProps = svgPropertiesNoEventsFromUnknown(labelLine);
687
717
  const offsetRadius =
688
- typeof label === 'object' && 'offsetRadius' in label &&
718
+ (typeof label === 'object' &&
719
+ 'offsetRadius' in label &&
689
720
  typeof label.offsetRadius === 'number' &&
690
- label.offsetRadius ||
691
- 20;
721
+ label.offsetRadius) ||
722
+ 20;
692
723
 
693
724
  const labels = sectors.map((entry, i) => {
694
725
  // The Cell ref belongs to its sector, not to the label or connector.
@@ -721,19 +752,21 @@ function PieLabels({
721
752
  key: 'line',
722
753
  };
723
754
 
724
- return <ZIndexLayer
725
- zIndex={DefaultZIndexes.label}
726
- key={`label-${entry.startAngle}-${entry.endAngle}-${entry.midAngle}-${i}`}
727
- >
728
- <Layer>
729
- {labelLine && renderLabelLineItem(labelLine, lineProps)}
730
- {renderLabelItem(
731
- label,
732
- labelProps,
733
- getValueByDataKey<unknown, RenderableText>(entry, dataKey),
734
- )}
735
- </Layer>
736
- </ZIndexLayer>;
755
+ return (
756
+ <ZIndexLayer
757
+ zIndex={DefaultZIndexes.label}
758
+ key={`label-${entry.startAngle}-${entry.endAngle}-${entry.midAngle}-${i}`}
759
+ >
760
+ <Layer>
761
+ {labelLine && renderLabelLineItem(labelLine, lineProps)}
762
+ {renderLabelItem(
763
+ label,
764
+ labelProps,
765
+ getValueByDataKey<unknown, RenderableText>(entry, dataKey),
766
+ )}
767
+ </Layer>
768
+ </ZIndexLayer>
769
+ );
737
770
  });
738
771
 
739
772
  return <Layer className="recharts-pie-labels">{labels}</Layer>;
@@ -794,51 +827,54 @@ function PieSectors(props: PieSectorsProps) {
794
827
  return null;
795
828
  }
796
829
 
797
- return <>
798
- {sectors.map((entry: PieSectorDataItem, i: number) => {
799
- if (entry?.startAngle === 0 && entry?.endAngle === 0 && sectors.length !== 1) return null;
830
+ return (
831
+ <>
832
+ {sectors.map((entry: PieSectorDataItem, i: number) => {
833
+ if (entry?.startAngle === 0 && entry?.endAngle === 0 && sectors.length !== 1) return null;
800
834
 
801
- // For Pie charts, when multiple Pies share the same dataKey, we need to ensure only the hovered Pie's sector is active.
802
- // We do this by checking if the active graphical item ID matches this Pie's ID.
803
- const graphicalItemMatches = activeGraphicalItemId == null || activeGraphicalItemId === id;
835
+ // For Pie charts, when multiple Pies share the same dataKey, we need to ensure only the hovered Pie's sector is active.
836
+ // We do this by checking if the active graphical item ID matches this Pie's ID.
837
+ const graphicalItemMatches = activeGraphicalItemId == null || activeGraphicalItemId === id;
804
838
 
805
- const isActive =
806
- String(i) === activeIndex &&
839
+ const isActive =
840
+ String(i) === activeIndex &&
807
841
  (activeDataKey == null || allOtherPieProps.dataKey === activeDataKey) &&
808
842
  graphicalItemMatches;
809
- const inactiveShape = activeIndex ? inactiveShapeProp : null;
810
- const sectorOptions =
811
- activeShape && isActive ? activeShape : inactiveShape;
812
- const sectorProps: PieSectorShapeProps = {
813
- ...entry,
814
- stroke: entry.stroke,
815
- tabIndex: -1,
816
- index: i,
817
- isActive,
818
- animationElapsedTime,
819
- isAnimating,
820
- isEntrance,
821
- [DATA_ITEM_INDEX_ATTRIBUTE_NAME]: i,
822
- [DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME]: id,
823
- };
824
-
825
- return <Layer
826
- key={`sector-${entry?.startAngle}-${entry?.endAngle}-${entry.midAngle}-${i}`}
827
- tabIndex={-1}
828
- className="recharts-pie-sector"
829
- {...adaptEventsOfChild(restOfAllOtherProps, entry, i)}
830
- onMouseEnter={onMouseEnterFromContext(entry, i)}
831
- onMouseLeave={onMouseLeaveFromContext(entry, i)}
832
- onClick={onClickFromContext(entry, i)}
833
- >
834
- <PieSectorShape
835
- option={sectorOptions ?? shape}
836
- DefaultShape={defaultPieSectorShape}
837
- shapeProps={sectorProps}
838
- />
839
- </Layer>;
840
- })}
841
- </>;
843
+ const inactiveShape = activeIndex ? inactiveShapeProp : null;
844
+ const sectorOptions = activeShape && isActive ? activeShape : inactiveShape;
845
+ const sectorProps: PieSectorShapeProps = {
846
+ ...entry,
847
+ stroke: entry.stroke,
848
+ tabIndex: -1,
849
+ index: i,
850
+ isActive,
851
+ animationElapsedTime,
852
+ isAnimating,
853
+ isEntrance,
854
+ [DATA_ITEM_INDEX_ATTRIBUTE_NAME]: i,
855
+ [DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME]: id,
856
+ };
857
+
858
+ return (
859
+ <Layer
860
+ key={`sector-${entry?.startAngle}-${entry?.endAngle}-${entry.midAngle}-${i}`}
861
+ tabIndex={-1}
862
+ className="recharts-pie-sector"
863
+ {...adaptEventsOfChild(restOfAllOtherProps, entry, i)}
864
+ onMouseEnter={onMouseEnterFromContext(entry, i)}
865
+ onMouseLeave={onMouseLeaveFromContext(entry, i)}
866
+ onClick={onClickFromContext(entry, i)}
867
+ >
868
+ <PieSectorShape
869
+ option={sectorOptions ?? shape}
870
+ DefaultShape={defaultPieSectorShape}
871
+ shapeProps={sectorProps}
872
+ />
873
+ </Layer>
874
+ );
875
+ })}
876
+ </>
877
+ );
842
878
  }
843
879
 
844
880
  export function computePieSectors({
@@ -856,8 +892,7 @@ export function computePieSectors({
856
892
  const minAngle = Math.abs(pieSettings.minAngle);
857
893
  const deltaAngle = parseDeltaAngle(startAngle, endAngle);
858
894
  const absDeltaAngle = Math.abs(deltaAngle);
859
- const paddingAngle =
860
- displayedData.length <= 1 ? 0 : pieSettings.paddingAngle ?? 0;
895
+ const paddingAngle = displayedData.length <= 1 ? 0 : (pieSettings.paddingAngle ?? 0);
861
896
 
862
897
  const notZeroItemCount = displayedData.filter(
863
898
  (entry) => getValueByDataKey(entry, dataKey, 0) !== 0,
@@ -874,11 +909,14 @@ export function computePieSectors({
874
909
  // natural angle falls below the minAngle threshold. Otherwise, minAngle
875
910
  // unnecessarily shifts all segments even when none need the boost.
876
911
  // See: https://github.com/recharts/recharts/issues/6814
877
- const needsMinAngleAdjustment = minAngle > 0 && sum > 0 && displayedData.some((entry) => {
878
- const val = getValueByDataKey(entry, dataKey, 0);
879
- const percent = (isNumber(val) ? val : 0) / sum;
880
- return val !== 0 && percent * absDeltaAngle < minAngle;
881
- });
912
+ const needsMinAngleAdjustment =
913
+ minAngle > 0 &&
914
+ sum > 0 &&
915
+ displayedData.some((entry) => {
916
+ const val = getValueByDataKey(entry, dataKey, 0);
917
+ const percent = (isNumber(val) ? val : 0) / sum;
918
+ return val !== 0 && percent * absDeltaAngle < minAngle;
919
+ });
882
920
  const effectiveMinAngle = needsMinAngleAdjustment ? minAngle : 0;
883
921
 
884
922
  const realTotalAngle = absDeltaAngle - notZeroItemCount * effectiveMinAngle - totalPaddingAngle;
@@ -894,11 +932,12 @@ export function computePieSectors({
894
932
  let tempStartAngle;
895
933
 
896
934
  const entryWithCellInfo: RealPieData = {
897
- ...entry as Record<string, unknown>,
898
- ...cells && cells[i] && cells[i].props,
935
+ ...(entry as Record<string, unknown>),
936
+ ...(cells && cells[i] && cells[i].props),
899
937
  };
900
938
  const sectorColor =
901
- entryWithCellInfo != null && 'fill' in entryWithCellInfo &&
939
+ entryWithCellInfo != null &&
940
+ 'fill' in entryWithCellInfo &&
902
941
  typeof entryWithCellInfo.fill === 'string'
903
942
  ? entryWithCellInfo.fill
904
943
  : pieSettings.fill;
@@ -971,28 +1010,28 @@ function PieLabelListProvider({
971
1010
  if (!showLabels || !sectors) {
972
1011
  return [];
973
1012
  }
974
- return sectors.map(
975
- (entry): PolarLabelListEntry => ({
976
- value: entry.value,
977
- payload: entry.payload,
1013
+ return sectors.map((entry): PolarLabelListEntry => ({
1014
+ value: entry.value,
1015
+ payload: entry.payload,
1016
+ clockWise: false,
1017
+ parentViewBox: undefined,
1018
+ viewBox: {
1019
+ cx: entry.cx,
1020
+ cy: entry.cy,
1021
+ innerRadius: entry.innerRadius,
1022
+ outerRadius: entry.outerRadius,
1023
+ startAngle: entry.startAngle,
1024
+ endAngle: entry.endAngle,
978
1025
  clockWise: false,
979
- parentViewBox: undefined,
980
- viewBox: {
981
- cx: entry.cx,
982
- cy: entry.cy,
983
- innerRadius: entry.innerRadius,
984
- outerRadius: entry.outerRadius,
985
- startAngle: entry.startAngle,
986
- endAngle: entry.endAngle,
987
- clockWise: false,
988
- },
989
- fill: entry.fill,
990
- }),
991
- );
1026
+ },
1027
+ fill: entry.fill,
1028
+ }));
992
1029
  }, [sectors, showLabels]);
993
- return <PolarLabelListContextProvider
994
- value={showLabels ? labelListEntries : undefined}
995
- >{children}</PolarLabelListContextProvider>;
1030
+ return (
1031
+ <PolarLabelListContextProvider value={showLabels ? labelListEntries : undefined}>
1032
+ {children}
1033
+ </PolarLabelListContextProvider>
1034
+ );
996
1035
  }
997
1036
 
998
1037
  type WithoutId<T> = Omit<T, 'id'>;
@@ -1008,8 +1047,7 @@ const defaultPieAnimateItems: AnimationInterpolateFn<PieSectorDataItem, PolarLay
1008
1047
 
1009
1048
  items.forEach((item, index) => {
1010
1049
  if (item.status === 'removed') return;
1011
- const paddingAngle =
1012
- index > 0 ? get(item.next, 'paddingAngle', 0) : 0;
1050
+ const paddingAngle = index > 0 ? get(item.next, 'paddingAngle', 0) : 0;
1013
1051
 
1014
1052
  if (item.status === 'matched') {
1015
1053
  const angle = interpolate(
@@ -1077,39 +1115,43 @@ function SectorsWithAnimation({
1077
1115
 
1078
1116
  if (layout == null) return null;
1079
1117
 
1080
- return <PieLabelListProvider showLabels={!isAnimating} sectors={sectors}>
1081
- <AnimatedItems
1082
- animationInput={animationInput}
1083
- animationIdPrefix="recharts-pie-"
1084
- items={sectors}
1085
- previousItemsRef={previousSectorsRef}
1086
- isAnimationActive={props.isAnimationActive}
1087
- animationBegin={props.animationBegin}
1088
- animationDuration={props.animationDuration}
1089
- animationEasing={props.animationEasing}
1090
- onAnimationStart={handleAnimationStart}
1091
- onAnimationEnd={handleAnimationEnd}
1092
- animationInterpolateFn={animationInterpolateFn}
1093
- animationMatchBy={props.animationMatchBy}
1094
- layout={layout}
1095
- >
1096
- {(stepData, animationElapsedTime, isEntrance) => <Layer>
1097
- <PieSectors
1098
- sectors={stepData}
1099
- activeShape={activeShape}
1100
- inactiveShape={inactiveShape}
1101
- allOtherPieProps={props}
1102
- shape={props.shape}
1103
- id={id}
1104
- animationElapsedTime={animationElapsedTime}
1105
- isAnimating={isAnimating || animationElapsedTime < 1}
1106
- isEntrance={isEntrance}
1107
- />
1108
- </Layer>}
1109
- </AnimatedItems>
1110
- <PieLabelList showLabels={!isAnimating} sectors={sectors} props={props} />
1111
- {props.children}
1112
- </PieLabelListProvider>;
1118
+ return (
1119
+ <PieLabelListProvider showLabels={!isAnimating} sectors={sectors}>
1120
+ <AnimatedItems
1121
+ animationInput={animationInput}
1122
+ animationIdPrefix="recharts-pie-"
1123
+ items={sectors}
1124
+ previousItemsRef={previousSectorsRef}
1125
+ isAnimationActive={props.isAnimationActive}
1126
+ animationBegin={props.animationBegin}
1127
+ animationDuration={props.animationDuration}
1128
+ animationEasing={props.animationEasing}
1129
+ onAnimationStart={handleAnimationStart}
1130
+ onAnimationEnd={handleAnimationEnd}
1131
+ animationInterpolateFn={animationInterpolateFn}
1132
+ animationMatchBy={props.animationMatchBy}
1133
+ layout={layout}
1134
+ >
1135
+ {(stepData, animationElapsedTime, isEntrance) => (
1136
+ <Layer>
1137
+ <PieSectors
1138
+ sectors={stepData}
1139
+ activeShape={activeShape}
1140
+ inactiveShape={inactiveShape}
1141
+ allOtherPieProps={props}
1142
+ shape={props.shape}
1143
+ id={id}
1144
+ animationElapsedTime={animationElapsedTime}
1145
+ isAnimating={isAnimating || animationElapsedTime < 1}
1146
+ isEntrance={isEntrance}
1147
+ />
1148
+ </Layer>
1149
+ )}
1150
+ </AnimatedItems>
1151
+ <PieLabelList showLabels={!isAnimating} sectors={sectors} props={props} />
1152
+ {props.children}
1153
+ </PieLabelListProvider>
1154
+ );
1113
1155
  }
1114
1156
 
1115
1157
  export const defaultPieProps = {
@@ -1154,44 +1196,52 @@ function PieImpl(props: WithIdRequired<PropsWithResolvedDefaults>) {
1154
1196
 
1155
1197
  if (sectors == null) {
1156
1198
  previousSectorsRef.current = null;
1157
- return <CellsContext value={cellRegistry}>
1158
- <SetPiePayloadLegend cells={cells} id={id} />
1159
- <Layer tabIndex={rootTabIndex} className={layerClass}>{props.children}</Layer>
1160
- </CellsContext>;
1199
+ return (
1200
+ <CellsContext value={cellRegistry}>
1201
+ <SetPiePayloadLegend cells={cells} id={id} />
1202
+ <Layer tabIndex={rootTabIndex} className={layerClass}>
1203
+ {props.children}
1204
+ </Layer>
1205
+ </CellsContext>
1206
+ );
1161
1207
  }
1162
1208
 
1163
1209
  if (hide) {
1164
1210
  previousSectorsRef.current = null;
1165
1211
  }
1166
1212
 
1167
- return <CellsContext value={cellRegistry}>
1168
- <SetPiePayloadLegend cells={cells} id={id} />
1169
- <ZIndexLayer zIndex={props.zIndex}>
1170
- <SetPieTooltipEntrySettings
1171
- dataKey={props.dataKey}
1172
- nameKey={props.nameKey}
1173
- sectors={sectors}
1174
- stroke={props.stroke}
1175
- strokeWidth={props.strokeWidth}
1176
- fill={props.fill}
1177
- name={props.name}
1178
- hide={props.hide}
1179
- tooltipType={props.tooltipType}
1180
- formatter={props.formatter}
1181
- id={id}
1182
- activeShape={props.activeShape}
1183
- />
1184
- <Layer tabIndex={rootTabIndex} className={layerClass}>
1185
- {!hide
1186
- ? <SectorsWithAnimation
1213
+ return (
1214
+ <CellsContext value={cellRegistry}>
1215
+ <SetPiePayloadLegend cells={cells} id={id} />
1216
+ <ZIndexLayer zIndex={props.zIndex}>
1217
+ <SetPieTooltipEntrySettings
1218
+ dataKey={props.dataKey}
1219
+ nameKey={props.nameKey}
1220
+ sectors={sectors}
1221
+ stroke={props.stroke}
1222
+ strokeWidth={props.strokeWidth}
1223
+ fill={props.fill}
1224
+ name={props.name}
1225
+ hide={props.hide}
1226
+ tooltipType={props.tooltipType}
1227
+ formatter={props.formatter}
1228
+ id={id}
1229
+ activeShape={props.activeShape}
1230
+ />
1231
+ <Layer tabIndex={rootTabIndex} className={layerClass}>
1232
+ {!hide ? (
1233
+ <SectorsWithAnimation
1187
1234
  props={{ ...propsWithoutId, sectors }}
1188
1235
  previousSectorsRef={previousSectorsRef}
1189
1236
  id={id}
1190
1237
  />
1191
- : props.children}
1192
- </Layer>
1193
- </ZIndexLayer>
1194
- </CellsContext>;
1238
+ ) : (
1239
+ props.children
1240
+ )}
1241
+ </Layer>
1242
+ </ZIndexLayer>
1243
+ </CellsContext>
1244
+ );
1195
1245
  }
1196
1246
 
1197
1247
  type PropsWithResolvedDefaults = RequiresDefaultProps<Props, typeof defaultPieProps>;
@@ -1211,36 +1261,40 @@ function PieFn<DataPointType = any, DataValueType = any>(
1211
1261
  const { id: externalId, ...propsWithoutId } = props;
1212
1262
  const presentationProps: PiePresentationProps | null = svgPropertiesNoEvents(propsWithoutId);
1213
1263
 
1214
- return <RegisterGraphicalItemId id={externalId} type="pie">
1215
- {(id) => <>
1216
- <SetPolarGraphicalItem
1217
- type="pie"
1218
- id={id}
1219
- data={propsWithoutId.data}
1220
- dataKey={propsWithoutId.dataKey}
1221
- hide={propsWithoutId.hide}
1222
- angleAxisId={0}
1223
- radiusAxisId={0}
1224
- name={propsWithoutId.name}
1225
- nameKey={propsWithoutId.nameKey}
1226
- tooltipType={propsWithoutId.tooltipType}
1227
- legendType={propsWithoutId.legendType}
1228
- fill={propsWithoutId.fill}
1229
- cx={propsWithoutId.cx}
1230
- cy={propsWithoutId.cy}
1231
- startAngle={propsWithoutId.startAngle}
1232
- endAngle={propsWithoutId.endAngle}
1233
- paddingAngle={propsWithoutId.paddingAngle}
1234
- minAngle={propsWithoutId.minAngle}
1235
- innerRadius={propsWithoutId.innerRadius}
1236
- outerRadius={propsWithoutId.outerRadius}
1237
- cornerRadius={propsWithoutId.cornerRadius}
1238
- presentationProps={presentationProps}
1239
- maxRadius={props.maxRadius}
1240
- />
1241
- <PieImpl {...propsWithoutId} id={id} />
1242
- </>}
1243
- </RegisterGraphicalItemId>;
1264
+ return (
1265
+ <RegisterGraphicalItemId id={externalId} type="pie">
1266
+ {(id) => (
1267
+ <>
1268
+ <SetPolarGraphicalItem
1269
+ type="pie"
1270
+ id={id}
1271
+ data={propsWithoutId.data}
1272
+ dataKey={propsWithoutId.dataKey}
1273
+ hide={propsWithoutId.hide}
1274
+ angleAxisId={0}
1275
+ radiusAxisId={0}
1276
+ name={propsWithoutId.name}
1277
+ nameKey={propsWithoutId.nameKey}
1278
+ tooltipType={propsWithoutId.tooltipType}
1279
+ legendType={propsWithoutId.legendType}
1280
+ fill={propsWithoutId.fill}
1281
+ cx={propsWithoutId.cx}
1282
+ cy={propsWithoutId.cy}
1283
+ startAngle={propsWithoutId.startAngle}
1284
+ endAngle={propsWithoutId.endAngle}
1285
+ paddingAngle={propsWithoutId.paddingAngle}
1286
+ minAngle={propsWithoutId.minAngle}
1287
+ innerRadius={propsWithoutId.innerRadius}
1288
+ outerRadius={propsWithoutId.outerRadius}
1289
+ cornerRadius={propsWithoutId.cornerRadius}
1290
+ presentationProps={presentationProps}
1291
+ maxRadius={props.maxRadius}
1292
+ />
1293
+ <PieImpl {...propsWithoutId} id={id} />
1294
+ </>
1295
+ )}
1296
+ </RegisterGraphicalItemId>
1297
+ );
1244
1298
  }
1245
1299
  export const Pie = PieFn as typeof PieFn & { displayName?: string };
1246
1300
  Pie.displayName = 'Pie';