@octanejs/recharts 0.1.62 → 0.1.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -14,116 +14,114 @@ import { resolveDefaultProps } from '../util/resolveDefaultProps';
14
14
 
15
15
  interface PolarGridProps extends ZIndexable {
16
16
  /**
17
- * The x-coordinate of center.
18
- * When used inside a chart context, this prop is calculated based on the chart's dimensions,
19
- * and this prop is ignored.
20
- *
21
- * This is only used when rendered outside a chart context.
22
- */
17
+ * The x-coordinate of center.
18
+ * When used inside a chart context, this prop is calculated based on the chart's dimensions,
19
+ * and this prop is ignored.
20
+ *
21
+ * This is only used when rendered outside a chart context.
22
+ */
23
23
  cx?: number;
24
24
  /**
25
- * The y-coordinate of center.
26
- * When used inside a chart context, this prop is calculated based on the chart's dimensions,
27
- * and this prop is ignored.
28
- *
29
- * This is only used when rendered outside a chart context.
30
- */
25
+ * The y-coordinate of center.
26
+ * When used inside a chart context, this prop is calculated based on the chart's dimensions,
27
+ * and this prop is ignored.
28
+ *
29
+ * This is only used when rendered outside a chart context.
30
+ */
31
31
  cy?: number;
32
32
  /**
33
- * The radius of the inner polar grid.
34
- * When used inside a chart context, this prop is calculated based on the chart's dimensions,
35
- * and this prop is ignored.
36
- *
37
- * This is only used when rendered outside a chart context.
38
- */
33
+ * The radius of the inner polar grid.
34
+ * When used inside a chart context, this prop is calculated based on the chart's dimensions,
35
+ * and this prop is ignored.
36
+ *
37
+ * This is only used when rendered outside a chart context.
38
+ */
39
39
  innerRadius?: number;
40
40
  /**
41
- * The radius of the outer polar grid.
42
- * When used inside a chart context, this prop is calculated based on the chart's dimensions,
43
- * and this prop is ignored.
44
- *
45
- * This is only used when rendered outside a chart context.
46
- */
41
+ * The radius of the outer polar grid.
42
+ * When used inside a chart context, this prop is calculated based on the chart's dimensions,
43
+ * and this prop is ignored.
44
+ *
45
+ * This is only used when rendered outside a chart context.
46
+ */
47
47
  outerRadius?: number;
48
48
  /**
49
- * The array of every line grid's angle.
50
- */
49
+ * The array of every line grid's angle.
50
+ */
51
51
  polarAngles?: ReadonlyArray<number>;
52
52
  /**
53
- * The array of every circle grid's radius.
54
- */
53
+ * The array of every circle grid's radius.
54
+ */
55
55
  polarRadius?: ReadonlyArray<number>;
56
56
  /**
57
- * The type of polar grids.
58
- * @defaultValue polygon
59
- */
57
+ * The type of polar grids.
58
+ * @defaultValue polygon
59
+ */
60
60
  gridType?: 'polygon' | 'circle';
61
61
  /**
62
- * @defaultValue true
63
- */
62
+ * @defaultValue true
63
+ */
64
64
  radialLines?: boolean;
65
65
  /**
66
- * @defaultValue 0
67
- */
66
+ * @defaultValue 0
67
+ */
68
68
  angleAxisId?: AxisId;
69
69
  /**
70
- * @defaultValue 0
71
- */
70
+ * @defaultValue 0
71
+ */
72
72
  radiusAxisId?: AxisId;
73
73
  /**
74
- * Z-Index of this component and its children. The higher the value,
75
- * the more on top it will be rendered.
76
- * Components with higher zIndex will appear in front of components with lower zIndex.
77
- * If undefined or 0, the content is rendered in the default layer without portals.
78
- *
79
- * @since 3.4
80
- * @defaultValue -100
81
- * @see {@link https://recharts.github.io/en-US/guide/zIndex/ Z-Index and layers guide}
82
- */
74
+ * Z-Index of this component and its children. The higher the value,
75
+ * the more on top it will be rendered.
76
+ * Components with higher zIndex will appear in front of components with lower zIndex.
77
+ * If undefined or 0, the content is rendered in the default layer without portals.
78
+ *
79
+ * @since 3.4
80
+ * @defaultValue -100
81
+ * @see {@link https://recharts.github.io/en-US/guide/zIndex/ Z-Index and layers guide}
82
+ */
83
83
  zIndex?: number;
84
84
  /**
85
- * The stroke color. If "none", no line will be drawn.
86
- * @defaultValue #ccc
87
- */
85
+ * The stroke color. If "none", no line will be drawn.
86
+ * @defaultValue #ccc
87
+ */
88
88
  stroke?: string;
89
89
  /**
90
- * The width of the stroke.
91
- * @defaultValue 1
92
- */
90
+ * The width of the stroke.
91
+ * @defaultValue 1
92
+ */
93
93
  strokeWidth?: number | string;
94
94
  /**
95
- * The pattern of dashes and gaps used to paint the lines of the grid.
96
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray stroke-dasharray on MDN}
97
- */
95
+ * The pattern of dashes and gaps used to paint the lines of the grid.
96
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray stroke-dasharray on MDN}
97
+ */
98
98
  strokeDasharray?: string | number;
99
99
  /**
100
- * The background color used to fill the space between grid lines.
101
- * @defaultValue none
102
- */
100
+ * The background color used to fill the space between grid lines.
101
+ * @defaultValue none
102
+ */
103
103
  fill?: string;
104
104
  /**
105
- * The opacity of the background used to fill the space between grid lines.
106
- */
105
+ * The opacity of the background used to fill the space between grid lines.
106
+ */
107
107
  fillOpacity?: number | string;
108
108
  }
