@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.
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
@@ -72,128 +72,126 @@ export interface RadarPoint {
72
72
  name?: string | number;
73
73
  }
74
74
 
75
- interface RadarProps<DataPointType = any, DataValueType = any> extends ZIndexable, DataConsumer<
76
- DataPointType,
77
- DataValueType
78
- > {
75
+ interface RadarProps<DataPointType = any, DataValueType = any>
76
+ extends ZIndexable, DataConsumer<DataPointType, DataValueType> {
79
77
  /**
80
- * @defaultValue true
81
- */
78
+ * @defaultValue true
79
+ */
82
80
  activeDot?: ActiveDotType;
83
81
  /**
84
- * @defaultValue 0
85
- */
82
+ * @defaultValue 0
83
+ */
86
84
  angleAxisId?: string | number;
87
85
  /**
88
- * Specifies when the animation should begin, the unit of this option is ms.
89
- * @defaultValue 0
90
- */
86
+ * Specifies when the animation should begin, the unit of this option is ms.
87
+ * @defaultValue 0
88
+ */
91
89
  animationBegin?: number;
92
90
  /**
93
- * Specifies the duration of animation, the unit of this option is ms.
94
- * @defaultValue 1500
95
- */
91
+ * Specifies the duration of animation, the unit of this option is ms.
92
+ * @defaultValue 1500
93
+ */
96
94
  animationDuration?: AnimationDuration;
97
95
  /**
98
- * The type of easing function.
99
- * @defaultValue ease
100
- */
96
+ * The type of easing function.
97
+ * @defaultValue ease
98
+ */
101
99
  animationEasing?: EasingInput;
102
100
  /**
103
- * Custom animation function for interpolating data items.
104
- * When provided, this replaces the default animation interpolation.
105
- *
106
- * @param prevItems The items from the previous animation frame, or null on first render
107
- * @param nextItems The target items to animate towards
108
- * @param animationElapsedTime A normalized time value (0 = start, 1 = end)
109
- * @returns The interpolated items at time animationElapsedTime
110
- *
111
- * @since 3.9
112
- * @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
113
- */
101
+ * Custom animation function for interpolating data items.
102
+ * When provided, this replaces the default animation interpolation.
103
+ *
104
+ * @param prevItems The items from the previous animation frame, or null on first render
105
+ * @param nextItems The target items to animate towards
106
+ * @param animationElapsedTime A normalized time value (0 = start, 1 = end)
107
+ * @returns The interpolated items at time animationElapsedTime
108
+ *
109
+ * @since 3.9
110
+ * @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
111
+ */
114
112
  animationInterpolateFn?: AnimationInterpolateFn<RadarPoint, PolarLayout>;
115
113
  /**
116
- * Strategy for matching previous items to next items during animation.
117
- * Determines how Recharts pairs old data points with new data points
118
- * to create smooth transitions.
119
- *
120
- * - `matchByIndex` (default): match by array position with proportional stretching
121
- * - `matchAppend`: match sequentially by index and treat newly appended items as new
122
- * - `matchByDataKey('someKey')`: match by a data key from the payload
123
- * - Custom function `(item, index) => key`: match by the returned key
124
- *
125
- * @defaultValue index
126
- * @see matchByIndex
127
- * @see matchByDataKey
128
- * @see matchAppend
129
- */
114
+ * Strategy for matching previous items to next items during animation.
115
+ * Determines how Recharts pairs old data points with new data points
116
+ * to create smooth transitions.
117
+ *
118
+ * - `matchByIndex` (default): match by array position with proportional stretching
119
+ * - `matchAppend`: match sequentially by index and treat newly appended items as new
120
+ * - `matchByDataKey('someKey')`: match by a data key from the payload
121
+ * - Custom function `(item, index) => key`: match by the returned key
122
+ *
123
+ * @defaultValue index
124
+ * @see matchByIndex
125
+ * @see matchByDataKey
126
+ * @see matchAppend
127
+ */
130
128
  animationMatchBy?: AnimationMatchByProp<RadarPoint>;
131
129
  baseLinePoints?: RadarPoint[];
132
130
  className?: string;
133
131
  connectNulls?: boolean;
134
132
  /**
135
- * Renders a circle element at each data point. Options:
136
- *
137
- * - `false`: no dots are drawn;
138
- * - `true`: renders the dots with default settings;
139
- * - `object`: the props of the dot. This will be merged with the internal calculated props of each dot;
140
- * - `OctaneElement`: the custom dot element;
141
- * - `function`: a render function of the custom dot.
142
- *
143
- * @defaultValue false
144
- */
133
+ * Renders a circle element at each data point. Options:
134
+ *
135
+ * - `false`: no dots are drawn;
136
+ * - `true`: renders the dots with default settings;
137
+ * - `object`: the props of the dot. This will be merged with the internal calculated props of each dot;
138
+ * - `OctaneElement`: the custom dot element;
139
+ * - `function`: a render function of the custom dot.
140
+ *
141
+ * @defaultValue false
142
+ */
145
143
  dot?: DotType;
146
144
  /**
147
- * @defaultValue false
148
- */
145
+ * @defaultValue false
146
+ */
149
147
  hide?: boolean;
150
148
  /**
151
- * If set false, animation of polygon will be disabled.
152
- * If set "auto", the animation will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility.
153
- * @defaultValue auto
154
- */
149
+ * If set false, animation of polygon will be disabled.
150
+ * If set "auto", the animation will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility.
151
+ * @defaultValue auto
152
+ */
155
153
  isAnimationActive?: boolean | 'auto';
156
154
  isRange?: boolean;
157
155
  /**
158
- * Renders one label for each point. Options:
159
- * - `true`: renders default labels;
160
- * - `false`: no labels are rendered;
161
- * - `object`: the props of LabelList component;
162
- * - `OctaneElement`: a custom SVG label element, such as `<text>` or `<g>`.
163
- * HTML elements such as `<div>` are not valid inside the chart SVG and may trigger React DOM warnings.
164
- * - `function`: a render function of custom label.
165
- *
166
- * @defaultValue false
167
- */
156
+ * Renders one label for each point. Options:
157
+ * - `true`: renders default labels;
158
+ * - `false`: no labels are rendered;
159
+ * - `object`: the props of LabelList component;
160
+ * - `OctaneElement`: a custom SVG label element, such as `<text>` or `<g>`.
161
+ * HTML elements such as `<div>` are not valid inside the chart SVG and may trigger React DOM warnings.
162
+ * - `function`: a render function of custom label.
163
+ *
164
+ * @defaultValue false
165
+ */
168
166
  label?: ImplicitLabelListType;
169
167
  /**
170
- * The type of icon in legend. If set to 'none', no legend item will be rendered.
171
- * @defaultValue rect
172
- */
168
+ * The type of icon in legend. If set to 'none', no legend item will be rendered.
169
+ * @defaultValue rect
170
+ */
173
171
  legendType?: LegendType;
174
172
  /**
175
- * The customized event handler of animation end
176
- */
173
+ * The customized event handler of animation end
174
+ */
177
175
  onAnimationEnd?: () => void;
178
176
  /**
179
- * The customized event handler of animation start
180
- */
177
+ * The customized event handler of animation start
178
+ */
181
179
  onAnimationStart?: () => void;
182
180
  onMouseEnter?: (props: InternalRadarProps, e: NativeMouseEvent<SVGPathElement>) => void;
183
181
  onMouseLeave?: (props: InternalRadarProps, e: NativeMouseEvent<SVGPathElement>) => void;
184
182
  /**
185
- * @defaultValue 0
186
- */
183
+ * @defaultValue 0
184
+ */
187
185
  radiusAxisId?: string | number;
188
186
  /**
189
- * If set a OctaneElement, the shape of radar can be customized.
190
- * If set a function, the function will be called to render customized shape.
191
- */
187
+ * If set a OctaneElement, the shape of radar can be customized.
188
+ * If set a function, the function will be called to render customized shape.
189
+ */
192
190
  shape?: OctaneElement<SVGElement> | ((props: any) => OctaneElement<SVGElement>);
193
191
  tooltipType?: TooltipType;
194
192
  /**
195
- * @defaultValue 100
196
- */
193
+ * @defaultValue 100
194
+ */
197
195
  zIndex?: number;
198
196
  }
199
197
 
@@ -206,11 +204,11 @@ export type AngleAxisForRadar = {
206
204
  cy: number;
207
205
  };
208
206
 
209
- export type Props<DataPointType = any, DataValueType = any> =
210
- Omit<
211
- SVGProps<SVGGraphicsElement>,
212
- 'onMouseEnter' | 'onMouseLeave' | 'points' | 'ref'
213
- > & RadarProps<DataPointType, DataValueType>;
207
+ export type Props<DataPointType = any, DataValueType = any> = Omit<
208
+ SVGProps<SVGGraphicsElement>,
209
+ 'onMouseEnter' | 'onMouseLeave' | 'points' | 'ref'
210
+ > &
211
+ RadarProps<DataPointType, DataValueType>;
214
212
 
215
213
  export type RadarComposedData = {
216
214
  points: RadarPoint[];
@@ -241,44 +239,46 @@ const computeLegendPayloadFromRadarSectors = (
241
239
  ];
242
240
  };
243
241
 
244
- const SetRadarTooltipEntrySettings = React.memo(({
245
- dataKey,
246
- stroke,
247
- strokeWidth,
248
- fill,
249
- name,
250
- hide,
251
- tooltipType,
252
- id,
253
- }: Pick<
254
- WithIdRequired<PropsWithDefaults>,
255
- 'dataKey' | 'stroke' | 'strokeWidth' | 'fill' | 'name' | 'hide' | 'tooltipType' | 'id'
256
- >) => {
257
- const tooltipEntrySettings: TooltipPayloadConfiguration = {
258
- /*
259
- * I suppose this here _could_ return props.points
260
- * because while Radar does not support item tooltip mode, it _could_ support it.
261
- * But when I actually do return the points here, a defaultIndex test starts failing.
262
- * So, undefined it is.
263
- */
264
- dataDefinedOnItem: undefined,
265
- getPosition: noop,
266
- settings: {
267
- stroke,
268
- strokeWidth,
269
- fill,
270
- nameKey: undefined, // RadarChart does not have nameKey unfortunately
271
- dataKey,
272
- name: getTooltipNameProp(name, dataKey),
273
- hide,
274
- type: tooltipType,
275
- color: getLegendItemColor(stroke, fill),
276
- unit: '', // why doesn't Radar support unit?
277
- graphicalItemId: id,
278
- },
279
- };
280
- return <SetTooltipEntrySettings tooltipEntrySettings={tooltipEntrySettings} />;
281
- });
242
+ const SetRadarTooltipEntrySettings = React.memo(
243
+ ({
244
+ dataKey,
245
+ stroke,
246
+ strokeWidth,
247
+ fill,
248
+ name,
249
+ hide,
250
+ tooltipType,
251
+ id,
252
+ }: Pick<
253
+ WithIdRequired<PropsWithDefaults>,
254
+ 'dataKey' | 'stroke' | 'strokeWidth' | 'fill' | 'name' | 'hide' | 'tooltipType' | 'id'
255
+ >) => {
256
+ const tooltipEntrySettings: TooltipPayloadConfiguration = {
257
+ /*
258
+ * I suppose this here _could_ return props.points
259
+ * because while Radar does not support item tooltip mode, it _could_ support it.
260
+ * But when I actually do return the points here, a defaultIndex test starts failing.
261
+ * So, undefined it is.
262
+ */
263
+ dataDefinedOnItem: undefined,
264
+ getPosition: noop,
265
+ settings: {
266
+ stroke,
267
+ strokeWidth,
268
+ fill,
269
+ nameKey: undefined, // RadarChart does not have nameKey unfortunately
270
+ dataKey,
271
+ name: getTooltipNameProp(name, dataKey),
272
+ hide,
273
+ type: tooltipType,
274
+ color: getLegendItemColor(stroke, fill),
275
+ unit: '', // why doesn't Radar support unit?
276
+ graphicalItemId: id,
277
+ },
278
+ };
279
+ return <SetTooltipEntrySettings tooltipEntrySettings={tooltipEntrySettings} />;
280
+ },
281
+ );
282
282
 
283
283
  function RadarDotsWrapper({
284
284
  points,
@@ -292,14 +292,16 @@ function RadarDotsWrapper({
292
292
 
293
293
  const baseProps = svgPropertiesNoEvents(propsWithoutId);
294
294
 
295
- return <Dots
296
- points={points}
297
- dot={dot}
298
- className="recharts-radar-dots"
299
- dotClassName="recharts-radar-dot"
300
- dataKey={dataKey}
301
- baseProps={baseProps}
302
- />;
295
+ return (
296
+ <Dots
297
+ points={points}
298
+ dot={dot}
299
+ className="recharts-radar-dots"
300
+ dotClassName="recharts-radar-dot"
301
+ dataKey={dataKey}
302
+ baseProps={baseProps}
303
+ />
304
+ );
303
305
  }
304
306
 
305
307
  export function computeRadarPoints({
@@ -318,16 +320,14 @@ export function computeRadarPoints({
318
320
  const { cx, cy } = angleAxis;
319
321
  let isRange = false;
320
322
  const points: RadarPoint[] = [];
321
- const angleBandSize =
322
- angleAxis.type !== 'number' ? bandSize ?? 0 : 0;
323
+ const angleBandSize = angleAxis.type !== 'number' ? (bandSize ?? 0) : 0;
323
324
 
324
325
  displayedData.forEach((entry, i) => {
325
326
  const name = getValueByDataKey(entry, angleAxis.dataKey, i);
326
327
  const value = getValueByDataKey(entry, dataKey);
327
328
  const angle: number = (angleAxis.scale.map(name) ?? 0) + angleBandSize;
328
- const pointValue =
329
- Array.isArray(value) ? last(value) : value;
330
- const radius: number = isNullish(pointValue) ? 0 : radiusAxis.scale.map(pointValue) ?? 0;
329
+ const pointValue = Array.isArray(value) ? last(value) : value;
330
+ const radius: number = isNullish(pointValue) ? 0 : (radiusAxis.scale.map(pointValue) ?? 0);
331
331
 
332
332
  if (Array.isArray(value) && value.length >= 2) {
333
333
  isRange = true;
@@ -352,7 +352,7 @@ export function computeRadarPoints({
352
352
  points.forEach((point: RadarPoint) => {
353
353
  if (Array.isArray(point.value)) {
354
354
  const baseValue = point.value[0];
355
- const radius: number = isNullish(baseValue) ? 0 : radiusAxis.scale.map(baseValue) ?? 0;
355
+ const radius: number = isNullish(baseValue) ? 0 : (radiusAxis.scale.map(baseValue) ?? 0);
356
356
 
357
357
  baseLinePoints.push({
358
358
  ...point,
@@ -378,9 +378,9 @@ function RadarLabelListProvider({
378
378
  children: OctaneNode;
379
379
  }) {
380
380
  /*
381
- * Radar provides a Cartesian label list context. Do we want to also provide a polar label list context?
382
- * That way, users can choose to use polar positions for the Radar labels.
383
- */
381
+ * Radar provides a Cartesian label list context. Do we want to also provide a polar label list context?
382
+ * That way, users can choose to use polar positions for the Radar labels.
383
+ */
384
384
  // const labelListEntries: ReadonlyArray<PolarLabelListEntry> = points.map(
385
385
  // (point): PolarLabelListEntry => ({
386
386
  // value: point.value,
@@ -399,30 +399,32 @@ function RadarLabelListProvider({
399
399
  // }),
400
400
  // );
401
401
 
402
- const labelListEntries: ReadonlyArray<CartesianLabelListEntry> = points.map((
403
- point,
404
- ): CartesianLabelListEntry => {
405
- const viewBox: TrapezoidViewBox = {
406
- x: point.x,
407
- y: point.y,
408
- width: 0,
409
- lowerWidth: 0,
410
- upperWidth: 0,
411
- height: 0,
412
- };
413
- return {
414
- ...viewBox,
415
- value: point.value ?? '',
416
- payload: point.payload,
417
- parentViewBox: undefined,
418
- viewBox,
419
- fill: undefined,
420
- };
421
- });
402
+ const labelListEntries: ReadonlyArray<CartesianLabelListEntry> = points.map(
403
+ (point): CartesianLabelListEntry => {
404
+ const viewBox: TrapezoidViewBox = {
405
+ x: point.x,
406
+ y: point.y,
407
+ width: 0,
408
+ lowerWidth: 0,
409
+ upperWidth: 0,
410
+ height: 0,
411
+ };
412
+ return {
413
+ ...viewBox,
414
+ value: point.value ?? '',
415
+ payload: point.payload,
416
+ parentViewBox: undefined,
417
+ viewBox,
418
+ fill: undefined,
419
+ };
420
+ },
421
+ );
422
422
 
423
- return <CartesianLabelListContextProvider
424
- value={showLabels ? labelListEntries : undefined}
425
- >{children}</CartesianLabelListContextProvider>;
423
+ return (
424
+ <CartesianLabelListContextProvider value={showLabels ? labelListEntries : undefined}>
425
+ {children}
426
+ </CartesianLabelListContextProvider>
427
+ );
426
428
  }
427
429
 
428
430
  function StaticPolygon({
@@ -462,20 +464,24 @@ function StaticPolygon({
462
464
  } else if (typeof shape === 'function') {
463
465
  radar = shape({ ...props, points });
464
466
  } else {
465
- radar = <Polygon
466
- {...svgPropertiesAndEvents(props)}
467
- onMouseEnter={handleMouseEnter}
468
- onMouseLeave={handleMouseLeave}
469
- points={points}
470
- baseLinePoints={isRange ? baseLinePoints : undefined}
471
- connectNulls={connectNulls}
472
- />;
467
+ radar = (
468
+ <Polygon
469
+ {...svgPropertiesAndEvents(props)}
470
+ onMouseEnter={handleMouseEnter}
471
+ onMouseLeave={handleMouseLeave}
472
+ points={points}
473
+ baseLinePoints={isRange ? baseLinePoints : undefined}
474
+ connectNulls={connectNulls}
475
+ />
476
+ );
473
477
  }
474
478
 
475
- return <Layer className="recharts-radar-polygon">
476
- {radar}
477
- <RadarDotsWrapper props={props} points={points} />
478
- </Layer>;
479
+ return (
480
+ <Layer className="recharts-radar-polygon">
481
+ {radar}
482
+ <RadarDotsWrapper props={props} points={points} />
483
+ </Layer>
484
+ );
479
485
  }
480
486
 
481
487
  const defaultRadarAnimateItems: AnimationInterpolateFn<RadarPoint, PolarLayout> = (
@@ -553,49 +559,51 @@ function PolygonWithAnimation({
553
559
 
554
560
  if (layout == null) return null;
555
561
 
556
- return <RadarLabelListProvider showLabels={!isAnimating} points={points}>
557
- <AnimatedItems
558
- animationInput={animationInput}
559
- animationIdPrefix="recharts-radar-"
560
- items={points}
561
- previousItemsRef={previousPointsRef}
562
- isAnimationActive={isAnimationActive}
563
- animationBegin={animationBegin}
564
- animationDuration={animationDuration}
565
- animationEasing={animationEasing}
566
- onAnimationStart={handleAnimationStart}
567
- onAnimationEnd={handleAnimationEnd}
568
- animationInterpolateFn={animationInterpolateFn}
569
- animationMatchBy={animationMatchBy}
570
- layout={layout}
571
- >
572
- {(stepData, animationElapsedTime) => {
573
- const stepBaseLinePoints =
574
- animationElapsedTime === 1
575
- ? baseLinePoints
576
- : animationInterpolateFn(baseLineAnimationItems, animationElapsedTime, layout);
577
- baseLineAnimationState.syncStepValue(stepBaseLinePoints, animationElapsedTime);
578
- return <StaticPolygon
579
- points={stepData}
580
- baseLinePoints={stepBaseLinePoints}
581
- props={props}
582
- />;
583
- }}
584
- </AnimatedItems>
585
- <LabelListFromLabelProp label={props.label} />
586
- {props.children}
587
- </RadarLabelListProvider>;
562
+ return (
563
+ <RadarLabelListProvider showLabels={!isAnimating} points={points}>
564
+ <AnimatedItems
565
+ animationInput={animationInput}
566
+ animationIdPrefix="recharts-radar-"
567
+ items={points}
568
+ previousItemsRef={previousPointsRef}
569
+ isAnimationActive={isAnimationActive}
570
+ animationBegin={animationBegin}
571
+ animationDuration={animationDuration}
572
+ animationEasing={animationEasing}
573
+ onAnimationStart={handleAnimationStart}
574
+ onAnimationEnd={handleAnimationEnd}
575
+ animationInterpolateFn={animationInterpolateFn}
576
+ animationMatchBy={animationMatchBy}
577
+ layout={layout}
578
+ >
579
+ {(stepData, animationElapsedTime) => {
580
+ const stepBaseLinePoints =
581
+ animationElapsedTime === 1
582
+ ? baseLinePoints
583
+ : animationInterpolateFn(baseLineAnimationItems, animationElapsedTime, layout);
584
+ baseLineAnimationState.syncStepValue(stepBaseLinePoints, animationElapsedTime);
585
+ return (
586
+ <StaticPolygon points={stepData} baseLinePoints={stepBaseLinePoints} props={props} />
587
+ );
588
+ }}
589
+ </AnimatedItems>
590
+ <LabelListFromLabelProp label={props.label} />
591
+ {props.children}
592
+ </RadarLabelListProvider>
593
+ );
588
594
  }
589
595
 
590
596
  function RenderPolygon(props: InternalRadarProps) {
591
597
  const previousPointsRef = useRef<ReadonlyArray<RadarPoint> | undefined>(undefined);
592
598
  const previousBaseLinePointsRef = useRef<ReadonlyArray<RadarPoint> | undefined>(undefined);
593
599
 
594
- return <PolygonWithAnimation
595
- props={props}
596
- previousPointsRef={previousPointsRef}
597
- previousBaseLinePointsRef={previousBaseLinePointsRef}
598
- />;
600
+ return (
601
+ <PolygonWithAnimation
602
+ props={props}
603
+ previousPointsRef={previousPointsRef}
604
+ previousBaseLinePointsRef={previousBaseLinePointsRef}
605
+ />
606
+ );
599
607
  }
600
608
 
601
609
  export const defaultRadarProps = {
@@ -628,41 +636,39 @@ function RadarWithState(props: InternalRadarProps) {
628
636
 
629
637
  const layerClass = clsx('recharts-radar', className);
630
638
 
631
- return <ZIndexLayer zIndex={props.zIndex}>
632
- <Layer className={layerClass}>
633
- <RenderPolygon {...props} />
634
- </Layer>
635
- <ActivePoints
636
- points={points}
637
- mainColor={getLegendItemColor(props.stroke, props.fill)}
638
- itemDataKey={props.dataKey}
639
- activeDot={props.activeDot}
640
- />
641
- </ZIndexLayer>;
639
+ return (
640
+ <ZIndexLayer zIndex={props.zIndex}>
641
+ <Layer className={layerClass}>
642
+ <RenderPolygon {...props} />
643
+ </Layer>
644
+ <ActivePoints
645
+ points={points}
646
+ mainColor={getLegendItemColor(props.stroke, props.fill)}
647
+ itemDataKey={props.dataKey}
648
+ activeDot={props.activeDot}
649
+ />
650
+ </ZIndexLayer>
651
+ );
642
652
  }
643
653
 
644
654
  function RadarImpl(props: WithIdRequired<PropsWithDefaults>) {
645
655
  const isPanorama = useIsPanorama();
646
- const radarPoints = useAppSelector(
647
- (state) => selectRadarPoints(
648
- state,
649
- props.radiusAxisId,
650
- props.angleAxisId,
651
- isPanorama,
652
- props.id,
653
- ),
656
+ const radarPoints = useAppSelector((state) =>
657
+ selectRadarPoints(state, props.radiusAxisId, props.angleAxisId, isPanorama, props.id),
654
658
  );
655
659
 
656
660
  if (radarPoints?.points == null) {
657
661
  return null;
658
662
  }
659
663
 
660
- return <RadarWithState
661
- {...props}
662
- points={radarPoints?.points}
663
- baseLinePoints={radarPoints?.baseLinePoints}
664
- isRange={radarPoints?.isRange}
665
- />;
664
+ return (
665
+ <RadarWithState
666
+ {...props}
667
+ points={radarPoints?.points}
668
+ baseLinePoints={radarPoints?.baseLinePoints}
669
+ isRange={radarPoints?.isRange}
670
+ />
671
+ );
666
672
  }
667
673
 
668
674
  /**
@@ -673,31 +679,35 @@ export function Radar<DataPointType = any, DataValueType = any>(
673
679
  outsideProps: Props<DataPointType, DataValueType>,
674
680
  ) {
675
681
  const props: PropsWithDefaults = resolveDefaultProps(outsideProps, defaultRadarProps);
676
- return <RegisterGraphicalItemId id={props.id} type="radar">
677
- {(id) => <>
678
- <SetPolarGraphicalItem
679
- type="radar"
680
- id={id}
681
- data={undefined}
682
- dataKey={props.dataKey}
683
- hide={props.hide}
684
- angleAxisId={props.angleAxisId}
685
- radiusAxisId={props.radiusAxisId}
686
- />
687
- <SetPolarLegendPayload legendPayload={computeLegendPayloadFromRadarSectors(props)} />
688
- <SetRadarTooltipEntrySettings
689
- dataKey={props.dataKey}
690
- stroke={props.stroke}
691
- strokeWidth={props.strokeWidth}
692
- fill={props.fill}
693
- name={props.name}
694
- hide={props.hide}
695
- tooltipType={props.tooltipType}
696
- id={id}
697
- />
698
- <RadarImpl {...props} id={id} />
699
- </>}
700
- </RegisterGraphicalItemId>;
682
+ return (
683
+ <RegisterGraphicalItemId id={props.id} type="radar">
684
+ {(id) => (
685
+ <>
686
+ <SetPolarGraphicalItem
687
+ type="radar"
688
+ id={id}
689
+ data={undefined}
690
+ dataKey={props.dataKey}
691
+ hide={props.hide}
692
+ angleAxisId={props.angleAxisId}
693
+ radiusAxisId={props.radiusAxisId}
694
+ />
695
+ <SetPolarLegendPayload legendPayload={computeLegendPayloadFromRadarSectors(props)} />
696
+ <SetRadarTooltipEntrySettings
697
+ dataKey={props.dataKey}
698
+ stroke={props.stroke}
699
+ strokeWidth={props.strokeWidth}
700
+ fill={props.fill}
701
+ name={props.name}
702
+ hide={props.hide}
703
+ tooltipType={props.tooltipType}
704
+ id={id}
705
+ />
706
+ <RadarImpl {...props} id={id} />
707
+ </>
708
+ )}
709
+ </RegisterGraphicalItemId>
710
+ );
701
711
  }
702
712
 
703
713
  Radar.displayName = 'Radar';