@octanejs/recharts 0.1.62 → 0.1.64
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/RadialBar.tsrx
CHANGED
|
@@ -94,8 +94,9 @@ import { CellsContext, useCellRegistry } from '../context/CellsContext';
|
|
|
94
94
|
|
|
95
95
|
const STABLE_EMPTY_ARRAY: readonly RadialBarDataItem[] = [];
|
|
96
96
|
|
|
97
|
-
export type RadialBarDataItem =
|
|
98
|
-
|
|
97
|
+
export type RadialBarDataItem = SectorProps &
|
|
98
|
+
GeometrySector &
|
|
99
|
+
TooltipTriggerInfo & {
|
|
99
100
|
value?: any;
|
|
100
101
|
payload?: any;
|
|
101
102
|
background?: SectorProps;
|
|
@@ -103,12 +104,11 @@ export type RadialBarDataItem =
|
|
|
103
104
|
|
|
104
105
|
type RadialBarBackground = boolean | (ActiveShape<SectorProps> & ZIndexable);
|
|
105
106
|
|
|
106
|
-
type RadialBarSectorsProps =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
};
|
|
107
|
+
type RadialBarSectorsProps = ShapeAnimationProps & {
|
|
108
|
+
sectors: ReadonlyArray<RadialBarDataItem>;
|
|
109
|
+
allOtherRadialBarProps: InternalProps;
|
|
110
|
+
showLabels: boolean;
|
|
111
|
+
};
|
|
112
112
|
|
|
113
113
|
function RadialBarLabelListProvider({
|
|
114
114
|
showLabels,
|
|
@@ -138,9 +138,11 @@ function RadialBarLabelListProvider({
|
|
|
138
138
|
}),
|
|
139
139
|
);
|
|
140
140
|
|
|
141
|
-
return
|
|
142
|
-
value={showLabels ? labelListEntries : undefined}
|
|
143
|
-
|
|
141
|
+
return (
|
|
142
|
+
<PolarLabelListContextProvider value={showLabels ? labelListEntries : undefined}>
|
|
143
|
+
{children}
|
|
144
|
+
</PolarLabelListContextProvider>
|
|
145
|
+
);
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
function RadialBarSectors({
|
|
@@ -178,49 +180,55 @@ function RadialBarSectors({
|
|
|
178
180
|
return null;
|
|
179
181
|
}
|
|
180
182
|
|
|
181
|
-
return
|
|
182
|
-
{sectors
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
183
|
+
return (
|
|
184
|
+
<RadialBarLabelListProvider showLabels={showLabels} sectors={sectors}>
|
|
185
|
+
{sectors.map((entry: RadialBarDataItem, i: number) => {
|
|
186
|
+
const isActive: boolean = Boolean(activeShape && activeIndex === String(i));
|
|
187
|
+
const onMouseEnter = onMouseEnterFromContext(entry, i);
|
|
188
|
+
const onMouseLeave = onMouseLeaveFromContext(entry, i);
|
|
189
|
+
const onClick = onClickFromContext(entry, i);
|
|
190
|
+
|
|
191
|
+
const radialBarSectorProps: ComponentProps<typeof RadialBarSector> = {
|
|
192
|
+
...baseProps,
|
|
193
|
+
cornerRadius: parseCornerRadius(cornerRadius),
|
|
194
|
+
...entry,
|
|
195
|
+
...adaptEventsOfChild(restOfAllOtherProps, entry, i),
|
|
196
|
+
onMouseEnter,
|
|
197
|
+
onMouseLeave,
|
|
198
|
+
onClick,
|
|
199
|
+
className: `recharts-radial-bar-sector ${entry.className}`,
|
|
200
|
+
forceCornerRadius: others.forceCornerRadius,
|
|
201
|
+
cornerIsExternal: others.cornerIsExternal,
|
|
202
|
+
animationElapsedTime,
|
|
203
|
+
isAnimating,
|
|
204
|
+
isEntrance,
|
|
205
|
+
isActive,
|
|
206
|
+
option: isActive && activeShape != null ? activeShape : shape,
|
|
207
|
+
index: i,
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
if (isActive) {
|
|
211
|
+
return (
|
|
212
|
+
<ZIndexLayer
|
|
213
|
+
zIndex={DefaultZIndexes.activeBar}
|
|
214
|
+
key={`sector-${entry.cx}-${entry.cy}-${entry.innerRadius}-${entry.outerRadius}-${entry.startAngle}-${entry.endAngle}-${i}`}
|
|
215
|
+
>
|
|
216
|
+
<RadialBarSector {...radialBarSectorProps} />
|
|
217
|
+
</ZIndexLayer>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
215
220
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
return (
|
|
222
|
+
<RadialBarSector
|
|
223
|
+
key={`sector-${entry.cx}-${entry.cy}-${entry.innerRadius}-${entry.outerRadius}-${entry.startAngle}-${entry.endAngle}-${i}`}
|
|
224
|
+
{...radialBarSectorProps}
|
|
225
|
+
/>
|
|
226
|
+
);
|
|
227
|
+
})}
|
|
228
|
+
<LabelListFromLabelProp label={allOtherRadialBarProps.label} />
|
|
229
|
+
{allOtherRadialBarProps.children}
|
|
230
|
+
</RadialBarLabelListProvider>
|
|
231
|
+
);
|
|
224
232
|
}
|
|
225
233
|
|
|
226
234
|
const defaultRadialBarAnimateItems: AnimationInterpolateFn<RadialBarDataItem, PolarLayout> = (
|
|
@@ -269,16 +277,14 @@ function SectorsWithAnimation({
|
|
|
269
277
|
onAnimationEnd,
|
|
270
278
|
} = props;
|
|
271
279
|
const animationInput = JSON.stringify(
|
|
272
|
-
sectors.map(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
],
|
|
281
|
-
),
|
|
280
|
+
sectors.map(({ cx, cy, innerRadius, outerRadius, startAngle, endAngle }) => [
|
|
281
|
+
cx,
|
|
282
|
+
cy,
|
|
283
|
+
innerRadius,
|
|
284
|
+
outerRadius,
|
|
285
|
+
startAngle,
|
|
286
|
+
endAngle,
|
|
287
|
+
]),
|
|
282
288
|
);
|
|
283
289
|
|
|
284
290
|
const { isAnimating, handleAnimationStart, handleAnimationEnd } = useAnimationCallbacks(
|
|
@@ -290,31 +296,34 @@ function SectorsWithAnimation({
|
|
|
290
296
|
|
|
291
297
|
if (layout == null) return null;
|
|
292
298
|
|
|
293
|
-
return
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
299
|
+
return (
|
|
300
|
+
<AnimatedItems
|
|
301
|
+
animationInput={animationInput}
|
|
302
|
+
animationIdPrefix="recharts-radialbar-"
|
|
303
|
+
items={sectors}
|
|
304
|
+
previousItemsRef={previousSectorsRef}
|
|
305
|
+
isAnimationActive={isAnimationActive}
|
|
306
|
+
animationBegin={animationBegin}
|
|
307
|
+
animationDuration={animationDuration}
|
|
308
|
+
animationEasing={animationEasing}
|
|
309
|
+
onAnimationStart={handleAnimationStart}
|
|
310
|
+
onAnimationEnd={handleAnimationEnd}
|
|
311
|
+
animationInterpolateFn={props.animationInterpolateFn}
|
|
312
|
+
animationMatchBy={props.animationMatchBy}
|
|
313
|
+
layout={layout}
|
|
314
|
+
>
|
|
315
|
+
{(stepData, animationElapsedTime, isEntrance) => (
|
|
316
|
+
<RadialBarSectors
|
|
317
|
+
sectors={stepData}
|
|
318
|
+
allOtherRadialBarProps={props}
|
|
319
|
+
showLabels={!isAnimating}
|
|
320
|
+
animationElapsedTime={animationElapsedTime}
|
|
321
|
+
isAnimating={isAnimating || animationElapsedTime < 1}
|
|
322
|
+
isEntrance={isEntrance}
|
|
323
|
+
/>
|
|
324
|
+
)}
|
|
325
|
+
</AnimatedItems>
|
|
326
|
+
);
|
|
318
327
|
}
|
|
319
328
|
|
|
320
329
|
function RenderSectors(props: InternalProps) {
|
|
@@ -323,271 +332,293 @@ function RenderSectors(props: InternalProps) {
|
|
|
323
332
|
return <SectorsWithAnimation props={props} previousSectorsRef={previousSectorsRef} />;
|
|
324
333
|
}
|
|
325
334
|
|
|
326
|
-
interface InternalRadialBarProps<DataPointType = any, DataValueType = any>
|
|
327
|
-
DataPointType,
|
|
328
|
-
DataValueType
|
|
329
|
-
>, ZIndexable {
|
|
335
|
+
interface InternalRadialBarProps<DataPointType = any, DataValueType = any>
|
|
336
|
+
extends DataConsumer<DataPointType, DataValueType>, ZIndexable {
|
|
330
337
|
activeShape?: ActiveShape<RadialBarSectorProps, SVGPathElement>;
|
|
331
338
|
/**
|
|
332
|
-
|
|
333
|
-
|
|
339
|
+
* @defaultValue 0
|
|
340
|
+
*/
|
|
334
341
|
angleAxisId?: AxisId;
|
|
335
342
|
/**
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
343
|
+
* Specifies when the animation should begin, the unit of this option is ms.
|
|
344
|
+
* @defaultValue 0
|
|
345
|
+
*/
|
|
339
346
|
animationBegin?: number;
|
|
340
347
|
/**
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
348
|
+
* Specifies the duration of animation, the unit of this option is ms.
|
|
349
|
+
* @defaultValue 1500
|
|
350
|
+
*/
|
|
344
351
|
animationDuration?: AnimationDuration;
|
|
345
352
|
/**
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
353
|
+
* The type of easing function.
|
|
354
|
+
* @defaultValue ease
|
|
355
|
+
*/
|
|
349
356
|
animationEasing?: EasingInput;
|
|
350
357
|
/**
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
358
|
+
* Custom animation function for interpolating data items.
|
|
359
|
+
* When provided, this replaces the default animation interpolation.
|
|
360
|
+
*
|
|
361
|
+
* @param prevItems The items from the previous animation frame, or null on first render
|
|
362
|
+
* @param nextItems The target items to animate towards
|
|
363
|
+
* @param animationElapsedTime A normalized time value (0 = start, 1 = end)
|
|
364
|
+
* @returns The interpolated items at time animationElapsedTime
|
|
365
|
+
*
|
|
366
|
+
* @since 3.9
|
|
367
|
+
* @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
|
|
368
|
+
*/
|
|
362
369
|
animationInterpolateFn?: AnimationInterpolateFn<RadialBarDataItem, PolarLayout>;
|
|
363
370
|
/**
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
371
|
+
* Strategy for matching previous items to next items during animation.
|
|
372
|
+
* Determines how Recharts pairs old data points with new data points
|
|
373
|
+
* to create smooth transitions.
|
|
374
|
+
*
|
|
375
|
+
* - `matchAppend` (default): match sequentially by index and treat newly appended items as new
|
|
376
|
+
* - `matchByIndex`: match by array position with proportional stretching
|
|
377
|
+
* - `matchByDataKey('someKey')`: match by a data key from the payload
|
|
378
|
+
* - Custom function `(item, index) => key`: match by the returned key
|
|
379
|
+
*
|
|
380
|
+
* @defaultValue append
|
|
381
|
+
* @see matchByIndex
|
|
382
|
+
* @see matchByDataKey
|
|
383
|
+
* @see matchAppend
|
|
384
|
+
*/
|
|
378
385
|
animationMatchBy?: AnimationMatchByProp<RadialBarDataItem>;
|
|
379
386
|
/**
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
387
|
+
* Renders a background for each bar. Options:
|
|
388
|
+
* - `false`: no background;
|
|
389
|
+
* - `true`: renders default background;
|
|
390
|
+
* - `object`: the props of background rectangle;
|
|
391
|
+
* - `OctaneElement`: a custom background element;
|
|
392
|
+
* - `function`: a render function of custom background.
|
|
393
|
+
*
|
|
394
|
+
* @defaultValue false
|
|
395
|
+
*/
|
|
389
396
|
background?: RadialBarBackground;
|
|
390
397
|
/**
|
|
391
|
-
|
|
392
|
-
|
|
398
|
+
* The width or height of each bar. If the barSize is not specified, the size of the bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups.
|
|
399
|
+
*/
|
|
393
400
|
barSize?: number;
|
|
394
401
|
className?: string;
|
|
395
402
|
/**
|
|
396
|
-
|
|
397
|
-
|
|
403
|
+
* @defaultValue false
|
|
404
|
+
*/
|
|
398
405
|
cornerIsExternal?: boolean;
|
|
399
406
|
/**
|
|
400
|
-
|
|
401
|
-
|
|
407
|
+
* @defaultValue 0
|
|
408
|
+
*/
|
|
402
409
|
cornerRadius?: string | number;
|
|
403
410
|
/**
|
|
404
|
-
|
|
405
|
-
|
|
411
|
+
* Calculated radial bar sectors
|
|
412
|
+
*/
|
|
406
413
|
sectors: ReadonlyArray<RadialBarDataItem>;
|
|
407
414
|
/**
|
|
408
|
-
|
|
409
|
-
|
|
415
|
+
* @defaultValue false
|
|
416
|
+
*/
|
|
410
417
|
forceCornerRadius?: boolean;
|
|
411
418
|
/**
|
|
412
|
-
|
|
413
|
-
|
|
419
|
+
* @defaultValue false
|
|
420
|
+
*/
|
|
414
421
|
hide?: boolean;
|
|
415
422
|
/**
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
423
|
+
* If set false, animation of radial bars will be disabled.
|
|
424
|
+
* If set "auto", the animation will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility.
|
|
425
|
+
* @defaultValue auto
|
|
426
|
+
*/
|
|
420
427
|
isAnimationActive?: boolean | 'auto';
|
|
421
428
|
/**
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
429
|
+
* Renders one label for each data point. Options:
|
|
430
|
+
* - `true`: renders default labels;
|
|
431
|
+
* - `false`: no labels are rendered;
|
|
432
|
+
* - `object`: the props of LabelList component;
|
|
433
|
+
* - `OctaneElement`: a custom SVG label element, such as `<text>` or `<g>`.
|
|
434
|
+
* HTML elements such as `<div>` are not valid inside the chart SVG and may trigger React DOM warnings.
|
|
435
|
+
* - `function`: a render function of custom label.
|
|
436
|
+
*
|
|
437
|
+
* @defaultValue false
|
|
438
|
+
*/
|
|
432
439
|
label?: ImplicitLabelListType;
|
|
433
440
|
/**
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
441
|
+
* The type of icon in legend. If set to 'none', no legend item will be rendered.
|
|
442
|
+
* @defaultValue rect
|
|
443
|
+
*/
|
|
437
444
|
legendType?: LegendType;
|
|
438
445
|
maxBarSize?: number;
|
|
439
446
|
/**
|
|
440
|
-
|
|
441
|
-
|
|
447
|
+
* @defaultValue 0
|
|
448
|
+
*/
|
|
442
449
|
minPointSize?: number;
|
|
443
450
|
/**
|
|
444
|
-
|
|
445
|
-
|
|
451
|
+
* The customized event handler of animation end
|
|
452
|
+
*/
|
|
446
453
|
onAnimationEnd?: () => void;
|
|
447
454
|
/**
|
|
448
|
-
|
|
449
|
-
|
|
455
|
+
* The customized event handler of animation start
|
|
456
|
+
*/
|
|
450
457
|
onAnimationStart?: () => void;
|
|
451
458
|
/**
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
onClick?: (
|
|
455
|
-
|
|
456
|
-
|
|
459
|
+
* The customized event handler of click in this chart.
|
|
460
|
+
*/
|
|
461
|
+
onClick?: (
|
|
462
|
+
data: RadialBarDataItem,
|
|
463
|
+
index: number,
|
|
464
|
+
e: NativeMouseEvent<SVGGraphicsElement>,
|
|
465
|
+
) => void;
|
|
457
466
|
/**
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
onMouseDown?: (
|
|
461
|
-
|
|
462
|
-
|
|
467
|
+
* The customized event handler of mousedown in this chart.
|
|
468
|
+
*/
|
|
469
|
+
onMouseDown?: (
|
|
470
|
+
data: RadialBarDataItem,
|
|
471
|
+
index: number,
|
|
472
|
+
e: NativeMouseEvent<SVGGraphicsElement>,
|
|
473
|
+
) => void;
|
|
463
474
|
/**
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
onMouseUp?: (
|
|
467
|
-
|
|
468
|
-
|
|
475
|
+
* The customized event handler of mouseup in this chart.
|
|
476
|
+
*/
|
|
477
|
+
onMouseUp?: (
|
|
478
|
+
data: RadialBarDataItem,
|
|
479
|
+
index: number,
|
|
480
|
+
e: NativeMouseEvent<SVGGraphicsElement>,
|
|
481
|
+
) => void;
|
|
469
482
|
/**
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
onMouseMove?: (
|
|
473
|
-
|
|
474
|
-
|
|
483
|
+
* The customized event handler of mousemove in this chart.
|
|
484
|
+
*/
|
|
485
|
+
onMouseMove?: (
|
|
486
|
+
data: RadialBarDataItem,
|
|
487
|
+
index: number,
|
|
488
|
+
e: NativeMouseEvent<SVGGraphicsElement>,
|
|
489
|
+
) => void;
|
|
475
490
|
/**
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
onMouseOver?: (
|
|
479
|
-
|
|
480
|
-
|
|
491
|
+
* The customized event handler of mouseover in this chart.
|
|
492
|
+
*/
|
|
493
|
+
onMouseOver?: (
|
|
494
|
+
data: RadialBarDataItem,
|
|
495
|
+
index: number,
|
|
496
|
+
e: NativeMouseEvent<SVGGraphicsElement>,
|
|
497
|
+
) => void;
|
|
481
498
|
/**
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
onMouseOut?: (
|
|
485
|
-
|
|
486
|
-
|
|
499
|
+
* The customized event handler of mouseout in this chart.
|
|
500
|
+
*/
|
|
501
|
+
onMouseOut?: (
|
|
502
|
+
data: RadialBarDataItem,
|
|
503
|
+
index: number,
|
|
504
|
+
e: NativeMouseEvent<SVGGraphicsElement>,
|
|
505
|
+
) => void;
|
|
487
506
|
/**
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
onMouseEnter?: (
|
|
491
|
-
|
|
492
|
-
|
|
507
|
+
* The customized event handler of mouseenter in this chart.
|
|
508
|
+
*/
|
|
509
|
+
onMouseEnter?: (
|
|
510
|
+
data: RadialBarDataItem,
|
|
511
|
+
index: number,
|
|
512
|
+
e: NativeMouseEvent<SVGGraphicsElement>,
|
|
513
|
+
) => void;
|
|
493
514
|
/**
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
onMouseLeave?: (
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
515
|
+
* The customized event handler of mouseleave in this chart.
|
|
516
|
+
*/
|
|
517
|
+
onMouseLeave?: (
|
|
518
|
+
data: RadialBarDataItem,
|
|
519
|
+
index: number,
|
|
520
|
+
e: NativeMouseEvent<SVGGraphicsElement>,
|
|
521
|
+
) => void;
|
|
522
|
+
onTouchStart?: (
|
|
523
|
+
data: RadialBarDataItem,
|
|
524
|
+
index: number,
|
|
525
|
+
e: NativeTouchEvent<SVGGraphicsElement>,
|
|
526
|
+
) => void;
|
|
527
|
+
onTouchMove?: (
|
|
528
|
+
data: RadialBarDataItem,
|
|
529
|
+
index: number,
|
|
530
|
+
e: NativeTouchEvent<SVGGraphicsElement>,
|
|
531
|
+
) => void;
|
|
532
|
+
onTouchEnd?: (
|
|
533
|
+
data: RadialBarDataItem,
|
|
534
|
+
index: number,
|
|
535
|
+
e: NativeTouchEvent<SVGGraphicsElement>,
|
|
536
|
+
) => void;
|
|
508
537
|
/**
|
|
509
|
-
|
|
510
|
-
|
|
538
|
+
* @defaultValue 0
|
|
539
|
+
*/
|
|
511
540
|
radiusAxisId?: AxisId;
|
|
512
541
|
/**
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
542
|
+
* If set a OctaneElement, the shape of radial bar sectors can be customized.
|
|
543
|
+
* If set a function, the function will be called to render customized shape.
|
|
544
|
+
* During animations, the function shape also receives `animationElapsedTime`, `isAnimating`, and `isEntrance`.
|
|
545
|
+
* By default, renders a sector.
|
|
546
|
+
*/
|
|
518
547
|
shape?: ActiveShape<RadialBarSectorProps, SVGPathElement>;
|
|
519
548
|
stackId?: string | number;
|
|
520
549
|
tooltipType?: TooltipType;
|
|
521
550
|
/**
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
551
|
+
* Formats the value displayed in the tooltip for this RadialBar.
|
|
552
|
+
* When set, takes precedence over the `formatter` prop on the Tooltip component.
|
|
553
|
+
*/
|
|
525
554
|
formatter?: Formatter;
|
|
526
555
|
/**
|
|
527
|
-
|
|
528
|
-
|
|
556
|
+
* @defaultValue 300
|
|
557
|
+
*/
|
|
529
558
|
zIndex?: number;
|
|
530
559
|
}
|
|
531
560
|
|
|
532
|
-
export type RadialBarProps<DataPointType = any, DataValueType = any> =
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
561
|
+
export type RadialBarProps<DataPointType = any, DataValueType = any> = Omit<
|
|
562
|
+
PresentationAttributesAdaptChildEvent<RadialBarDataItem, SVGElement>,
|
|
563
|
+
'ref' | keyof InternalRadialBarProps<DataPointType, DataValueType>
|
|
564
|
+
> &
|
|
565
|
+
Omit<InternalRadialBarProps<DataPointType, DataValueType>, 'sectors'>;
|
|
537
566
|
|
|
538
567
|
type InternalProps = WithIdRequired<PropsWithDefaults> & Pick<InternalRadialBarProps, 'sectors'>;
|
|
539
568
|
|
|
540
569
|
function SetRadialBarPayloadLegend(props: RadialBarProps) {
|
|
541
|
-
const legendPayload = useAppSelector(
|
|
542
|
-
|
|
570
|
+
const legendPayload = useAppSelector((state) =>
|
|
571
|
+
selectRadialBarLegendPayload(state, props.legendType),
|
|
543
572
|
);
|
|
544
573
|
return <SetPolarLegendPayload legendPayload={legendPayload ?? []} />;
|
|
545
574
|
}
|
|
546
575
|
|
|
547
|
-
const SetRadialBarTooltipEntrySettings = React.memo(
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
576
|
+
const SetRadialBarTooltipEntrySettings = React.memo(
|
|
577
|
+
({
|
|
578
|
+
dataKey,
|
|
579
|
+
sectors,
|
|
580
|
+
stroke,
|
|
581
|
+
strokeWidth,
|
|
582
|
+
name,
|
|
583
|
+
hide,
|
|
584
|
+
fill,
|
|
585
|
+
tooltipType,
|
|
586
|
+
formatter,
|
|
587
|
+
id,
|
|
588
|
+
}: Pick<
|
|
589
|
+
InternalProps,
|
|
590
|
+
| 'dataKey'
|
|
591
|
+
| 'sectors'
|
|
592
|
+
| 'stroke'
|
|
593
|
+
| 'strokeWidth'
|
|
594
|
+
| 'name'
|
|
595
|
+
| 'hide'
|
|
596
|
+
| 'fill'
|
|
597
|
+
| 'tooltipType'
|
|
598
|
+
| 'formatter'
|
|
599
|
+
| 'id'
|
|
600
|
+
>) => {
|
|
601
|
+
const tooltipEntrySettings: TooltipPayloadConfiguration = {
|
|
602
|
+
dataDefinedOnItem: sectors,
|
|
603
|
+
getPosition: noop,
|
|
604
|
+
settings: {
|
|
605
|
+
graphicalItemId: id,
|
|
606
|
+
stroke,
|
|
607
|
+
strokeWidth,
|
|
608
|
+
fill,
|
|
609
|
+
nameKey: undefined, // RadialBar does not have nameKey, why?
|
|
610
|
+
dataKey,
|
|
611
|
+
name: getTooltipNameProp(name, dataKey),
|
|
612
|
+
hide,
|
|
613
|
+
type: tooltipType,
|
|
614
|
+
color: fill,
|
|
615
|
+
unit: '', // Why does RadialBar not support unit?
|
|
616
|
+
formatter,
|
|
617
|
+
},
|
|
618
|
+
};
|
|
619
|
+
return <SetTooltipEntrySettings tooltipEntrySettings={tooltipEntrySettings} />;
|
|
620
|
+
},
|
|
621
|
+
);
|
|
591
622
|
|
|
592
623
|
function renderBackground(props: InternalProps, sectors?: ReadonlyArray<RadialBarDataItem>) {
|
|
593
624
|
if (sectors == null) {
|
|
@@ -595,33 +626,40 @@ function renderBackground(props: InternalProps, sectors?: ReadonlyArray<RadialBa
|
|
|
595
626
|
}
|
|
596
627
|
const { cornerRadius } = props;
|
|
597
628
|
const backgroundProps = svgPropertiesNoEventsFromUnknown(props.background);
|
|
598
|
-
return
|
|
599
|
-
zIndex={getZIndexFromUnknown(props.background, DefaultZIndexes.barBackground)}
|
|
600
|
-
|
|
601
|
-
|
|
629
|
+
return (
|
|
630
|
+
<ZIndexLayer zIndex={getZIndexFromUnknown(props.background, DefaultZIndexes.barBackground)}>
|
|
631
|
+
{sectors.map((entry, i) => {
|
|
632
|
+
const { value, background, ...rest } = entry;
|
|
602
633
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
634
|
+
if (!background) {
|
|
635
|
+
return null;
|
|
636
|
+
}
|
|
606
637
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
638
|
+
const sectorProps: ComponentProps<typeof RadialBarSector> = {
|
|
639
|
+
cornerRadius: parseCornerRadius(cornerRadius),
|
|
640
|
+
...rest,
|
|
641
|
+
fill: '#eee',
|
|
642
|
+
...background,
|
|
643
|
+
...backgroundProps,
|
|
644
|
+
...adaptEventsOfChild(props, entry, i),
|
|
645
|
+
index: i,
|
|
646
|
+
className: clsx(
|
|
647
|
+
'recharts-radial-bar-background-sector',
|
|
648
|
+
String(backgroundProps?.className),
|
|
649
|
+
),
|
|
650
|
+
option: background,
|
|
651
|
+
isActive: false,
|
|
652
|
+
};
|
|
619
653
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
654
|
+
return (
|
|
655
|
+
<RadialBarSector
|
|
656
|
+
key={`background-${rest.cx}-${rest.cy}-${rest.innerRadius}-${rest.outerRadius}-${rest.startAngle}-${rest.endAngle}-${i}`}
|
|
657
|
+
{...sectorProps}
|
|
658
|
+
/>
|
|
659
|
+
);
|
|
660
|
+
})}
|
|
661
|
+
</ZIndexLayer>
|
|
662
|
+
);
|
|
625
663
|
}
|
|
626
664
|
|
|
627
665
|
function RadialBarWithState(props: InternalProps) {
|
|
@@ -633,18 +671,20 @@ function RadialBarWithState(props: InternalProps) {
|
|
|
633
671
|
|
|
634
672
|
const layerClass = clsx('recharts-area', className);
|
|
635
673
|
|
|
636
|
-
return
|
|
637
|
-
<
|
|
638
|
-
{
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
<
|
|
674
|
+
return (
|
|
675
|
+
<ZIndexLayer zIndex={props.zIndex}>
|
|
676
|
+
<Layer className={layerClass}>
|
|
677
|
+
{background && (
|
|
678
|
+
<Layer className="recharts-radial-bar-background">
|
|
679
|
+
{renderBackground(props, sectors)}
|
|
680
|
+
</Layer>
|
|
681
|
+
)}
|
|
682
|
+
<Layer className="recharts-radial-bar-sectors">
|
|
683
|
+
<RenderSectors {...props} />
|
|
684
|
+
</Layer>
|
|
645
685
|
</Layer>
|
|
646
|
-
</
|
|
647
|
-
|
|
686
|
+
</ZIndexLayer>
|
|
687
|
+
);
|
|
648
688
|
}
|
|
649
689
|
|
|
650
690
|
function RadialBarImpl(props: WithIdRequired<PropsWithDefaults>) {
|
|
@@ -676,31 +716,32 @@ function RadialBarImpl(props: WithIdRequired<PropsWithDefaults>) {
|
|
|
676
716
|
],
|
|
677
717
|
);
|
|
678
718
|
const sectors: ReadonlyArray<RadialBarDataItem> =
|
|
679
|
-
useAppSelector(
|
|
680
|
-
|
|
719
|
+
useAppSelector((state) =>
|
|
720
|
+
selectRadialBarSectors(
|
|
681
721
|
state,
|
|
682
722
|
props.radiusAxisId,
|
|
683
723
|
props.angleAxisId,
|
|
684
724
|
radialBarSettings,
|
|
685
725
|
cells,
|
|
686
726
|
),
|
|
687
|
-
) ??
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
727
|
+
) ?? STABLE_EMPTY_ARRAY;
|
|
728
|
+
return (
|
|
729
|
+
<CellsContext value={cellRegistry}>
|
|
730
|
+
<SetRadialBarTooltipEntrySettings
|
|
731
|
+
dataKey={props.dataKey}
|
|
732
|
+
sectors={sectors}
|
|
733
|
+
stroke={props.stroke}
|
|
734
|
+
strokeWidth={props.strokeWidth}
|
|
735
|
+
name={props.name}
|
|
736
|
+
hide={props.hide}
|
|
737
|
+
fill={props.fill}
|
|
738
|
+
tooltipType={props.tooltipType}
|
|
739
|
+
formatter={props.formatter}
|
|
740
|
+
id={props.id}
|
|
741
|
+
/>
|
|
742
|
+
<RadialBarWithState {...props} sectors={sectors} />
|
|
743
|
+
</CellsContext>
|
|
744
|
+
);
|
|
704
745
|
}
|
|
705
746
|
|
|
706
747
|
export const defaultRadialBarProps = {
|
|
@@ -724,8 +765,10 @@ export const defaultRadialBarProps = {
|
|
|
724
765
|
zIndex: DefaultZIndexes.bar,
|
|
725
766
|
} as const satisfies Partial<RadialBarProps>;
|
|
726
767
|
|
|
727
|
-
type PropsWithDefaults<DataPointType = any, DataValueType = any> =
|
|
728
|
-
|
|
768
|
+
type PropsWithDefaults<DataPointType = any, DataValueType = any> = RequiresDefaultProps<
|
|
769
|
+
RadialBarProps<DataPointType, DataValueType>,
|
|
770
|
+
typeof defaultRadialBarProps
|
|
771
|
+
>;
|
|
729
772
|
|
|
730
773
|
export function computeRadialBarDataItems({
|
|
731
774
|
displayedData,
|
|
@@ -852,7 +895,7 @@ export function computeRadialBarDataItems({
|
|
|
852
895
|
// Sector. Keep the row so custom shapes, Cell overrides, and tooltip
|
|
853
896
|
// indices still refer to the original datum.
|
|
854
897
|
return {
|
|
855
|
-
...entry as Record<string, unknown
|
|
898
|
+
...(entry as Record<string, unknown>),
|
|
856
899
|
...backgroundSector,
|
|
857
900
|
payload: entry,
|
|
858
901
|
value: stackedData ? value : value[1],
|
|
@@ -862,7 +905,7 @@ export function computeRadialBarDataItems({
|
|
|
862
905
|
outerRadius: outerRadius ?? defaultSectorProps.outerRadius,
|
|
863
906
|
startAngle: startAngle ?? defaultSectorProps.startAngle,
|
|
864
907
|
endAngle: endAngle ?? defaultSectorProps.endAngle,
|
|
865
|
-
...cells && cells[index] && cells[index].props as CellPropsFor<SVGPathElement
|
|
908
|
+
...(cells && cells[index] && (cells[index].props as CellPropsFor<SVGPathElement>)),
|
|
866
909
|
} satisfies RadialBarDataItem;
|
|
867
910
|
});
|
|
868
911
|
}
|
|
@@ -879,25 +922,29 @@ export function RadialBar<DataPointType = any, DataValueType = any>(
|
|
|
879
922
|
outsideProps,
|
|
880
923
|
defaultRadialBarProps,
|
|
881
924
|
);
|
|
882
|
-
return
|
|
883
|
-
{
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
925
|
+
return (
|
|
926
|
+
<RegisterGraphicalItemId id={props.id} type="radialBar">
|
|
927
|
+
{(id) => (
|
|
928
|
+
<>
|
|
929
|
+
<SetPolarGraphicalItem
|
|
930
|
+
type="radialBar"
|
|
931
|
+
id={id}
|
|
932
|
+
data={undefined}
|
|
933
|
+
dataKey={props.dataKey}
|
|
934
|
+
hide={props.hide ?? defaultRadialBarProps.hide}
|
|
935
|
+
angleAxisId={props.angleAxisId ?? defaultRadialBarProps.angleAxisId}
|
|
936
|
+
radiusAxisId={props.radiusAxisId ?? defaultRadialBarProps.radiusAxisId}
|
|
937
|
+
stackId={getNormalizedStackId(props.stackId)}
|
|
938
|
+
barSize={props.barSize}
|
|
939
|
+
minPointSize={props.minPointSize}
|
|
940
|
+
maxBarSize={props.maxBarSize}
|
|
941
|
+
/>
|
|
942
|
+
<SetRadialBarPayloadLegend {...props} />
|
|
943
|
+
<RadialBarImpl {...props} id={id} />
|
|
944
|
+
</>
|
|
945
|
+
)}
|
|
946
|
+
</RegisterGraphicalItemId>
|
|
947
|
+
);
|
|
901
948
|
}
|
|
902
949
|
|
|
903
950
|
RadialBar.displayName = 'RadialBar';
|