109
109
 
110
110
  export type Props = Omit<SVGProps<SVGLineElement>, 'ref'> & PolarGridProps;
111
111
 
112
- type PropsWithDefaults =
113
- Props & {
114
- cx: number;
115
- cy: number;
116
- innerRadius: number;
117
- outerRadius: number;
118
- polarAngles: ReadonlyArray<number>;
119
- polarRadius: ReadonlyArray<number>;
120
- };
112
+ type PropsWithDefaults = Props & {
113
+ cx: number;
114
+ cy: number;
115
+ innerRadius: number;
116
+ outerRadius: number;
117
+ polarAngles: ReadonlyArray<number>;
118
+ polarRadius: ReadonlyArray<number>;
119
+ };
121
120
 
122
- type ConcentricProps =
123
- PropsWithDefaults & {
124
- // The radius of circle
125
- radius: number;
126
- };
121
+ type ConcentricProps = PropsWithDefaults & {
122
+ // The radius of circle
123
+ radius: number;
124
+ };
127
125
 
128
126
  const getPolygonPath = (
129
127
  radius: number,
@@ -158,19 +156,25 @@ const PolarAngles: FunctionComponent<PropsWithDefaults> = (props: PropsWithDefau
158
156
  ...svgPropertiesNoEvents(props),
159
157
  };
160
158
 
161
- return <g className="recharts-polar-grid-angle">{polarAngles.map((entry) => {
162
- const start = polarToCartesian(cx, cy, innerRadius, entry);
163
- const end = polarToCartesian(cx, cy, outerRadius, entry);
164
-
165
- return <line
166
- key={`line-${entry}`}
167
- {...polarAnglesProps}
168
- x1={start.x}
169
- y1={start.y}
170
- x2={end.x}
171
- y2={end.y}
172
- />;
173
- })}</g>;
159
+ return (
160
+ <g className="recharts-polar-grid-angle">
161
+ {polarAngles.map((entry) => {
162
+ const start = polarToCartesian(cx, cy, innerRadius, entry);
163
+ const end = polarToCartesian(cx, cy, outerRadius, entry);
164
+
165
+ return (
166
+ <line
167
+ key={`line-${entry}`}
168
+ {...polarAnglesProps}
169
+ x1={start.x}
170
+ y1={start.y}
171
+ x2={end.x}
172
+ y2={end.y}
173
+ />
174
+ );
175
+ })}
176
+ </g>
177
+ );
174
178
  };
175
179
 
176
180
  // Draw concentric circles
@@ -199,11 +203,13 @@ const ConcentricPolygon: FunctionComponent<ConcentricProps> = (props: Concentric
199
203
  ...svgPropertiesNoEvents(props),
200
204
  };
