@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
@@ -59,16 +59,14 @@ export interface BarRectangleItem extends RectangleProps {
59
59
  stackedBarStart: number | undefined;
60
60
  originalDataIndex: number;
61
61
  }
62
- export type BarShapeProps =
63
- BarRectangleItem & ShapeAnimationProps & {
62
+ export type BarShapeProps = BarRectangleItem &
63
+ ShapeAnimationProps & {
64
64
  isActive: boolean;
65
65
  index: number;
66
66
  };
67
67
  export type BarBackgroundShapeProps = Omit<BarShapeProps, 'value' | 'tooltipPosition'>;
68
- interface BarProps<DataPointType, ValueAxisType> extends DataConsumer<
69
- DataPointType,
70
- ValueAxisType
71
- >, ZIndexable {
68
+ interface BarProps<DataPointType, ValueAxisType>
69
+ extends DataConsumer<DataPointType, ValueAxisType>, ZIndexable {
72
70
  className?: string;
73
71
  index?: Key;
74
72
  xAxisId?: AxisId;
@@ -99,8 +97,11 @@ interface BarProps<DataPointType, ValueAxisType> extends DataConsumer<
99
97
  label?: ImplicitLabelListType;
100
98
  zIndex?: number;
101
99
  }
102
- type BarMouseEvent =
103
- (data: BarRectangleItem, index: number, event: NativeMouseEvent<SVGGElement>) => void;
100
+ type BarMouseEvent = (
101
+ data: BarRectangleItem,
102
+ index: number,
103
+ event: NativeMouseEvent<SVGGElement>,
104
+ ) => void;
104
105
  interface BarEvents {
105
106
  onClick: BarMouseEvent;
106
107
  onMouseEnter: BarMouseEvent;
@@ -145,13 +146,13 @@ type InternalBarProps = {
145
146
  id: GraphicalItemId;
146
147
  label?: ImplicitLabelListType;
147
148
  };
148
- type BarSvgProps =
149
- Omit<
150
- PresentationAttributesAdaptChildEvent<BarRectangleItem, SVGGElement>,
151
- 'radius' | 'name' | 'ref'
152
- >;
153
- export type Props<DataPointType = any, ValueAxisType = any> =
154
- Partial<BarEvents> & BarProps<DataPointType, ValueAxisType> & Omit<BarSvgProps, keyof BarEvents>;
149
+ type BarSvgProps = Omit<
150
+ PresentationAttributesAdaptChildEvent<BarRectangleItem, SVGGElement>,
151
+ 'radius' | 'name' | 'ref'
152
+ >;
153
+ export type Props<DataPointType = any, ValueAxisType = any> = Partial<BarEvents> &
154
+ BarProps<DataPointType, ValueAxisType> &
155
+ Omit<BarSvgProps, keyof BarEvents>;
155
156
  type InternalProps = BarSvgProps & InternalBarProps;
156
157
  type BarBackgroundProps = {
157
158
  background?: ActiveShape<BarBackgroundShapeProps, SVGPathElement>;
@@ -159,14 +160,12 @@ type BarBackgroundProps = {
159
160
  dataKey: DataKey<any> | undefined;
160
161
  allOtherBarProps: InternalProps;
161
162
  };
162
- type BarRectanglesProps =
163
- InternalProps & {
164
- data: ReadonlyArray<BarRectangleItem> | undefined;
165
- };
166
- type BarImplProps =
167
- Omit<InternalBarProps, 'layout' | 'data'> & {
168
- children?: OctaneNode;
169
- };
163
+ type BarRectanglesProps = InternalProps & {
164
+ data: ReadonlyArray<BarRectangleItem> | undefined;
165
+ };
166
+ type BarImplProps = Omit<InternalBarProps, 'layout' | 'data'> & {
167
+ children?: OctaneNode;
168
+ };
170
169
  // Port of cartesian/Bar.tsx — the bar graphical item: redux registration
171
170
  // (graphical item, legend, tooltip settings), store-computed rectangles,
172
171
  // background bars, active-bar highlight, stack clipping, labels, animation.
@@ -243,53 +242,45 @@ const computeLegendPayloadFromBarData = (props: Props) => {
243
242
  ];
244
243
  };
245
244
 
246
- const SetBarTooltipEntrySettings = memo((
247
- props: Pick<
248
- InternalProps,
249
- | 'dataKey'
250
- | 'stroke'
251
- | 'strokeWidth'
252
- | 'fill'
253
- | 'name'
254
- | 'hide'
255
- | 'unit'
256
- | 'formatter'
257
- | 'tooltipType'
258
- | 'id'
259
- >,
260
- ) => {
261
- const {
262
- dataKey,
263
- stroke,
264
- strokeWidth,
265
- fill,
266
- name,
267
- hide,
268
- unit,
269
- formatter,
270
- tooltipType,
271
- id,
272
- } = props;
273
- const tooltipEntrySettings: TooltipPayloadConfiguration = {
274
- dataDefinedOnItem: undefined,
275
- getPosition: noop,
276
- settings: {
277
- stroke,
278
- strokeWidth,
279
- fill,
280
- dataKey,
281
- nameKey: undefined,
282
- name: getTooltipNameProp(name, dataKey),
283
- hide,
284
- type: tooltipType,
285
- color: fill,
286
- unit,
287
- formatter,
288
- graphicalItemId: id,
289
- },
290
- };
291
- return <SetTooltipEntrySettings tooltipEntrySettings={tooltipEntrySettings} />;
292
- });
245
+ const SetBarTooltipEntrySettings = memo(
246
+ (
247
+ props: Pick<
248
+ InternalProps,
249
+ | 'dataKey'
250
+ | 'stroke'
251
+ | 'strokeWidth'
252
+ | 'fill'
253
+ | 'name'
254
+ | 'hide'
255
+ | 'unit'
256
+ | 'formatter'
257
+ | 'tooltipType'
258
+ | 'id'
259
+ >,
260
+ ) => {
261
+ const { dataKey, stroke, strokeWidth, fill, name, hide, unit, formatter, tooltipType, id } =
262
+ props;
263
+ const tooltipEntrySettings: TooltipPayloadConfiguration = {
264
+ dataDefinedOnItem: undefined,
265
+ getPosition: noop,
266
+ settings: {
267
+ stroke,
268
+ strokeWidth,
269
+ fill,
270
+ dataKey,
271
+ nameKey: undefined,
272
+ name: getTooltipNameProp(name, dataKey),
273
+ hide,
274
+ type: tooltipType,
275
+ color: fill,
276
+ unit,
277
+ formatter,
278
+ graphicalItemId: id,
279
+ },
280
+ };
281
+ return <SetTooltipEntrySettings tooltipEntrySettings={tooltipEntrySettings} />;
282
+ },
283
+ );
293
284
 
294
285
  function BarBackground(props: BarBackgroundProps) {
295
286
  const activeIndex = useAppSelector(selectActiveTooltipIndex);
@@ -315,33 +306,35 @@ function BarBackground(props: BarBackgroundProps) {
315
306
  return null;
316
307
  }
317
308
  const backgroundProps = svgPropertiesNoEventsFromUnknown(backgroundFromProps);
318
- return <ZIndexLayer
319
- zIndex={getZIndexFromUnknown(backgroundFromProps, DefaultZIndexes.barBackground)}
320
- >{data.map((entry, i) => {
321
- const { value, background: backgroundFromDataEntry, tooltipPosition, ...rest } = entry;
322
- if (!backgroundFromDataEntry) {
323
- return null;
324
- }
325
- const onMouseEnter = onMouseEnterFromContext(entry, entry.originalDataIndex);
326
- const onMouseLeave = onMouseLeaveFromContext(entry, entry.originalDataIndex);
327
- const onClick = onClickFromContext(entry, entry.originalDataIndex);
328
- const barRectangleProps: BarBackgroundRectangleProps = {
329
- option: backgroundFromProps,
330
- isActive: String(entry.originalDataIndex) === activeIndex,
331
- ...rest,
332
- fill: '#eee',
333
- ...backgroundFromDataEntry,
334
- ...backgroundProps,
335
- ...adaptEventsOfChild(restOfAllOtherProps, entry, i),
336
- onMouseEnter,
337
- onMouseLeave,
338
- onClick,
339
- dataKey,
340
- index: i,
341
- className: 'recharts-bar-background-rectangle',
342
- };
343
- return <BarBackgroundRectangle key={'background-bar-' + i} {...barRectangleProps} />;
344
- })}</ZIndexLayer>;
309
+ return (
310
+ <ZIndexLayer zIndex={getZIndexFromUnknown(backgroundFromProps, DefaultZIndexes.barBackground)}>
311
+ {data.map((entry, i) => {
312
+ const { value, background: backgroundFromDataEntry, tooltipPosition, ...rest } = entry;
313
+ if (!backgroundFromDataEntry) {
314
+ return null;
315
+ }
316
+ const onMouseEnter = onMouseEnterFromContext(entry, entry.originalDataIndex);
317
+ const onMouseLeave = onMouseLeaveFromContext(entry, entry.originalDataIndex);
318
+ const onClick = onClickFromContext(entry, entry.originalDataIndex);
319
+ const barRectangleProps: BarBackgroundRectangleProps = {
320
+ option: backgroundFromProps,
321
+ isActive: String(entry.originalDataIndex) === activeIndex,
322
+ ...rest,
323
+ fill: '#eee',
324
+ ...backgroundFromDataEntry,
325
+ ...backgroundProps,
326
+ ...adaptEventsOfChild(restOfAllOtherProps, entry, i),
327
+ onMouseEnter,
328
+ onMouseLeave,
329
+ onClick,
330
+ dataKey,
331
+ index: i,
332
+ className: 'recharts-bar-background-rectangle',
333
+ };
334
+ return <BarBackgroundRectangle key={'background-bar-' + i} {...barRectangleProps} />;
335
+ })}
336
+ </ZIndexLayer>
337
+ );
345
338
  }
346
339
 
347
340
  function BarLabelListProvider(props: {
@@ -350,39 +343,41 @@ function BarLabelListProvider(props: {
350
343
  rects: ReadonlyArray<BarRectangleItem> | undefined;
351
344
  }) @{
352
345
  const { showLabels, children, rects } = props;
353
- const labelListEntries: ReadonlyArray<CartesianLabelListEntry> | undefined = rects?.map((
354
- entry: BarRectangleItem,
355
- ) => {
356
- const viewBox: TrapezoidViewBox = {
357
- x: entry.x,
358
- y: entry.y,
359
- width: entry.width,
360
- lowerWidth: entry.width,
361
- upperWidth: entry.width,
362
- height: entry.height,
363
- };
364
- return {
365
- ...viewBox,
366
- value: entry.value,
367
- payload: entry.payload,
368
- parentViewBox: entry.parentViewBox,
369
- viewBox,
370
- fill: entry.fill,
371
- };
372
- });
373
- <CartesianLabelListContextProvider
374
- value={showLabels ? labelListEntries : undefined}
375
- >{children}</CartesianLabelListContextProvider>
346
+ const labelListEntries: ReadonlyArray<CartesianLabelListEntry> | undefined = rects?.map(
347
+ (entry: BarRectangleItem) => {
348
+ const viewBox: TrapezoidViewBox = {
349
+ x: entry.x,
350
+ y: entry.y,
351
+ width: entry.width,
352
+ lowerWidth: entry.width,
353
+ upperWidth: entry.width,
354
+ height: entry.height,
355
+ };
356
+ return {
357
+ ...viewBox,
358
+ value: entry.value,
359
+ payload: entry.payload,
360
+ parentViewBox: entry.parentViewBox,
361
+ viewBox,
362
+ fill: entry.fill,
363
+ };
364
+ },
365
+ );
366
+ <CartesianLabelListContextProvider value={showLabels ? labelListEntries : undefined}>
367
+ {children}
368
+ </CartesianLabelListContextProvider>
376
369
  }
377
370
 
378
- function BarRectangleWithActiveState(props: ShapeAnimationProps & {
379
- shape: ActiveShape<BarShapeProps, SVGPathElement>;
380
- activeBar: ActiveShape<BarShapeProps, SVGPathElement>;
381
- baseProps: WithoutId<SVGPropsNoEvents<BarRectanglesProps>>;
382
- entry: BarRectangleItem;
383
- index: number;
384
- dataKey: DataKey<any> | undefined;
385
- }) {
371
+ function BarRectangleWithActiveState(
372
+ props: ShapeAnimationProps & {
373
+ shape: ActiveShape<BarShapeProps, SVGPathElement>;
374
+ activeBar: ActiveShape<BarShapeProps, SVGPathElement>;
375
+ baseProps: WithoutId<SVGPropsNoEvents<BarRectanglesProps>>;
376
+ entry: BarRectangleItem;
377
+ index: number;
378
+ dataKey: DataKey<any> | undefined;
379
+ },
380
+ ) {
386
381
  const { shape, activeBar, baseProps, entry, index, dataKey } = props;
387
382
  const activeIndex = useAppSelector(selectActiveTooltipIndex);
388
383
  const activeDataKey = useAppSelector(selectActiveTooltipDataKey);
@@ -390,8 +385,9 @@ function BarRectangleWithActiveState(props: ShapeAnimationProps & {
390
385
  // non-shared tooltips) the active dataKey. originalDataIndex matches
391
386
  // against the pre-filter data slice.
392
387
  const isActive: boolean =
393
- activeBar && String(entry.originalDataIndex) === activeIndex &&
394
- (activeDataKey == null || dataKey === activeDataKey);
388
+ activeBar &&
389
+ String(entry.originalDataIndex) === activeIndex &&
390
+ (activeDataKey == null || dataKey === activeDataKey);
395
391
  const [stayInLayer, setStayInLayer] = useState(false);
396
392
  const [hasMountedActive, setHasMountedActive] = useState(false);
397
393
  useEffect(() => {
@@ -429,53 +425,63 @@ function BarRectangleWithActiveState(props: ShapeAnimationProps & {
429
425
  } else {
430
426
  option = shape;
431
427
  }
432
- const content = <BarRectangle
433
- {...baseProps}
434
- name={String(baseProps.name)}
435
- {...entry}
436
- isActive={isVisuallyActive}
437
- option={option}
438
- index={index}
439
- dataKey={dataKey}
440
- animationElapsedTime={props.animationElapsedTime}
441
- isAnimating={props.isAnimating}
442
- isEntrance={props.isEntrance}
443
- onTransitionEnd={handleTransitionEnd}
444
- />;
428
+ const content = (
429
+ <BarRectangle
430
+ {...baseProps}
431
+ name={String(baseProps.name)}
432
+ {...entry}
433
+ isActive={isVisuallyActive}
434
+ option={option}
435
+ index={index}
436
+ dataKey={dataKey}
437
+ animationElapsedTime={props.animationElapsedTime}
438
+ isAnimating={props.isAnimating}
439
+ isEntrance={props.isEntrance}
440
+ onTransitionEnd={handleTransitionEnd}
441
+ />
442
+ );
445
443
  if (shouldRenderInLayer) {
446
- return <ZIndexLayer zIndex={DefaultZIndexes.activeBar}>
447
- <BarStackClipLayer index={entry.originalDataIndex}>{content}</BarStackClipLayer>
448
- </ZIndexLayer>;
444
+ return (
445
+ <ZIndexLayer zIndex={DefaultZIndexes.activeBar}>
446
+ <BarStackClipLayer index={entry.originalDataIndex}>{content}</BarStackClipLayer>
447
+ </ZIndexLayer>
448
+ );
449
449
  }
450
450
  return content;
451
451
  }
452
452
 
453
- function BarRectangleNeverActive(props: ShapeAnimationProps & {
454
- shape: ActiveShape<BarShapeProps, SVGPathElement>;
455
- baseProps: WithoutId<SVGPropsNoEvents<BarRectanglesProps>>;
456
- entry: BarRectangleItem;
457
- index: number;
458
- dataKey: DataKey<any> | undefined;
459
- }) {
453
+ function BarRectangleNeverActive(
454
+ props: ShapeAnimationProps & {
455
+ shape: ActiveShape<BarShapeProps, SVGPathElement>;
456
+ baseProps: WithoutId<SVGPropsNoEvents<BarRectanglesProps>>;
457
+ entry: BarRectangleItem;
458
+ index: number;
459
+ dataKey: DataKey<any> | undefined;
460
+ },
461
+ ) {
460
462
  const { shape, baseProps, entry, index, dataKey } = props;
461
- return <BarRectangle
462
- {...baseProps}
463
- name={String(baseProps.name)}
464
- {...entry}
465
- isActive={false}
466
- option={shape}
467
- index={index}
468
- dataKey={dataKey}
469
- animationElapsedTime={props.animationElapsedTime}
470
- isAnimating={props.isAnimating}
471
- isEntrance={props.isEntrance}
472
- />;
463
+ return (
464
+ <BarRectangle
465
+ {...baseProps}
466
+ name={String(baseProps.name)}
467
+ {...entry}
468
+ isActive={false}
469
+ option={shape}
470
+ index={index}
471
+ dataKey={dataKey}
472
+ animationElapsedTime={props.animationElapsedTime}
473
+ isAnimating={props.isAnimating}
474
+ isEntrance={props.isEntrance}
475
+ />
476
+ );
473
477
  }
474
478
 
475
- function BarRectangles(rectanglesProps: ShapeAnimationProps & {
476
- data: ReadonlyArray<BarRectangleItem> | undefined;
477
- props: BarRectanglesProps;
478
- }) {
479
+ function BarRectangles(
480
+ rectanglesProps: ShapeAnimationProps & {
481
+ data: ReadonlyArray<BarRectangleItem> | undefined;
482
+ props: BarRectanglesProps;
483
+ },
484
+ ) {
479
485
  const { data, props, animationElapsedTime, isAnimating, isEntrance } = rectanglesProps;
480
486
  const { id, ...baseProps } = svgPropertiesNoEvents(props) ?? {};
481
487
  const { shape, dataKey, activeBar } = props;
@@ -491,44 +497,50 @@ function BarRectangles(rectanglesProps: ShapeAnimationProps & {
491
497
  if (!data) {
492
498
  return null;
493
499
  }
494
- return <>
495
- {data.map((entry, i) => {
496
- return <BarStackClipLayer
497
- index={entry.originalDataIndex}
498
- key={'rectangle-' + entry?.x + '-' + entry?.y + '-' + entry?.value + '-' + i}
499
- className="recharts-bar-rectangle"
500
- {...adaptEventsOfChild(restOfAllOtherProps, entry, i)}
501
- onMouseEnter={onMouseEnterFromContext(entry, entry.originalDataIndex)}
502
- onMouseLeave={onMouseLeaveFromContext(entry, entry.originalDataIndex)}
503
- onClick={onClickFromContext(entry, entry.originalDataIndex)}
504
- >
505
- {activeBar
506
- ? <BarRectangleWithActiveState
507
- shape={shape}
508
- activeBar={activeBar}
509
- baseProps={baseProps}
510
- entry={entry}
511
- index={i}
512
- dataKey={dataKey}
513
- animationElapsedTime={animationElapsedTime}
514
- isAnimating={isAnimating}
515
- isEntrance={isEntrance}
516
- />
517
- : // activeBar falsy: the hook-free variant (skips the active-index
518
- // selectors entirely — they'd never be used).
519
- <BarRectangleNeverActive
520
- shape={shape}
521
- baseProps={baseProps}
522
- entry={entry}
523
- index={i}
524
- dataKey={dataKey}
525
- animationElapsedTime={animationElapsedTime}
526
- isAnimating={isAnimating}
527
- isEntrance={isEntrance}
528
- />}
529
- </BarStackClipLayer>;
530
- })}
531
- </>;
500
+ return (
501
+ <>
502
+ {data.map((entry, i) => {
503
+ return (
504
+ <BarStackClipLayer
505
+ index={entry.originalDataIndex}
506
+ key={'rectangle-' + entry?.x + '-' + entry?.y + '-' + entry?.value + '-' + i}
507
+ className="recharts-bar-rectangle"
508
+ {...adaptEventsOfChild(restOfAllOtherProps, entry, i)}
509
+ onMouseEnter={onMouseEnterFromContext(entry, entry.originalDataIndex)}
510
+ onMouseLeave={onMouseLeaveFromContext(entry, entry.originalDataIndex)}
511
+ onClick={onClickFromContext(entry, entry.originalDataIndex)}
512
+ >
513
+ {activeBar ? (
514
+ <BarRectangleWithActiveState
515
+ shape={shape}
516
+ activeBar={activeBar}
517
+ baseProps={baseProps}
518
+ entry={entry}
519
+ index={i}
520
+ dataKey={dataKey}
521
+ animationElapsedTime={animationElapsedTime}
522
+ isAnimating={isAnimating}
523
+ isEntrance={isEntrance}
524
+ />
525
+ ) : (
526
+ // activeBar falsy: the hook-free variant (skips the active-index
527
+ // selectors entirely — they'd never be used).
528
+ <BarRectangleNeverActive
529
+ shape={shape}
530
+ baseProps={baseProps}
531
+ entry={entry}
532
+ index={i}
533
+ dataKey={dataKey}
534
+ animationElapsedTime={animationElapsedTime}
535
+ isAnimating={isAnimating}
536
+ isEntrance={isEntrance}
537
+ />
538
+ )}
539
+ </BarStackClipLayer>
540
+ );
541
+ })}
542
+ </>
543
+ );
532
544
  }
533
545
 
534
546
  const defaultBarAnimateItems: AnimationInterpolateFn<BarRectangleItem, CartesianLayout> = (
@@ -552,9 +564,7 @@ const defaultBarAnimateItems: AnimationInterpolateFn<BarRectangleItem, Cartesian
552
564
  },
553
565
  ];
554
566
  }
555
- return [
556
- { ...item.prev, width: interpolate(item.prev.width, 0, animationElapsedTime) },
557
- ];
567
+ return [{ ...item.prev, width: interpolate(item.prev.width, 0, animationElapsedTime) }];
558
568
  }
559
569
  if (item.status === 'matched') {
560
570
  return [
@@ -606,35 +616,39 @@ function RectanglesWithAnimation(rectanglesWithAnimationProps: {
606
616
  props.onAnimationStart,
607
617
  props.onAnimationEnd,
608
618
  );
609
- return <BarLabelListProvider showLabels={!isAnimating} rects={data}>
610
- <AnimatedItems
611
- animationInput={data}
612
- animationIdPrefix="recharts-bar-"
613
- items={data}
614
- previousItemsRef={previousRectanglesRef}
615
- isAnimationActive={isAnimationActive}
616
- animationBegin={animationBegin}
617
- animationDuration={animationDuration}
618
- animationEasing={animationEasing}
619
- onAnimationStart={handleAnimationStart}
620
- onAnimationEnd={handleAnimationEnd}
621
- animationInterpolateFn={animationInterpolateFn}
622
- animationMatchBy={props.animationMatchBy}
623
- layout={layout}
624
- >
625
- {(stepData, animationElapsedTime, isEntrance) => <Layer>
626
- <BarRectangles
627
- props={props}
628
- data={stepData}
629
- animationElapsedTime={animationElapsedTime}
630
- isAnimating={isAnimating || animationElapsedTime < 1}
631
- isEntrance={isEntrance}
632
- />
633
- </Layer>}
634
- </AnimatedItems>
635
- <LabelListFromLabelProp label={props.label} />
636
- {props.children}
637
- </BarLabelListProvider>;
619
+ return (
620
+ <BarLabelListProvider showLabels={!isAnimating} rects={data}>
621
+ <AnimatedItems
622
+ animationInput={data}
623
+ animationIdPrefix="recharts-bar-"
624
+ items={data}
625
+ previousItemsRef={previousRectanglesRef}
626
+ isAnimationActive={isAnimationActive}
627
+ animationBegin={animationBegin}
628
+ animationDuration={animationDuration}
629
+ animationEasing={animationEasing}
630
+ onAnimationStart={handleAnimationStart}
631
+ onAnimationEnd={handleAnimationEnd}
632
+ animationInterpolateFn={animationInterpolateFn}
633
+ animationMatchBy={props.animationMatchBy}
634
+ layout={layout}
635
+ >
636
+ {(stepData, animationElapsedTime, isEntrance) => (
637
+ <Layer>
638
+ <BarRectangles
639
+ props={props}
640
+ data={stepData}
641
+ animationElapsedTime={animationElapsedTime}
642
+ isAnimating={isAnimating || animationElapsedTime < 1}
643
+ isEntrance={isEntrance}
644
+ />
645
+ </Layer>
646
+ )}
647
+ </AnimatedItems>
648
+ <LabelListFromLabelProp label={props.label} />
649
+ {props.children}
650
+ </BarLabelListProvider>
651
+ );
638
652
  }
639
653
 
640
654
  function RenderRectangles(props: InternalProps) {
@@ -725,8 +739,8 @@ function BarImpl(props: BarImplProps) {
725
739
  // octane divergence: cells arrive via registration (children render inside
726
740
  // the CellsContext provider below), not children introspection.
727
741
  const [cells, cellRegistry] = useCellRegistry();
728
- const rects: ReadonlyArray<BarRectangleItem> | undefined = useAppSelector(
729
- (state) => selectBarRectangles(state, props.id, isPanorama, cells),
742
+ const rects: ReadonlyArray<BarRectangleItem> | undefined = useAppSelector((state) =>
743
+ selectBarRectangles(state, props.id, isPanorama, cells),
730
744
  );
731
745
  if (layout !== 'vertical' && layout !== 'horizontal') {
732
746
  return null;
@@ -738,32 +752,34 @@ function BarImpl(props: BarImplProps) {
738
752
  } else {
739
753
  errorBarOffset = layout === 'vertical' ? firstDataPoint.height / 2 : firstDataPoint.width / 2;
740
754
  }
741
- return <SetErrorBarContext
742
- xAxisId={xAxisId}
743
- yAxisId={yAxisId}
744
- data={rects}
745
- dataPointFormatter={errorBarDataPointFormatter}
746
- errorBarOffset={errorBarOffset}
747
- >
748
- <CellsContext value={cellRegistry}>
749
- <BarWithState
750
- {...props}
751
- layout={layout}
752
- needClip={needClip}
753
- data={rects}
754
- xAxisId={xAxisId}
755
- yAxisId={yAxisId}
756
- hide={hide}
757
- legendType={legendType}
758
- minPointSize={minPointSize}
759
- activeBar={activeBar}
760
- animationBegin={animationBegin}
761
- animationDuration={animationDuration}
762
- animationEasing={animationEasing}
763
- isAnimationActive={isAnimationActive}
764
- />
765
- </CellsContext>
766
- </SetErrorBarContext>;
755
+ return (
756
+ <SetErrorBarContext
757
+ xAxisId={xAxisId}
758
+ yAxisId={yAxisId}
759
+ data={rects}
760
+ dataPointFormatter={errorBarDataPointFormatter}
761
+ errorBarOffset={errorBarOffset}
762
+ >
763
+ <CellsContext value={cellRegistry}>
764
+ <BarWithState
765
+ {...props}
766
+ layout={layout}
767
+ needClip={needClip}
768
+ data={rects}
769
+ xAxisId={xAxisId}
770
+ yAxisId={yAxisId}
771
+ hide={hide}
772
+ legendType={legendType}
773
+ minPointSize={minPointSize}
774
+ activeBar={activeBar}
775
+ animationBegin={animationBegin}
776
+ animationDuration={animationDuration}
777
+ animationEasing={animationEasing}
778
+ isAnimationActive={isAnimationActive}
779
+ />
780
+ </CellsContext>
781
+ </SetErrorBarContext>
782
+ );
767
783
  }
768
784
 
769
785
  export function computeBarRectangles({
@@ -797,16 +813,20 @@ export function computeBarRectangles({
797
813
  parentViewBox: CartesianViewBoxRequired;
798
814
  dataStartIndex: number;
799
815
  }) {
800
- const numericAxis =
801
- layout === 'horizontal' ? yAxis : xAxis;
802
- const stackedDomain = stackedData ? numericAxis.scale.domain() as readonly number[] : null;
816
+ const numericAxis = layout === 'horizontal' ? yAxis : xAxis;
817
+ const stackedDomain = stackedData ? (numericAxis.scale.domain() as readonly number[]) : null;
803
818
  const baseValue = getBaseValueOfBar({ numericAxis });
804
819
  const stackedBarStart: number | undefined = numericAxis.scale.map(baseValue);
805
820
  const rectangles = displayedData.map((entry, index) => {
806
- let value, x: number | null, y, width, height, background: Omit<BarRectangleType, 'x' | 'y'> & {
807
- x: number | null;
808
- y: number | null;
809
- };
821
+ let value,
822
+ x: number | null,
823
+ y,
824
+ width,
825
+ height,
826
+ background: Omit<BarRectangleType, 'x' | 'y'> & {
827
+ x: number | null;
828
+ y: number | null;
829
+ };
810
830
  if (stackedData) {
811
831
  // Use dataStartIndex to access the correct element in the full stackedData array
812
832
  const untruncatedValue = stackedData[index + dataStartIndex];
@@ -876,13 +896,16 @@ export function computeBarRectangles({
876
896
  // still draw something there). Sparse arrays stay index-stable via
877
897
  // originalDataIndex.
878
898
  if (
879
- x == null || y == null || width == null || height == null ||
880
- !hasCustomShape && (width === 0 || height === 0)
899
+ x == null ||
900
+ y == null ||
901
+ width == null ||
902
+ height == null ||
903
+ (!hasCustomShape && (width === 0 || height === 0))
881
904
  ) {
882
905
  return null;
883
906
  }
884
907
  return {
885
- ...entry as Record<string, unknown>,
908
+ ...(entry as Record<string, unknown>),
886
909
  stackedBarStart,
887
910
  x,
888
911
  y,
@@ -896,14 +919,13 @@ export function computeBarRectangles({
896
919
  tooltipPosition: { x: x + width / 2, y: y + height / 2 },
897
920
  parentViewBox,
898
921
  originalDataIndex: index,
899
- ...cells && cells[index] && cells[index].props as CellPropsFor<SVGPathElement>,
922
+ ...(cells && cells[index] && (cells[index].props as CellPropsFor<SVGPathElement>)),
900
923
  };
901
924
  });
902
925
  // This map returns only objects or null, so Boolean removes exactly the nulls.
903
926
  return rectangles.filter(
904
- Boolean as BooleanConstructor & ((rectangle: (typeof rectangles)[number]) => rectangle is NonNullable<
905
- typeof rectangle
906
- >),
927
+ Boolean as BooleanConstructor &
928
+ ((rectangle: (typeof rectangles)[number]) => rectangle is NonNullable<typeof rectangle>),
907
929
  );
908
930
  }
909
931
 
@@ -916,42 +938,46 @@ function BarFn<DataPointType = any, ValueAxisType = any>(
916
938
  const isPanorama = useIsPanorama();
917
939
  // Report all props to the store first, before any other hooks, to avoid
918
940
  // circular dependencies.
919
- return <RegisterGraphicalItemId id={props.id} type="bar">
920
- {(id) => <>
921
- <SetLegendPayload legendPayload={computeLegendPayloadFromBarData(props)} />
922
- <SetBarTooltipEntrySettings
923
- dataKey={props.dataKey}
924
- stroke={props.stroke}
925
- strokeWidth={props.strokeWidth}
926
- fill={props.fill}
927
- name={props.name}
928
- hide={props.hide}
929
- unit={props.unit}
930
- formatter={props.formatter}
931
- tooltipType={props.tooltipType}
932
- id={id}
933
- />
934
- <SetCartesianGraphicalItem
935
- type="bar"
936
- id={id}
937
- data={undefined}
938
- xAxisId={props.xAxisId}
939
- yAxisId={props.yAxisId}
940
- zAxisId={0}
941
- dataKey={props.dataKey}
942
- stackId={stackId}
943
- hide={props.hide}
944
- barSize={props.barSize}
945
- minPointSize={props.minPointSize}
946
- maxBarSize={props.maxBarSize}
947
- isPanorama={isPanorama}
948
- hasCustomShape={props.shape != null && props.shape !== defaultBarShape}
949
- />
950
- <ZIndexLayer zIndex={props.zIndex}>
951
- <BarImpl {...props} id={id} />
952
- </ZIndexLayer>
953
- </>}
954
- </RegisterGraphicalItemId>;
941
+ return (
942
+ <RegisterGraphicalItemId id={props.id} type="bar">
943
+ {(id) => (
944
+ <>
945
+ <SetLegendPayload legendPayload={computeLegendPayloadFromBarData(props)} />
946
+ <SetBarTooltipEntrySettings
947
+ dataKey={props.dataKey}
948
+ stroke={props.stroke}
949
+ strokeWidth={props.strokeWidth}
950
+ fill={props.fill}
951
+ name={props.name}
952
+ hide={props.hide}
953
+ unit={props.unit}
954
+ formatter={props.formatter}
955
+ tooltipType={props.tooltipType}
956
+ id={id}
957
+ />
958
+ <SetCartesianGraphicalItem
959
+ type="bar"
960
+ id={id}
961
+ data={undefined}
962
+ xAxisId={props.xAxisId}
963
+ yAxisId={props.yAxisId}
964
+ zAxisId={0}
965
+ dataKey={props.dataKey}
966
+ stackId={stackId}
967
+ hide={props.hide}
968
+ barSize={props.barSize}
969
+ minPointSize={props.minPointSize}
970
+ maxBarSize={props.maxBarSize}
971
+ isPanorama={isPanorama}
972
+ hasCustomShape={props.shape != null && props.shape !== defaultBarShape}
973
+ />
974
+ <ZIndexLayer zIndex={props.zIndex}>
975
+ <BarImpl {...props} id={id} />
976
+ </ZIndexLayer>
977
+ </>
978
+ )}
979
+ </RegisterGraphicalItemId>
980
+ );
955
981
  }
956
982
 
957
983
  /**