@octanejs/recharts 0.1.61 → 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,9 +14,7 @@ import { getTicks, type GetTicksInput } from './getTicks';
14
14
  import { defaultCartesianAxisProps } from './CartesianAxis.tsrx';
15
15
  import { useChartHeight, useChartWidth, useOffsetInternal } from '../context/chartLayoutContext';
16
16
  import type { AxisId } from '../state/cartesianAxisSlice';
17
- import {
18
- selectAxisPropsNeededForCartesianGridTicksGenerator,
19
- } from '../state/selectors/axisSelectors';
17
+ import { selectAxisPropsNeededForCartesianGridTicksGenerator } from '../state/selectors/axisSelectors';
20
18
  import { useAppSelector } from '../state/hooks';
21
19
  import { useIsPanorama } from '../context/PanoramaContext';
22
20
  import { type RequiresDefaultProps, resolveDefaultProps } from '../util/resolveDefaultProps';
@@ -28,16 +26,15 @@ import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
28
26
  /**
29
27
  * The <CartesianGrid horizontal
30
28
  */
31
- export type GridLineTypeFunctionProps =
32
- Omit<LineItemProps, 'key'> & {
33
- // React does not pass the key through when calling cloneElement - so it might be undefined when cloning
34
- key: LineItemProps['key'] | undefined;
35
- // offset is not present in LineItemProps, but it is read from context and then passed to the GridLineType function and element
36
- offset: ChartOffsetInternal;
37
- };
29
+ export type GridLineTypeFunctionProps = Omit<LineItemProps, 'key'> & {
30
+ // React does not pass the key through when calling cloneElement - so it might be undefined when cloning
31
+ key: LineItemProps['key'] | undefined;
32
+ // offset is not present in LineItemProps, but it is read from context and then passed to the GridLineType function and element
33
+ offset: ChartOffsetInternal;
34
+ };
38
35
 
39
- export type AxisPropsForCartesianGridTicksGeneration =
40
- AxisPropsNeededForTicksGenerator & Omit<GetTicksInput, 'ticks' | 'viewBox'>;
36
+ export type AxisPropsForCartesianGridTicksGeneration = AxisPropsNeededForTicksGenerator &
37
+ Omit<GetTicksInput, 'ticks' | 'viewBox'>;
41
38
 
42
39
  type GridLineType =
43
40
  | SVGProps<SVGLineElement>
@@ -45,163 +42,167 @@ type GridLineType =
45
42
  | ((props: GridLineTypeFunctionProps) => OctaneElement<SVGElement>)
46
43
  | boolean;
47
44
 
48
- export type HorizontalCoordinatesGenerator =
49
- (props: {
45
+ export type HorizontalCoordinatesGenerator = (
46
+ props: {
50
47
  yAxis: AxisPropsForCartesianGridTicksGeneration | undefined;
51
48
  width: number;
52
49
  height: number;
53
50
  offset: ChartOffsetInternal;
54
- }, syncWithTicks: boolean) => number[];
51
+ },
52
+ syncWithTicks: boolean,
53
+ ) => number[];
55
54
 
56
- export type VerticalCoordinatesGenerator =
57
- (props: {
55
+ export type VerticalCoordinatesGenerator = (
56
+ props: {
58
57
  xAxis: AxisPropsForCartesianGridTicksGeneration | undefined;
59
58
  width: number;
60
59
  height: number;
61
60
  offset: ChartOffsetInternal;
62
- }, syncWithTicks: boolean) => number[];
61
+ },
62
+ syncWithTicks: boolean,
63
+ ) => number[];
63
64
 