201
205
 
202
- return <path
203
- {...concentricPolygonProps}
204
- className={clsx('recharts-polar-grid-concentric-polygon', props.className)}
205
- d={getPolygonPath(radius, props.cx, props.cy, props.polarAngles)}
206
- />;
206
+ return (
207
+ <path
208
+ {...concentricPolygonProps}
209
+ className={clsx('recharts-polar-grid-concentric-polygon', props.className)}
210
+ d={getPolygonPath(radius, props.cx, props.cy, props.polarAngles)}
211
+ />
212
+ );
207
213
  };
208
214
 
209
215
  // Draw concentric axis
@@ -217,23 +223,27 @@ const ConcentricGridPath = (props: PropsWithDefaults) => {
217
223
  const maxPolarRadius: number = Math.max(...polarRadius);
218
224
  const renderBackground = props.fill && props.fill !== 'none';
219
225
 
220
- return <g className="recharts-polar-grid-concentric">
221
- {/* Render background as separate first child to do not cover strokes of smaller figures */}
222
- {renderBackground && gridType === 'circle' &&
223
- <ConcentricCircle {...props} radius={maxPolarRadius} />}
224
- {renderBackground && gridType !== 'circle' &&
225
- <ConcentricPolygon {...props} radius={maxPolarRadius} />}
226
-
227
- {polarRadius.map((entry: number, i: number) => {
228
- const key = i;
229
-
230
- if (gridType === 'circle') {
231
- return <ConcentricCircle key={key} {...props} fill="none" radius={entry} />;
232
- }
233
-
234
- return <ConcentricPolygon key={key} {...props} fill="none" radius={entry} />;
235
- })}
236
- </g>;
226
+ return (
227
+ <g className="recharts-polar-grid-concentric">
228
+ {/* Render background as separate first child to do not cover strokes of smaller figures */}
229
+ {renderBackground && gridType === 'circle' && (
230
+ <ConcentricCircle {...props} radius={maxPolarRadius} />
231
+ )}
232
+ {renderBackground && gridType !== 'circle' && (
233
+ <ConcentricPolygon {...props} radius={maxPolarRadius} />
234
+ )}
235
+
236
+ {polarRadius.map((entry: number, i: number) => {
237
+ const key = i;
238
+
239
+ if (gridType === 'circle') {
240
+ return <ConcentricCircle key={key} {...props} fill="none" radius={entry} />;
241
+ }
242
+
243
+ return <ConcentricPolygon key={key} {...props} fill="none" radius={entry} />;
244
+ })}
245
+ </g>
246
+ );
237
247
  };
238
248
 
239
249
  export const defaultPolarGridProps = {
@@ -294,24 +304,26 @@ export const PolarGrid = (outsideProps: Props) => {
294
304
  return null;
295
305
  }
296
306
 
297
- return <ZIndexLayer zIndex={props.zIndex}>
298
- <g className="recharts-polar-grid">
299
- <ConcentricGridPath
300
- gridType={gridType}
301
- radialLines={radialLines}
302
- {...props}
303
- polarAngles={polarAngles}
304
- polarRadius={polarRadius}
305
- />
306
- <PolarAngles
307
- gridType={gridType}
308
- radialLines={radialLines}
309
- {...props}
310
- polarAngles={polarAngles}
311
- polarRadius={polarRadius}
312
- />
313
- </g>
314
- </ZIndexLayer>;
307
+ return (
308
+ <ZIndexLayer zIndex={props.zIndex}>
309
+ <g className="recharts-polar-grid">
310
+ <ConcentricGridPath
311
+ gridType={gridType}
312
+ radialLines={radialLines}
313
+ {...props}
314
+ polarAngles={polarAngles}
315
+ polarRadius={polarRadius}
316
+ />
317
+ <PolarAngles
318
+ gridType={gridType}
319
+ radialLines={radialLines}
320
+ {...props}
321
+ polarAngles={polarAngles}
322
+ polarRadius={polarRadius}
323
+ />
324
+ </g>
325
+ </ZIndexLayer>
326
+ );
315
327
  };
316
328
 
317
329
  PolarGrid.displayName = 'PolarGrid';