@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
@@ -49,100 +49,106 @@ import {
49
49
  *
50
50
  * @inline
51
51
  */
52
- export type ReferenceLineSegment =
53
- readonly [{
52
+ export type ReferenceLineSegment = readonly [
53
+ {
54
54
  x?: number | string;
55
55
  y?: number | string;
56
- }, {
56
+ },
57
+ {
57
58
  x?: number | string;
58
59
  y?: number | string;
59
- }];
60
+ },
61
+ ];
60
62
 
61
63
  type ReferenceCoordinateValue = number | string;
62
64
 
63
65
  interface ReferenceLineProps<
64
66
  XValueType extends ReferenceCoordinateValue = any,
65
67
  YValueType extends ReferenceCoordinateValue = any,
66
- > extends Overflowable, ZIndexable {
68
+ >
69
+ extends Overflowable, ZIndexable {
67
70
  /**
68
- * If defined, renders a horizontal line on this position.
69
- *
70
- * This value is using your chart's domain, so you will provide a data value instead of a pixel value.
71
- * ReferenceLine will internally calculate the correct pixel position.
72
- *
73
- * @example <ReferenceLine y="Page D" />
74
- */
71
+ * If defined, renders a horizontal line on this position.
72
+ *
73
+ * This value is using your chart's domain, so you will provide a data value instead of a pixel value.
74
+ * ReferenceLine will internally calculate the correct pixel position.
75
+ *
76
+ * @example <ReferenceLine y="Page D" />
77
+ */
75
78
  y?: YValueType;
76
79
  /**
77
- * If defined, renders a vertical line on this position.
78
- *
79
- * This value is using your chart's domain, so you will provide a data value instead of a pixel value.
80
- * ReferenceLine will internally calculate the correct pixel position.
81
- *
82
- * @example <ReferenceLine x="Monday" />
83
- */
80
+ * If defined, renders a vertical line on this position.
81
+ *
82
+ * This value is using your chart's domain, so you will provide a data value instead of a pixel value.
83
+ * ReferenceLine will internally calculate the correct pixel position.
84
+ *
85
+ * @example <ReferenceLine x="Monday" />
86
+ */
84
87
  x?: XValueType;
85
88
  /**
86
- * Tuple of coordinates. If defined, renders a diagonal line segment.
87
- */
88
- segment?: readonly [{
89
- x?: XValueType;
90
- y?: YValueType;
91
- }, {
92
- x?: XValueType;
93
- y?: YValueType;
94
- }];
89
+ * Tuple of coordinates. If defined, renders a diagonal line segment.
90
+ */
91
+ segment?: readonly [
92
+ {
93
+ x?: XValueType;
94
+ y?: YValueType;
95
+ },
96
+ {
97
+ x?: XValueType;
98
+ y?: YValueType;
99
+ },
100
+ ];
95
101
  /**
96
- * The position of the reference line when the axis has bandwidth
97
- * (e.g., a band scale). This determines where within the band
98
- * the line is drawn.
99
- * @defaultValue 'middle'
100
- */
102
+ * The position of the reference line when the axis has bandwidth
103
+ * (e.g., a band scale). This determines where within the band
104
+ * the line is drawn.
105
+ * @defaultValue 'middle'
106
+ */
101
107
  position?: BandPosition;
102
108
  className?: number | string;
103
109
  /**
104
- * The id of y-axis which is corresponding to the data.
105
- * Required when there are multiple YAxes.
106
- * @defaultValue 0
107
- */
110
+ * The id of y-axis which is corresponding to the data.
111
+ * Required when there are multiple YAxes.
112
+ * @defaultValue 0
113
+ */
108
114
  yAxisId?: number | string;
109
115
  /**
110
- * The id of x-axis which is corresponding to the data.
111
- * Required when there are multiple XAxes.
112
- * @defaultValue 0
113
- */
116
+ * The id of x-axis which is corresponding to the data.
117
+ * Required when there are multiple XAxes.
118
+ * @defaultValue 0
119
+ */
114
120
  xAxisId?: number | string;
115
121
  shape?: OctaneElement<SVGElement> | ((props: any) => OctaneElement<SVGElement>);
116
122
  /**
117
- * Renders a single label.
118
- *
119
- * - `false`: no labels are rendered
120
- * - `string` | `number`: the content of the label
121
- * - `object`: the props of LabelList component
122
- * - `OctaneElement`: a custom SVG label element, such as `<text>` or `<g>`.
123
- * HTML elements such as `<div>` are not valid inside the chart SVG and may trigger React DOM warnings.
124
- * - `function`: a render function of custom label
125
- *
126
- * @defaultValue false
127
- *
128
- * @see {@link https://recharts.github.io/en-US/examples/LineChartWithReferenceLines/ Reference elements with a label}
129
- */
123
+ * Renders a single label.
124
+ *
125
+ * - `false`: no labels are rendered
126
+ * - `string` | `number`: the content of the label
127
+ * - `object`: the props of LabelList component
128
+ * - `OctaneElement`: a custom SVG label element, such as `<text>` or `<g>`.
129
+ * HTML elements such as `<div>` are not valid inside the chart SVG and may trigger React DOM warnings.
130
+ * - `function`: a render function of custom label
131
+ *
132
+ * @defaultValue false
133
+ *
134
+ * @see {@link https://recharts.github.io/en-US/examples/LineChartWithReferenceLines/ Reference elements with a label}
135
+ */
130
136
  label?: ImplicitLabelType;
131
137
  /**
132
- * Z-Index of this component and its children. The higher the value,
133
- * the more on top it will be rendered.
134
- * Components with higher zIndex will appear in front of components with lower zIndex.
135
- * If undefined or 0, the content is rendered in the default layer without portals.
136
- *
137
- * @since 3.4
138
- * @defaultValue 400
139
- * @see {@link https://recharts.github.io/en-US/guide/zIndex/ Z-Index and layers guide}
140
- */
138
+ * Z-Index of this component and its children. The higher the value,
139
+ * the more on top it will be rendered.
140
+ * Components with higher zIndex will appear in front of components with lower zIndex.
141
+ * If undefined or 0, the content is rendered in the default layer without portals.
142
+ *
143
+ * @since 3.4
144
+ * @defaultValue 400
145
+ * @see {@link https://recharts.github.io/en-US/guide/zIndex/ Z-Index and layers guide}
146
+ */
141
147
  zIndex?: number;
142
148
  /**
143
- * The width of the stroke
144
- * @defaultValue 1
145
- */
149
+ * The width of the stroke
150
+ * @defaultValue 1
151
+ */
146
152
  strokeWidth?: number | string;
147
153
  }
148
154
 
@@ -155,8 +161,7 @@ interface ReferenceLineProps<
155
161
  export type Props<
156
162
  XValueType extends ReferenceCoordinateValue = any,
157
163
  YValueType extends ReferenceCoordinateValue = any,
158
- > =
159
- Omit<SVGProps<SVGLineElement>, 'viewBox'> & ReferenceLineProps<XValueType, YValueType>;
164
+ > = Omit<SVGProps<SVGLineElement>, 'viewBox'> & ReferenceLineProps<XValueType, YValueType>;
160
165
 
161
166
  const renderLine = (option: ReferenceLineProps['shape'], props: SVGProps<SVGLineElement>) => {
162
167
  let line;
@@ -167,9 +172,10 @@ const renderLine = (option: ReferenceLineProps['shape'], props: SVGProps<SVGLine
167
172
  line = option(props);
168
173
  } else {
169
174
  if (
170
- !isWellBehavedNumber(props.x1) || !isWellBehavedNumber(props.y1) ||
171
- !isWellBehavedNumber(props.x2) ||
172
- !isWellBehavedNumber(props.y2)
175
+ !isWellBehavedNumber(props.x1) ||
176
+ !isWellBehavedNumber(props.y1) ||
177
+ !isWellBehavedNumber(props.x2) ||
178
+ !isWellBehavedNumber(props.y2)
173
179
  ) {
174
180
  return null;
175
181
  }
@@ -310,12 +316,13 @@ export function ReportReferenceLine(props: ReferenceLineSettings): null {
310
316
  ifOverflow,
311
317
  x,
312
318
  y,
313
- segment: segment == null
314
- ? segment
315
- : [
316
- { x: segmentStartX, y: segmentStartY },
317
- { x: segmentEndX, y: segmentEndY },
318
- ],
319
+ segment:
320
+ segment == null
321
+ ? segment
322
+ : [
323
+ { x: segmentStartX, y: segmentStartY },
324
+ { x: segmentEndX, y: segmentEndY },
325
+ ],
319
326
  };
320
327
  dispatch(addLine(settings));
321
328
  return () => {
@@ -343,18 +350,22 @@ function ReferenceLineImpl(props: PropsWithDefaults) {
343
350
  const clipPathId = useClipPathId();
344
351
  const xAxis = useAppSelector((state) => selectXAxisSettings(state, xAxisId));
345
352
  const yAxis = useAppSelector((state) => selectYAxisSettings(state, yAxisId));
346
- const xAxisScale = useAppSelector(
347
- (state) => selectAxisScale(state, 'xAxis', xAxisId, isPanorama),
353
+ const xAxisScale = useAppSelector((state) =>
354
+ selectAxisScale(state, 'xAxis', xAxisId, isPanorama),
348
355
  );
349
- const yAxisScale = useAppSelector(
350
- (state) => selectAxisScale(state, 'yAxis', yAxisId, isPanorama),
356
+ const yAxisScale = useAppSelector((state) =>
357
+ selectAxisScale(state, 'yAxis', yAxisId, isPanorama),
351
358
  );
352
359
 
353
360
  const viewBox = useViewBox();
354
361
 
355
362
  if (
356
- !clipPathId || !viewBox || xAxis == null || yAxis == null || xAxisScale == null ||
357
- yAxisScale == null
363
+ !clipPathId ||
364
+ !viewBox ||
365
+ xAxis == null ||
366
+ yAxis == null ||
367
+ xAxisScale == null ||
368
+ yAxisScale == null
358
369
  ) {
359
370
  return null;
360
371
  }
@@ -380,8 +391,7 @@ function ReferenceLineImpl(props: PropsWithDefaults) {
380
391
  const { x: x1, y: y1 } = point1;
381
392
  const { x: x2, y: y2 } = point2;
382
393
 
383
- const clipPath =
384
- ifOverflow === 'hidden' ? `url(#${clipPathId})` : undefined;
394
+ const clipPath = ifOverflow === 'hidden' ? `url(#${clipPathId})` : undefined;
385
395
 
386
396
  const lineProps: SVGProps<SVGLineElement> = {
387
397
  clipPath,
@@ -394,15 +404,17 @@ function ReferenceLineImpl(props: PropsWithDefaults) {
394
404
 
395
405
  const rect = rectWithCoords({ x1, y1, x2, y2 });
396
406
 
397
- return <ZIndexLayer zIndex={props.zIndex}>
398
- <Layer className={clsx('recharts-reference-line', className)}>
399
- {renderLine(shape, lineProps)}
400
- <CartesianLabelContextProvider {...rect} lowerWidth={rect.width} upperWidth={rect.width}>
401
- <CartesianLabelFromLabelProp label={props.label} />
402
- {props.children}
403
- </CartesianLabelContextProvider>
404
- </Layer>
405
- </ZIndexLayer>;
407
+ return (
408
+ <ZIndexLayer zIndex={props.zIndex}>
409
+ <Layer className={clsx('recharts-reference-line', className)}>
410
+ {renderLine(shape, lineProps)}
411
+ <CartesianLabelContextProvider {...rect} lowerWidth={rect.width} upperWidth={rect.width}>
412
+ <CartesianLabelFromLabelProp label={props.label} />
413
+ {props.children}
414
+ </CartesianLabelContextProvider>
415
+ </Layer>
416
+ </ZIndexLayer>
417
+ );
406
418
  }
407
419
 
408
420
  export const referenceLineDefaultProps = {
@@ -439,17 +451,19 @@ export function ReferenceLine<
439
451
  YValueType extends ReferenceCoordinateValue = any,
440
452
  >(outsideProps: Props<XValueType, YValueType>) {
441
453
  const props: PropsWithDefaults = resolveDefaultProps(outsideProps, referenceLineDefaultProps);
442
- return <>
443
- <ReportReferenceLine
444
- yAxisId={props.yAxisId}
445
- xAxisId={props.xAxisId}
446
- ifOverflow={props.ifOverflow}
447
- x={props.x}
448
- y={props.y}
449
- segment={props.segment}
450
- />
451
- <ReferenceLineImpl {...props} />
452
- </>;
454
+ return (
455
+ <>
456
+ <ReportReferenceLine
457
+ yAxisId={props.yAxisId}
458
+ xAxisId={props.xAxisId}
459
+ ifOverflow={props.ifOverflow}
460
+ x={props.x}
461
+ y={props.y}
462
+ segment={props.segment}
463
+ />
464
+ <ReferenceLineImpl {...props} />
465
+ </>
466
+ );
453
467
  }
454
468
 
455
469
  ReferenceLine.displayName = 'ReferenceLine';