64
65
  interface CartesianGridProps extends ZIndexable {
65
66
  /**
66
- * The width of grid. If undefined, covers the full width of the chart plot area.
67
- */
67
+ * The width of grid. If undefined, covers the full width of the chart plot area.
68
+ */
68
69
  width?: number;
69
70
  /**
70
- * The height of grid. If undefined, covers the full height of the chart plot area.
71
- */
71
+ * The height of grid. If undefined, covers the full height of the chart plot area.
72
+ */
72
73
  height?: number;
73
74
  /**
74
- * A function that generates the y-coordinates of all horizontal lines.
75
- *
76
- * @see {@link https://codesandbox.io/p/sandbox/cartesian-grid-with-coordinate-generators-my38cg?file=%2Fsrc%2FApp.tsx Cartesian grid with coordinate generators}
77
- */
75
+ * A function that generates the y-coordinates of all horizontal lines.
76
+ *
77
+ * @see {@link https://codesandbox.io/p/sandbox/cartesian-grid-with-coordinate-generators-my38cg?file=%2Fsrc%2FApp.tsx Cartesian grid with coordinate generators}
78
+ */
78
79
  horizontalCoordinatesGenerator?: HorizontalCoordinatesGenerator;
79
80
  /**
80
- * A function that generates the x-coordinates of all vertical lines.
81
- *
82
- * @see {@link https://codesandbox.io/p/sandbox/cartesian-grid-with-coordinate-generators-my38cg?file=%2Fsrc%2FApp.tsx Cartesian grid with coordinate generators}
83
- */
81
+ * A function that generates the x-coordinates of all vertical lines.
82
+ *
83
+ * @see {@link https://codesandbox.io/p/sandbox/cartesian-grid-with-coordinate-generators-my38cg?file=%2Fsrc%2FApp.tsx Cartesian grid with coordinate generators}
84
+ */
84
85
  verticalCoordinatesGenerator?: VerticalCoordinatesGenerator;
85
86
  /**
86
- * The x-coordinate of grid.
87
- * If left undefined, it will be computed from the chart's offset and margins.
88
- */
87
+ * The x-coordinate of grid.
88
+ * If left undefined, it will be computed from the chart's offset and margins.
89
+ */
89
90
  x?: number;
90
91
  /**
91
- * The y-coordinate of grid.
92
- * If left undefined, it will be computed from the chart's offset and margins.
93
- */
92
+ * The y-coordinate of grid.
93
+ * If left undefined, it will be computed from the chart's offset and margins.
94
+ */
94
95
  y?: number;
95
96
  /**
96
- * If set false, no horizontal grid lines will be drawn.
97
- *
98
- * @defaultValue true
99
- */
97
+ * If set false, no horizontal grid lines will be drawn.
98
+ *
99
+ * @defaultValue true
100
+ */
100
101
  horizontal?: GridLineType;
101
102
  /**
102
- * If set false, no vertical grid lines will be drawn.
103
- *
104
- * @defaultValue true
105
- */
103
+ * If set false, no vertical grid lines will be drawn.
104
+ *
105
+ * @defaultValue true
106
+ */
106
107
  vertical?: GridLineType;
107
108
  /**
108
- * Array of coordinates in pixels where to draw horizontal grid lines.
109
- * Has priority over syncWithTicks and horizontalValues.
110
- *
111
- * @defaultValue []
112
- */
109
+ * Array of coordinates in pixels where to draw horizontal grid lines.
110
+ * Has priority over syncWithTicks and horizontalValues.
111
+ *
112
+ * @defaultValue []
113
+ */
113
114
  horizontalPoints?: number[];
114
115
  /**
115
- * Array of coordinates in pixels where to draw vertical grid lines.
116
- * Has priority over syncWithTicks and verticalValues.
117
- *
118
- * @defaultValue []
119
- */
116
+ * Array of coordinates in pixels where to draw vertical grid lines.
117
+ * Has priority over syncWithTicks and verticalValues.
118
+ *
119
+ * @defaultValue []
120
+ */
120
121
  verticalPoints?: number[];
121
122
  /**
122
- * The background color used to fill the space between grid lines
123
- *
124
- * @defaultValue none
125
- * @example <CartesianGrid fill="red" />
126
- * @example <CartesianGrid fill="#ccc" />
127
- */
123
+ * The background color used to fill the space between grid lines
124
+ *
125
+ * @defaultValue none
126
+ * @example <CartesianGrid fill="red" />
127
+ * @example <CartesianGrid fill="#ccc" />
128
+ */
128
129
  fill?: string;
129
130
  /**
130
- * The opacity of the background used to fill the space between grid lines
131
- *
132
- * @example <CartesianGrid fill="red" fillOpacity={0.6} />
133
- */
131
+ * The opacity of the background used to fill the space between grid lines
132
+ *
133
+ * @example <CartesianGrid fill="red" fillOpacity={0.6} />
134
+ */
134
135
  fillOpacity?: number | string;
135
136
  /**
136
- * Defines background color of stripes.
137
- *
138
- * The values from this array will be passed in as the `fill` property in a `rect` SVG element.
139
- * For possible values see: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill#rect
140
- *
141
- * In case there are more stripes than colors, the colors will start from beginning.
142
- * So for example: verticalFill['yellow', 'black'] produces a pattern of yellow|black|yellow|black
143
- *
144
- * If this is undefined, or an empty array, then there is no background fill.
145
- * Note: Grid lines will be rendered above these background stripes.
146
- *
147
- * @defaultValue []
148
- */
137
+ * Defines background color of stripes.
138
+ *
139
+ * The values from this array will be passed in as the `fill` property in a `rect` SVG element.
140
+ * For possible values see: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill#rect
141
+ *
142
+ * In case there are more stripes than colors, the colors will start from beginning.
143
+ * So for example: verticalFill['yellow', 'black'] produces a pattern of yellow|black|yellow|black
144
+ *
145
+ * If this is undefined, or an empty array, then there is no background fill.
146
+ * Note: Grid lines will be rendered above these background stripes.
147
+ *
148
+ * @defaultValue []
149
+ */
149
150
  verticalFill?: string[];
150
151
  /**
151
- * Defines background color of stripes.
152
- *
153
- * The values from this array will be passed in as the `fill` property in a `rect` SVG element.
154
- * For possible values see: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill#rect
155
- *
156
- * In case there are more stripes than colors, the colors will start from beginning.
157
- * So for example: horizontalFill['yellow', 'black'] produces a pattern of yellow|black|yellow|black
158
- *
159
- * If this is undefined, or an empty array, then there is no background fill.
160
- * Note: Grid lines will be rendered above these background stripes.
161
- *
162
- * @defaultValue []
163
- */
152
+ * Defines background color of stripes.
153
+ *
154
+ * The values from this array will be passed in as the `fill` property in a `rect` SVG element.
155
+ * For possible values see: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill#rect
156
+ *
157
+ * In case there are more stripes than colors, the colors will start from beginning.
158
+ * So for example: horizontalFill['yellow', 'black'] produces a pattern of yellow|black|yellow|black
159
+ *
160
+ * If this is undefined, or an empty array, then there is no background fill.
161
+ * Note: Grid lines will be rendered above these background stripes.
162
+ *
163
+ * @defaultValue []
164
+ */
164
165
  horizontalFill?: string[];
165
166
  /**
166
- * If true, only the lines that correspond to the axes ticks values will be drawn.
167
- * If false, extra lines could be added for each axis (at min and max coordinates), if there will not such ticks.
168
- * horizontalPoints, verticalPoints, horizontalValues, verticalValues have priority over syncWithTicks.
169
- *
170
- * @defaultValue false
171
- */
167
+ * If true, only the lines that correspond to the axes ticks values will be drawn.
168
+ * If false, extra lines could be added for each axis (at min and max coordinates), if there will not such ticks.
169
+ * horizontalPoints, verticalPoints, horizontalValues, verticalValues have priority over syncWithTicks.
170
+ *
171
+ * @defaultValue false
172
+ */
172
173
  syncWithTicks?: boolean;
173
174
  /**
174
- * Array of values, where horizontal lines will be drawn. Numbers or strings, in dependence on axis type.
175
- * Has priority over syncWithTicks but not over horizontalPoints.
176
- */
175
+ * Array of values, where horizontal lines will be drawn. Numbers or strings, in dependence on axis type.
176
+ * Has priority over syncWithTicks but not over horizontalPoints.
177
+ */
177
178
  horizontalValues?: number[] | string[];
178
179
  /**
179
- * Array of values, where vertical lines will be drawn. Numbers or strings, in dependence on axis type.
180
- * Has priority over syncWithTicks but not over verticalPoints.
181
- */
180
+ * Array of values, where vertical lines will be drawn. Numbers or strings, in dependence on axis type.
181
+ * Has priority over syncWithTicks but not over verticalPoints.
182
+ */
182
183
  verticalValues?: number[] | string[];
183
184
  /**
184
- * The pattern of dashes and gaps used to paint the lines of the grid
185
- *
186
- * @example <CartesianGrid strokeDasharray="3 3" />
187
- * @example <CartesianGrid strokeDasharray={[5, 5, 1, 5]} />
188
- * @example <CartesianGrid strokeDasharray="5 5 1 5" />
189
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray stroke-dasharray on MDN}
190
- */
185
+ * The pattern of dashes and gaps used to paint the lines of the grid
186
+ *
187
+ * @example <CartesianGrid strokeDasharray="3 3" />
188
+ * @example <CartesianGrid strokeDasharray={[5, 5, 1, 5]} />
189
+ * @example <CartesianGrid strokeDasharray="5 5 1 5" />
190
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray stroke-dasharray on MDN}
191
+ */
191
192
  strokeDasharray?: string | number[];
192
193
  /**
193
- * The id of XAxis which is corresponding to the data. Required when there are multiple XAxes.
194
- * @defaultValue 0
195
- */
194
+ * The id of XAxis which is corresponding to the data. Required when there are multiple XAxes.
195
+ * @defaultValue 0
196
+ */
196
197
  xAxisId?: AxisId;
197
198
  /**
198
- * The id of YAxis which is corresponding to the data. Required when there are multiple YAxes.
199
- * @defaultValue 0
200
- */
199
+ * The id of YAxis which is corresponding to the data. Required when there are multiple YAxes.
200
+ * @defaultValue 0
201
+ */
201
202
  yAxisId?: AxisId;
202
203
  /**
203
- * @defaultValue -100
204
- */
204
+ * @defaultValue -100
205
+ */
205
206
  zIndex?: number;
206
207
  }
207
208
 
@@ -209,8 +210,8 @@ type AcceptedSvgProps = Omit<SVGProps<SVGLineElement>, 'offset'>;
209
210
 
210
211
  export type Props = AcceptedSvgProps & CartesianGridProps;
211
212
 
212
- type CartesianGridInternalProps =
213
- AcceptedSvgProps & RequiresDefaultProps<CartesianGridProps, typeof defaultCartesianGridProps> & {
213
+ type CartesianGridInternalProps = AcceptedSvgProps &
214
+ RequiresDefaultProps<CartesianGridProps, typeof defaultCartesianGridProps> & {
214
215
  // x,y,width,height are not declared directly in default props but are resolved using offset, if undefined
215
216
  x: number;
216
217
  y: number;
@@ -229,31 +230,32 @@ const Background = (
229
230
 
230
231
  const { fillOpacity, x, y, width, height, ry } = props;
231
232
 
232
- return <rect
233
- x={x}
234
- y={y}
235
- ry={ry}
236
- width={width}
237
- height={height}
238
- stroke="none"
239
- fill={fill}
240
- fillOpacity={fillOpacity}
241
- className="recharts-cartesian-grid-bg"
242
- />;
233
+ return (
234
+ <rect
235
+ x={x}
236
+ y={y}
237
+ ry={ry}
238
+ width={width}
239
+ height={height}
240
+ stroke="none"
241
+ fill={fill}
242
+ fillOpacity={fillOpacity}
243
+ className="recharts-cartesian-grid-bg"
244
+ />
245
+ );
243
246
  };
244
247
 
245
- type LineItemProps =
246
- Props & {
247
- offset: ChartOffsetInternal;
248
- xAxis: undefined | AxisPropsForCartesianGridTicksGeneration;
249
- yAxis: undefined | AxisPropsForCartesianGridTicksGeneration;
250
- x1: number;
251
- y1: number;
252
- x2: number;
253
- y2: number;
254
- key: string;
255
- index: number;
256
- };
248
+ type LineItemProps = Props & {
249
+ offset: ChartOffsetInternal;
250
+ xAxis: undefined | AxisPropsForCartesianGridTicksGeneration;
251
+ yAxis: undefined | AxisPropsForCartesianGridTicksGeneration;
252
+ x1: number;
253
+ y1: number;
254
+ x2: number;
255
+ y2: number;
256
+ key: string;
257
+ index: number;
258
+ };
257
259
 
258
260
  function LineItem({
259
261
  option,
@@ -271,26 +273,19 @@ function LineItem({
271
273
  } else {
272
274
  const { x1, y1, x2, y2, key, ...others } = lineItemProps;
273
275
  const { offset: __, ...restOfFilteredProps } = svgPropertiesNoEvents(others) ?? {};
274
- lineItem = <line
275
- {...restOfFilteredProps}
276
- x1={x1}
277
- y1={y1}
278
- x2={x2}
279
- y2={y2}
280
- fill="none"
281
- key={key}
282
- />;
276
+ lineItem = (
277
+ <line {...restOfFilteredProps} x1={x1} y1={y1} x2={x2} y2={y2} fill="none" key={key} />
278
+ );
283
279
  }
284
280
 
285
281
  return lineItem;
286
282
  }
287
283
 
288
- type GridLinesProps =
289
- CartesianGridInternalProps & {
290
- offset: GridLineTypeFunctionProps['offset'];
291
- xAxis: GridLineTypeFunctionProps['xAxis'];
292
- yAxis: GridLineTypeFunctionProps['yAxis'];
293
- };
284
+ type GridLinesProps = CartesianGridInternalProps & {
285
+ offset: GridLineTypeFunctionProps['offset'];
286
+ xAxis: GridLineTypeFunctionProps['xAxis'];
287
+ yAxis: GridLineTypeFunctionProps['yAxis'];
288
+ };
294
289
 
295
290
  function HorizontalGridLines(props: GridLinesProps) {
296
291
  const { x, width, horizontal = true, horizontalPoints } = props;
@@ -359,9 +354,9 @@ function HorizontalStripes(props: CartesianGridInternalProps) {
359
354
  return null;
360
355
  }
361
356
 
362
- const roundedSortedHorizontalPoints = horizontalPoints.map((e) => Math.round(e + y - y)).sort(
363
- (a, b) => a - b,
364
- );
357
+ const roundedSortedHorizontalPoints = horizontalPoints
358
+ .map((e) => Math.round(e + y - y))
359
+ .sort((a, b) => a - b);
365
360
  // Why is this condition `!==` instead of `<=` ?
366
361
  if (y !== roundedSortedHorizontalPoints[0]) {
367
362
  roundedSortedHorizontalPoints.unshift(y);
@@ -376,17 +371,19 @@ function HorizontalStripes(props: CartesianGridInternalProps) {
376
371
  return null;
377
372
  }
378
373
  const colorIndex = i % horizontalFill.length;
379
- return <rect
380
- key={`react-${i}`}
381
- y={entry}
382
- x={x}
383
- height={lineHeight}
384
- width={width}
385
- stroke="none"
386
- fill={horizontalFill[colorIndex]}
387
- fillOpacity={fillOpacity}
388
- className="recharts-cartesian-grid-bg"
389
- />;
374
+ return (
375
+ <rect
376
+ key={`react-${i}`}
377
+ y={entry}
378
+ x={x}
379
+ height={lineHeight}
380
+ width={width}
381
+ stroke="none"
382
+ fill={horizontalFill[colorIndex]}
383
+ fillOpacity={fillOpacity}
384
+ className="recharts-cartesian-grid-bg"
385
+ />
386
+ );
390
387
  });
391
388
 
392
389
  return <g className="recharts-cartesian-gridstripes-horizontal">{items}</g>;
@@ -398,9 +395,9 @@ function VerticalStripes(props: CartesianGridInternalProps) {
398
395
  return null;
399
396
  }
400
397
 
401
- const roundedSortedVerticalPoints = verticalPoints.map((e) => Math.round(e + x - x)).sort(
402
- (a, b) => a - b,
403
- );
398
+ const roundedSortedVerticalPoints = verticalPoints
399
+ .map((e) => Math.round(e + x - x))
400
+ .sort((a, b) => a - b);
404
401
 
405
402
  if (x !== roundedSortedVerticalPoints[0]) {
406
403
  roundedSortedVerticalPoints.unshift(x);
@@ -415,17 +412,19 @@ function VerticalStripes(props: CartesianGridInternalProps) {
415
412
  return null;
416
413
  }
417
414
  const colorIndex = i % verticalFill.length;
418
- return <rect
419
- key={`react-${i}`}
420
- x={entry}
421
- y={y}
422
- width={lineWidth}
423
- height={height}
424
- stroke="none"
425
- fill={verticalFill[colorIndex]}
426
- fillOpacity={fillOpacity}
427
- className="recharts-cartesian-grid-bg"
428
- />;
415
+ return (
416
+ <rect
417
+ key={`react-${i}`}
418
+ x={entry}
419
+ y={y}
420
+ width={lineWidth}
421
+ height={height}
422
+ stroke="none"
423
+ fill={verticalFill[colorIndex]}
424
+ fillOpacity={fillOpacity}
425
+ className="recharts-cartesian-grid-bg"
426
+ />
427
+ );
429
428
  });
430
429
 
431
430
  return <g className="recharts-cartesian-gridstripes-vertical">{items}</g>;
@@ -434,32 +433,34 @@ function VerticalStripes(props: CartesianGridInternalProps) {
434
433
  const defaultVerticalCoordinatesGenerator: VerticalCoordinatesGenerator = (
435
434
  { xAxis, width, height, offset },
436
435
  syncWithTicks,
437
- ) => getCoordinatesOfGrid(
438
- getTicks({
439
- ...defaultCartesianAxisProps,
440
- ...xAxis,
441
- ticks: getTicksOfAxis(xAxis, true),
442
- viewBox: { x: 0, y: 0, width, height },
443
- }),
444
- offset.left,
445
- offset.left + offset.width,
446
- syncWithTicks,
447
- );
436
+ ) =>
437
+ getCoordinatesOfGrid(
438
+ getTicks({
439
+ ...defaultCartesianAxisProps,
440
+ ...xAxis,
441
+ ticks: getTicksOfAxis(xAxis, true),
442
+ viewBox: { x: 0, y: 0, width, height },
443
+ }),
444
+ offset.left,
445
+ offset.left + offset.width,
446
+ syncWithTicks,
447
+ );
448
448
 
449
449
  const defaultHorizontalCoordinatesGenerator: HorizontalCoordinatesGenerator = (
450
450
  { yAxis, width, height, offset },
451
451
  syncWithTicks,
452
- ) => getCoordinatesOfGrid(
453
- getTicks({
454
- ...defaultCartesianAxisProps,
455
- ...yAxis,
456
- ticks: getTicksOfAxis(yAxis, true),
457
- viewBox: { x: 0, y: 0, width, height },
458
- }),
459
- offset.top,
460
- offset.top + offset.height,
461
- syncWithTicks,
462
- );
452
+ ) =>
453
+ getCoordinatesOfGrid(
454
+ getTicks({
455
+ ...defaultCartesianAxisProps,
456
+ ...yAxis,
457
+ ticks: getTicksOfAxis(yAxis, true),
458
+ viewBox: { x: 0, y: 0, width, height },
459
+ }),
460
+ offset.top,
461
+ offset.top + offset.height,
462
+ syncWithTicks,
463
+ );
463
464
 
464
465
  export const defaultCartesianGridProps = {
465
466
  horizontal: true,
@@ -497,34 +498,15 @@ export function CartesianGrid(props: Props) {
497
498
  height: isNumber(props.height) ? props.height : offset.height,
498
499
  };
499
500
 
500
- const {
501
- xAxisId,
502
- yAxisId,
503
- x,
504
- y,
505
- width,
506
- height,
507
- syncWithTicks,
508
- horizontalValues,
509
- verticalValues,
510
- } = propsIncludingDefaults;
501
+ const { xAxisId, yAxisId, x, y, width, height, syncWithTicks, horizontalValues, verticalValues } =
502
+ propsIncludingDefaults;
511
503
 
512
504
  const isPanorama = useIsPanorama();
513
- const xAxis: AxisPropsForCartesianGridTicksGeneration | undefined = useAppSelector(
514
- (state) => selectAxisPropsNeededForCartesianGridTicksGenerator(
515
- state,
516
- 'xAxis',
517
- xAxisId,
518
- isPanorama,
519
- ),
505
+ const xAxis: AxisPropsForCartesianGridTicksGeneration | undefined = useAppSelector((state) =>
506
+ selectAxisPropsNeededForCartesianGridTicksGenerator(state, 'xAxis', xAxisId, isPanorama),
520
507
  );
521
- const yAxis: AxisPropsForCartesianGridTicksGeneration | undefined = useAppSelector(
522
- (state) => selectAxisPropsNeededForCartesianGridTicksGenerator(
523
- state,
524
- 'yAxis',
525
- yAxisId,
526
- isPanorama,
527
- ),
508
+ const yAxis: AxisPropsForCartesianGridTicksGeneration | undefined = useAppSelector((state) =>
509
+ selectAxisPropsNeededForCartesianGridTicksGenerator(state, 'yAxis', yAxisId, isPanorama),
528
510
  );
529
511
 
530
512
  if (!isPositiveNumber(width) || !isPositiveNumber(height) || !isNumber(x) || !isNumber(y)) {
@@ -532,12 +514,12 @@ export function CartesianGrid(props: Props) {
532
514
  }
533
515
 
534
516
  /*
535
- * verticalCoordinatesGenerator and horizontalCoordinatesGenerator are defined
536
- * outside the propsIncludingDefaults because they were never part of the original props
537
- * and they were never passed as a prop down to horizontal/vertical custom elements.
538
- * If we add these two to propsIncludingDefaults then we are changing public API.
539
- * Not a bad thing per se but also not necessary.
540
- */
517
+ * verticalCoordinatesGenerator and horizontalCoordinatesGenerator are defined
518
+ * outside the propsIncludingDefaults because they were never part of the original props
519
+ * and they were never passed as a prop down to horizontal/vertical custom elements.
520
+ * If we add these two to propsIncludingDefaults then we are changing public API.
521
+ * Not a bad thing per se but also not necessary.
522
+ */
541
523
  const verticalCoordinatesGenerator =
542
524
  propsIncludingDefaults.verticalCoordinatesGenerator || defaultVerticalCoordinatesGenerator;
543
525
  const horizontalCoordinatesGenerator =
@@ -548,7 +530,7 @@ export function CartesianGrid(props: Props) {
548
530
  // No horizontal points are specified
549
531
  if (
550
532
  (!horizontalPoints || !horizontalPoints.length) &&
551
- typeof horizontalCoordinatesGenerator === 'function'
533
+ typeof horizontalCoordinatesGenerator === 'function'
552
534
  ) {
553
535
  const isHorizontalValues = horizontalValues && horizontalValues.length;
554
536
 
@@ -579,7 +561,7 @@ export function CartesianGrid(props: Props) {
579
561
  // No vertical points are specified
580
562
  if (
581
563
  (!verticalPoints || !verticalPoints.length) &&
582
- typeof verticalCoordinatesGenerator === 'function'
564
+ typeof verticalCoordinatesGenerator === 'function'
583
565
  ) {
584
566
  const isVerticalValues = verticalValues && verticalValues.length;
585
567
  const generatorResult = verticalCoordinatesGenerator(
@@ -605,38 +587,40 @@ export function CartesianGrid(props: Props) {
605
587
  }
606
588
  }
607
589
 
608
- return <ZIndexLayer zIndex={propsIncludingDefaults.zIndex}>
609
- <g className="recharts-cartesian-grid">
610
- <Background
611
- fill={propsIncludingDefaults.fill}
612
- fillOpacity={propsIncludingDefaults.fillOpacity}
613
- x={propsIncludingDefaults.x}
614
- y={propsIncludingDefaults.y}
615
- width={propsIncludingDefaults.width}
616
- height={propsIncludingDefaults.height}
617
- ry={propsIncludingDefaults.ry}
618
- />
619
-
620
- <HorizontalStripes {...propsIncludingDefaults} horizontalPoints={horizontalPoints} />
621
- <VerticalStripes {...propsIncludingDefaults} verticalPoints={verticalPoints} />
622
-
623
- <HorizontalGridLines
624
- {...propsIncludingDefaults}
625
- offset={offset}
626
- horizontalPoints={horizontalPoints}
627
- xAxis={xAxis}
628
- yAxis={yAxis}
629
- />
630
-
631
- <VerticalGridLines
632
- {...propsIncludingDefaults}
633
- offset={offset}
634
- verticalPoints={verticalPoints}
635
- xAxis={xAxis}
636
- yAxis={yAxis}
637
- />
638
- </g>
639
- </ZIndexLayer>;
590
+ return (
591
+ <ZIndexLayer zIndex={propsIncludingDefaults.zIndex}>
592
+ <g className="recharts-cartesian-grid">
593
+ <Background
594
+ fill={propsIncludingDefaults.fill}
595
+ fillOpacity={propsIncludingDefaults.fillOpacity}
596
+ x={propsIncludingDefaults.x}
597
+ y={propsIncludingDefaults.y}
598
+ width={propsIncludingDefaults.width}
599
+ height={propsIncludingDefaults.height}
600
+ ry={propsIncludingDefaults.ry}
601
+ />
602
+
603
+ <HorizontalStripes {...propsIncludingDefaults} horizontalPoints={horizontalPoints} />
604
+ <VerticalStripes {...propsIncludingDefaults} verticalPoints={verticalPoints} />
605
+
606
+ <HorizontalGridLines
607
+ {...propsIncludingDefaults}
608
+ offset={offset}
609
+ horizontalPoints={horizontalPoints}
610
+ xAxis={xAxis}
611
+ yAxis={yAxis}
612
+ />
613
+
614
+ <VerticalGridLines
615
+ {...propsIncludingDefaults}
616
+ offset={offset}
617
+ verticalPoints={verticalPoints}
618
+ xAxis={xAxis}
619
+ yAxis={yAxis}
620
+ />
621
+ </g>
622
+ </ZIndexLayer>
623
+ );
640
624
  }
641
625
 
642
626
  CartesianGrid.displayName = 'CartesianGrid';