@octanejs/recharts 0.1.61 → 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.
- package/package.json +5 -5
- package/src/animation/AnimatedItems.tsrx +36 -31
- package/src/animation/CSSTransitionAnimate.tsrx +1 -2
- package/src/animation/JavascriptAnimate.tsrx +1 -2
- package/src/cartesian/Area.tsrx +414 -386
- package/src/cartesian/AreaRevealShape.tsrx +103 -84
- package/src/cartesian/Bar.tsrx +343 -317
- package/src/cartesian/BarStack.tsrx +33 -28
- package/src/cartesian/CartesianAxis.tsrx +168 -165
- package/src/cartesian/CartesianGrid.tsrx +256 -272
- package/src/cartesian/ErrorBar.tsrx +108 -104
- package/src/cartesian/Funnel.tsrx +405 -382
- package/src/cartesian/GraphicalItemClipPath.tsrx +4 -8
- package/src/cartesian/Line.tsrx +190 -177
- package/src/cartesian/LineDrawShape.tsrx +14 -15
- package/src/cartesian/ReferenceLine.tsrx +119 -105
- package/src/cartesian/Scatter.tsrx +416 -398
- package/src/cartesian/XAxis.tsrx +39 -32
- package/src/cartesian/YAxis.tsrx +47 -37
- package/src/cartesian/ZAxis.tsrx +76 -73
- package/src/chart/AreaChart.tsrx +15 -11
- package/src/chart/BarChart.tsrx +15 -11
- package/src/chart/CategoricalChart.tsrx +32 -26
- package/src/chart/ComposedChart.tsrx +15 -11
- package/src/chart/FunnelChart.tsrx +15 -11
- package/src/chart/LineChart.tsrx +15 -11
- package/src/chart/PieChart.tsrx +15 -11
- package/src/chart/PolarChart.tsrx +45 -48
- package/src/chart/RadarChart.tsrx +38 -32
- package/src/chart/RadialBarChart.tsrx +15 -11
- package/src/chart/RechartsWrapper.tsrx +214 -162
- package/src/chart/Sankey.tsrx +412 -378
- package/src/chart/ScatterChart.tsrx +15 -11
- package/src/chart/SunburstChart.tsrx +162 -155
- package/src/component/ActivePoints.tsrx +19 -13
- package/src/component/Cursor.tsrx +25 -18
- package/src/component/DefaultLegendContent.tsrx +131 -127
- package/src/component/DefaultTooltipContent.tsrx +46 -42
- package/src/component/Dots.tsrx +11 -5
- package/src/component/Label.tsrx +69 -55
- package/src/component/LabelList.tsrx +32 -27
- package/src/component/Legend.tsrx +120 -123
- package/src/component/ResponsiveContainer.tsrx +18 -11
- package/src/component/Text.tsrx +50 -43
- package/src/component/Tooltip.tsrx +234 -223
- package/src/component/TooltipBoundingBox.tsrx +34 -34
- package/src/container/ClipPathProvider.tsrx +1 -3
- package/src/container/Layer.tsrx +5 -1
- package/src/container/RootSurface.tsrx +31 -21
- package/src/container/Surface.tsrx +15 -13
- package/src/context/ErrorBarContext.tsrx +5 -5
- package/src/polar/Pie.tsrx +541 -487
- package/src/polar/PolarAngleAxis.tsrx +245 -227
- package/src/polar/PolarGrid.tsrx +139 -127
- package/src/polar/PolarRadiusAxis.tsrx +204 -185
- package/src/polar/Radar.tsrx +274 -264
- package/src/polar/RadialBar.tsrx +408 -361
- package/src/shape/Cross.tsrx +13 -7
- package/src/shape/Curve.tsrx +54 -44
- package/src/shape/Dot.tsrx +10 -8
- package/src/shape/Polygon.tsrx +38 -29
- package/src/shape/Rectangle.tsrx +73 -28
- package/src/shape/Sector.tsrx +30 -18
- package/src/shape/Symbols.tsrx +13 -11
- package/src/shape/Trapezoid.tsrx +16 -11
- package/src/state/RechartsStoreProvider.tsrx +5 -1
- package/src/synchronisation/useChartSynchronisation.tsrx +8 -7
- package/src/util/BarUtils.tsrx +43 -40
- package/src/util/FunnelUtils.tsrx +5 -5
- package/src/util/RadialBarUtils.tsrx +3 -4
- package/src/util/ScatterUtils.tsrx +13 -8
- package/src/zIndex/ZIndexLayer.tsrx +2 -2
- package/src/zIndex/ZIndexPortal.tsrx +2 -8
package/src/polar/Pie.tsrx
CHANGED
|
@@ -91,38 +91,38 @@ import { CellsContext, useCellRegistry } from '../context/CellsContext';
|
|
|
91
91
|
|
|
92
92
|
interface PieDef {
|
|
93
93
|
/**
|
|
94
|
-
|
|
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
|
-
|
|
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
|
-
|
|
103
|
-
|
|
102
|
+
* Angle in degrees from which the chart should start.
|
|
103
|
+
*/
|
|
104
104
|
startAngle?: number;
|
|
105
105
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
* Angle, in degrees, at which the chart should end.
|
|
107
|
+
*/
|
|
108
108
|
endAngle?: number;
|
|
109
109
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
118
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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<
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
| boolean
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
202
|
+
export type PieSectorDataItem = PiePresentationProps &
|
|
203
|
+
PieCoordinate &
|
|
204
|
+
PieSectorData & {
|
|
208
205
|
cornerRadius: number | undefined;
|
|
209
206
|
};
|
|
210
207
|
|
|
211
|
-
export type PieSectorShapeProps =
|
|
212
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
onClick?: (
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
|
|
229
|
-
|
|
230
|
-
onMouseDown?: (
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
235
|
-
|
|
236
|
-
onMouseUp?: (
|
|
237
|
-
|
|
238
|
-
|
|
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
|
-
|
|
241
|
-
|
|
242
|
-
onMouseMove?: (
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
onMouseOver?: (
|
|
249
|
-
|
|
250
|
-
|
|
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
|
-
|
|
253
|
-
|
|
254
|
-
onMouseOut?: (
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
259
|
-
|
|
260
|
-
onMouseEnter?: (
|
|
261
|
-
|
|
262
|
-
|
|
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
|
-
|
|
265
|
-
|
|
266
|
-
onMouseLeave?: (
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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>
|
|
289
|
-
|
|
290
|
-
|
|
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
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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
|
-
|
|
302
|
-
|
|
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
|
-
|
|
307
|
-
|
|
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
|
-
|
|
312
|
-
|
|
313
|
-
|
|
334
|
+
* The type of easing function.
|
|
335
|
+
* @defaultValue ease
|
|
336
|
+
*/
|
|
314
337
|
animationEasing?: EasingInput;
|
|
315
338
|
/**
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
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
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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
|
-
|
|
362
|
-
|
|
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
|
-
|
|
367
|
-
|
|
368
|
-
|
|
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
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
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
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
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
|
-
|
|
400
|
-
|
|
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
|
-
|
|
407
|
-
|
|
408
|
-
|
|
429
|
+
* The minimum angle of each unzero data.
|
|
430
|
+
* @defaultValue 0
|
|
431
|
+
*/
|
|
409
432
|
minAngle?: number;
|
|
410
433
|
/**
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
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
|
-
|
|
423
|
-
|
|
445
|
+
* The customized event handler of animation end.
|
|
446
|
+
*/
|
|
424
447
|
onAnimationEnd?: () => void;
|
|
425
448
|
/**
|
|
426
|
-
|
|
427
|
-
|
|
449
|
+
* The customized event handler of animation start.
|
|
450
|
+
*/
|
|
428
451
|
onAnimationStart?: () => void;
|
|
429
452
|
/**
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
453
|
+
* The tabindex of wrapper surrounding the cells.
|
|
454
|
+
* @defaultValue 0
|
|
455
|
+
*/
|
|
433
456
|
rootTabIndex?: number;
|
|
434
457
|
/**
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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
|
-
|
|
444
|
-
|
|
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
|
-
|
|
449
|
-
|
|
471
|
+
* @defaultValue 100
|
|
472
|
+
*/
|
|
450
473
|
zIndex?: number;
|
|
451
474
|
}
|
|
452
475
|
|
|
453
|
-
type PieSvgAttributes =
|
|
454
|
-
|
|
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
|
-
|
|
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
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
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 ||
|
|
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
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
const
|
|
557
|
-
|
|
558
|
-
|
|
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
|
-
|
|
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
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
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
|
|
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' &&
|
|
718
|
+
(typeof label === 'object' &&
|
|
719
|
+
'offsetRadius' in label &&
|
|
689
720
|
typeof label.offsetRadius === 'number' &&
|
|
690
|
-
label.offsetRadius ||
|
|
691
|
-
|
|
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
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
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
|
-
|
|
799
|
-
|
|
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
|
-
|
|
802
|
-
|
|
803
|
-
|
|
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
|
-
|
|
806
|
-
|
|
839
|
+
const isActive =
|
|
840
|
+
String(i) === activeIndex &&
|
|
807
841
|
(activeDataKey == null || allOtherPieProps.dataKey === activeDataKey) &&
|
|
808
842
|
graphicalItemMatches;
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
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 =
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
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 &&
|
|
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
|
-
|
|
976
|
-
|
|
977
|
-
|
|
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
|
-
|
|
980
|
-
|
|
981
|
-
|
|
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
|
|
994
|
-
value={showLabels ? labelListEntries : undefined}
|
|
995
|
-
|
|
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
|
|
1081
|
-
<
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
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
|
|
1158
|
-
<
|
|
1159
|
-
|
|
1160
|
-
|
|
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
|
|
1168
|
-
<
|
|
1169
|
-
|
|
1170
|
-
<
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
{
|
|
1186
|
-
?
|
|
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
|
-
:
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
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
|
|
1215
|
-
{
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
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';
|