@octanejs/recharts 0.1.0

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 (219) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +53 -0
  3. package/src/animation/AnimatedItems.tsrx +82 -0
  4. package/src/animation/AnimationControllerImpl.js +33 -0
  5. package/src/animation/AnimationHandle.js +291 -0
  6. package/src/animation/JavascriptAnimate.tsrx +81 -0
  7. package/src/animation/easing.js +193 -0
  8. package/src/animation/matchBy.js +279 -0
  9. package/src/animation/timeoutController.js +49 -0
  10. package/src/animation/useAnimationController.ts +22 -0
  11. package/src/animation/useAnimationStartSnapshot.ts +43 -0
  12. package/src/animation/util.js +11 -0
  13. package/src/cartesian/Bar.ts +4 -0
  14. package/src/cartesian/Bar.tsrx +716 -0
  15. package/src/cartesian/Bar.tsrx.d.ts +4 -0
  16. package/src/cartesian/BarStack.tsrx +97 -0
  17. package/src/cartesian/BarStack.tsrx.d.ts +6 -0
  18. package/src/cartesian/CartesianAxis.tsrx +413 -0
  19. package/src/cartesian/CartesianAxis.tsrx.d.ts +3 -0
  20. package/src/cartesian/GraphicalItemClipPath.tsrx +44 -0
  21. package/src/cartesian/Line.ts +4 -0
  22. package/src/cartesian/Line.tsrx +544 -0
  23. package/src/cartesian/Line.tsrx.d.ts +4 -0
  24. package/src/cartesian/LineDrawShape.tsrx +106 -0
  25. package/src/cartesian/LineDrawShape.tsrx.d.ts +2 -0
  26. package/src/cartesian/XAxis.tsrx +156 -0
  27. package/src/cartesian/XAxis.tsrx.d.ts +3 -0
  28. package/src/cartesian/YAxis.tsrx +183 -0
  29. package/src/cartesian/YAxis.tsrx.d.ts +3 -0
  30. package/src/cartesian/getCartesianPosition.js +277 -0
  31. package/src/cartesian/getEquidistantTicks.js +133 -0
  32. package/src/cartesian/getTicks.js +280 -0
  33. package/src/cartesian/useAnimatedLineLength.ts +33 -0
  34. package/src/chart/BarChart.tsrx +22 -0
  35. package/src/chart/BarChart.tsrx.d.ts +2 -0
  36. package/src/chart/CartesianChart.tsrx +76 -0
  37. package/src/chart/CartesianChart.tsrx.d.ts +10 -0
  38. package/src/chart/CategoricalChart.tsrx +54 -0
  39. package/src/chart/LineChart.tsrx +22 -0
  40. package/src/chart/LineChart.tsrx.d.ts +2 -0
  41. package/src/chart/RechartsWrapper.tsrx +294 -0
  42. package/src/component/ActivePoints.tsrx +76 -0
  43. package/src/component/Cell.ts +37 -0
  44. package/src/component/Dots.tsrx +74 -0
  45. package/src/component/Label.tsrx +309 -0
  46. package/src/component/Label.tsrx.d.ts +12 -0
  47. package/src/component/LabelList.tsrx +83 -0
  48. package/src/component/LabelList.tsrx.d.ts +8 -0
  49. package/src/component/ResponsiveContainer.ts +22 -0
  50. package/src/component/Text.tsrx +281 -0
  51. package/src/component/Text.tsrx.d.ts +9 -0
  52. package/src/component/responsiveContainerUtils.js +111 -0
  53. package/src/container/ClipPathProvider.tsrx +29 -0
  54. package/src/container/Layer.tsrx +9 -0
  55. package/src/container/Layer.tsrx.d.ts +6 -0
  56. package/src/container/RootSurface.tsrx +76 -0
  57. package/src/container/Surface.tsrx +23 -0
  58. package/src/container/Surface.tsrx.d.ts +12 -0
  59. package/src/context/CellsContext.ts +80 -0
  60. package/src/context/ErrorBarContext.tsrx +53 -0
  61. package/src/context/PanoramaContext.ts +10 -0
  62. package/src/context/RegisterGraphicalItemId.tsrx +19 -0
  63. package/src/context/accessibilityContext.js +10 -0
  64. package/src/context/chartDataContext.ts +57 -0
  65. package/src/context/chartLayoutContext.ts +171 -0
  66. package/src/context/legendPortalContext.ts +5 -0
  67. package/src/context/tooltipContext.js +55 -0
  68. package/src/context/tooltipPortalContext.ts +5 -0
  69. package/src/hooks.js +509 -0
  70. package/src/index.ts +64 -0
  71. package/src/internal.ts +37 -0
  72. package/src/polar/defaultPolarAngleAxisProps.js +27 -0
  73. package/src/polar/defaultPolarRadiusAxisProps.js +24 -0
  74. package/src/shape/Cross.tsrx +25 -0
  75. package/src/shape/Cross.tsrx.d.ts +12 -0
  76. package/src/shape/Curve.tsrx +132 -0
  77. package/src/shape/Curve.tsrx.d.ts +42 -0
  78. package/src/shape/Dot.tsrx +21 -0
  79. package/src/shape/Dot.tsrx.d.ts +9 -0
  80. package/src/shape/Polygon.tsrx +95 -0
  81. package/src/shape/Polygon.tsrx.d.ts +13 -0
  82. package/src/shape/Rectangle.tsrx +162 -0
  83. package/src/shape/Rectangle.tsrx.d.ts +31 -0
  84. package/src/shape/Sector.tsrx +219 -0
  85. package/src/shape/Sector.tsrx.d.ts +29 -0
  86. package/src/shape/Symbols.tsrx +95 -0
  87. package/src/shape/Symbols.tsrx.d.ts +15 -0
  88. package/src/shape/Trapezoid.tsrx +56 -0
  89. package/src/shape/Trapezoid.tsrx.d.ts +29 -0
  90. package/src/state/RechartsReduxContext.ts +7 -0
  91. package/src/state/RechartsStoreProvider.tsrx +24 -0
  92. package/src/state/ReportChartProps.ts +13 -0
  93. package/src/state/ReportEventSettings.ts +15 -0
  94. package/src/state/ReportMainChartProps.ts +22 -0
  95. package/src/state/SetGraphicalItem.ts +61 -0
  96. package/src/state/SetLegendPayload.ts +61 -0
  97. package/src/state/SetTooltipEntrySettings.ts +40 -0
  98. package/src/state/brushSlice.js +36 -0
  99. package/src/state/cartesianAxisSlice.js +256 -0
  100. package/src/state/chartDataSlice.js +67 -0
  101. package/src/state/errorBarSlice.js +53 -0
  102. package/src/state/eventSettingsSlice.js +25 -0
  103. package/src/state/externalEventsMiddleware.js +127 -0
  104. package/src/state/graphicalItemsSlice.js +91 -0
  105. package/src/state/hooks.ts +46 -0
  106. package/src/state/keyboardEventsMiddleware.js +226 -0
  107. package/src/state/layoutSlice.js +57 -0
  108. package/src/state/legendSlice.js +83 -0
  109. package/src/state/mouseEventsMiddleware.js +130 -0
  110. package/src/state/optionsSlice.js +45 -0
  111. package/src/state/polarAxisSlice.js +33 -0
  112. package/src/state/polarOptionsSlice.js +26 -0
  113. package/src/state/reduxDevtoolsJsonStringifyReplacer.js +14 -0
  114. package/src/state/referenceElementsSlice.js +51 -0
  115. package/src/state/renderedTicksSlice.js +41 -0
  116. package/src/state/rootPropsSlice.js +48 -0
  117. package/src/state/selectors/arrayEqualityCheck.js +32 -0
  118. package/src/state/selectors/axisSelectors.js +2113 -0
  119. package/src/state/selectors/barSelectors.js +263 -0
  120. package/src/state/selectors/barStackSelectors.js +65 -0
  121. package/src/state/selectors/brushSelectors.js +21 -0
  122. package/src/state/selectors/combiners/combineActiveLabel.js +18 -0
  123. package/src/state/selectors/combiners/combineActiveTooltipIndex.js +75 -0
  124. package/src/state/selectors/combiners/combineAllBarPositions.js +169 -0
  125. package/src/state/selectors/combiners/combineAxisRangeWithReverse.js +11 -0
  126. package/src/state/selectors/combiners/combineBarPosition.js +17 -0
  127. package/src/state/selectors/combiners/combineBarSizeList.js +115 -0
  128. package/src/state/selectors/combiners/combineCheckedDomain.js +44 -0
  129. package/src/state/selectors/combiners/combineConfiguredScale.js +46 -0
  130. package/src/state/selectors/combiners/combineCoordinateForDefaultIndex.js +48 -0
  131. package/src/state/selectors/combiners/combineDisplayedStackedData.js +54 -0
  132. package/src/state/selectors/combiners/combineInverseScaleFunction.js +12 -0
  133. package/src/state/selectors/combiners/combineRealScaleType.js +36 -0
  134. package/src/state/selectors/combiners/combineStackedData.js +22 -0
  135. package/src/state/selectors/combiners/combineTooltipInteractionState.js +121 -0
  136. package/src/state/selectors/combiners/combineTooltipPayload.js +248 -0
  137. package/src/state/selectors/combiners/combineTooltipPayloadConfigurations.js +59 -0
  138. package/src/state/selectors/containerSelectors.js +6 -0
  139. package/src/state/selectors/dataSelectors.js +97 -0
  140. package/src/state/selectors/graphicalItemSelectors.js +25 -0
  141. package/src/state/selectors/legendSelectors.js +18 -0
  142. package/src/state/selectors/lineSelectors.js +106 -0
  143. package/src/state/selectors/numberDomainEqualityCheck.js +11 -0
  144. package/src/state/selectors/pickAxisId.js +3 -0
  145. package/src/state/selectors/pickAxisType.js +3 -0
  146. package/src/state/selectors/polarAxisSelectors.js +237 -0
  147. package/src/state/selectors/rootPropsSelectors.js +13 -0
  148. package/src/state/selectors/selectActivePropsFromChartPointer.js +23 -0
  149. package/src/state/selectors/selectAllAxes.js +15 -0
  150. package/src/state/selectors/selectChartOffset.js +12 -0
  151. package/src/state/selectors/selectChartOffsetInternal.js +174 -0
  152. package/src/state/selectors/selectPlotArea.js +19 -0
  153. package/src/state/selectors/selectTooltipAxisId.js +3 -0
  154. package/src/state/selectors/selectTooltipAxisType.js +25 -0
  155. package/src/state/selectors/selectTooltipEventType.js +27 -0
  156. package/src/state/selectors/selectTooltipPayloadSearcher.js +3 -0
  157. package/src/state/selectors/selectTooltipSettings.js +3 -0
  158. package/src/state/selectors/selectTooltipState.js +3 -0
  159. package/src/state/selectors/selectors.js +222 -0
  160. package/src/state/selectors/tooltipSelectors.js +471 -0
  161. package/src/state/selectors/touchSelectors.js +31 -0
  162. package/src/state/store.js +101 -0
  163. package/src/state/tooltipSlice.js +237 -0
  164. package/src/state/touchEventsMiddleware.js +140 -0
  165. package/src/state/types/StackedGraphicalItem.js +18 -0
  166. package/src/state/zIndexSlice.js +167 -0
  167. package/src/synchronisation/syncSelectors.js +5 -0
  168. package/src/synchronisation/useChartSynchronisation.tsrx +285 -0
  169. package/src/util/ActiveShapeUtils.tsrx +62 -0
  170. package/src/util/BarUtils.tsrx +35 -0
  171. package/src/util/CartesianUtils.js +66 -0
  172. package/src/util/ChartUtils.js +630 -0
  173. package/src/util/Constants.js +42 -0
  174. package/src/util/DOMUtils.js +180 -0
  175. package/src/util/DataUtils.js +199 -0
  176. package/src/util/Events.js +7 -0
  177. package/src/util/Global.js +13 -0
  178. package/src/util/LRUCache.js +58 -0
  179. package/src/util/LogUtils.js +29 -0
  180. package/src/util/PolarUtils.js +190 -0
  181. package/src/util/ReactUtils.ts +94 -0
  182. package/src/util/ReduceCSSCalc.js +260 -0
  183. package/src/util/TickUtils.js +43 -0
  184. package/src/util/YAxisUtils.js +43 -0
  185. package/src/util/axisPropsAreEqual.js +63 -0
  186. package/src/util/createEventProxy.js +18 -0
  187. package/src/util/excludeEventProps.js +172 -0
  188. package/src/util/getActiveCoordinate.js +253 -0
  189. package/src/util/getAxisTypeBasedOnLayout.js +17 -0
  190. package/src/util/getClassNameFromUnknown.js +8 -0
  191. package/src/util/getEveryNth.js +29 -0
  192. package/src/util/getRadiusAndStrokeWidthFromDot.js +28 -0
  193. package/src/util/getRelativeCoordinate.js +96 -0
  194. package/src/util/getSliced.js +11 -0
  195. package/src/util/isDomainSpecifiedByUser.js +255 -0
  196. package/src/util/isWellBehavedNumber.js +8 -0
  197. package/src/util/propsAreEqual.js +96 -0
  198. package/src/util/resolveDefaultProps.js +131 -0
  199. package/src/util/round.js +39 -0
  200. package/src/util/scale/RechartsScale.js +68 -0
  201. package/src/util/scale/createCategoricalInverse.js +77 -0
  202. package/src/util/scale/getNiceTickValues.js +354 -0
  203. package/src/util/scale/index.js +3 -0
  204. package/src/util/scale/util/arithmetic.js +51 -0
  205. package/src/util/stacks/getStackSeriesIdentifier.js +10 -0
  206. package/src/util/svgPropertiesAndEvents.ts +29 -0
  207. package/src/util/svgPropertiesNoEvents.js +383 -0
  208. package/src/util/types.ts +59 -0
  209. package/src/util/useAnimationId.ts +14 -0
  210. package/src/util/useId.ts +13 -0
  211. package/src/util/usePrefersReducedMotion.ts +30 -0
  212. package/src/util/useReportScale.ts +26 -0
  213. package/src/util/useUniqueId.js +34 -0
  214. package/src/zIndex/DefaultZIndexes.js +75 -0
  215. package/src/zIndex/ZIndexLayer.tsrx +80 -0
  216. package/src/zIndex/ZIndexLayer.tsrx.d.ts +2 -0
  217. package/src/zIndex/ZIndexPortal.tsrx +43 -0
  218. package/src/zIndex/getZIndexFromUnknown.js +15 -0
  219. package/src/zIndex/zIndexSelectors.js +45 -0
@@ -0,0 +1,253 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/getActiveCoordinate.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ function ownKeys(e, r) {
4
+ var t = Object.keys(e);
5
+ if (Object.getOwnPropertySymbols) {
6
+ var o = Object.getOwnPropertySymbols(e);
7
+ (r &&
8
+ (o = o.filter(function (r) {
9
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
10
+ })),
11
+ t.push.apply(t, o));
12
+ }
13
+ return t;
14
+ }
15
+ function _objectSpread(e) {
16
+ for (var r = 1; r < arguments.length; r++) {
17
+ var t = null != arguments[r] ? arguments[r] : {};
18
+ r % 2
19
+ ? ownKeys(Object(t), !0).forEach(function (r) {
20
+ _defineProperty(e, r, t[r]);
21
+ })
22
+ : Object.getOwnPropertyDescriptors
23
+ ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t))
24
+ : ownKeys(Object(t)).forEach(function (r) {
25
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
26
+ });
27
+ }
28
+ return e;
29
+ }
30
+ function _defineProperty(e, r, t) {
31
+ return (
32
+ (r = _toPropertyKey(r)) in e
33
+ ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 })
34
+ : (e[r] = t),
35
+ e
36
+ );
37
+ }
38
+ function _toPropertyKey(t) {
39
+ var i = _toPrimitive(t, 'string');
40
+ return 'symbol' == typeof i ? i : i + '';
41
+ }
42
+ function _toPrimitive(t, r) {
43
+ if ('object' != typeof t || !t) return t;
44
+ var e = t[Symbol.toPrimitive];
45
+ if (void 0 !== e) {
46
+ var i = e.call(t, r || 'default');
47
+ if ('object' != typeof i) return i;
48
+ throw new TypeError('@@toPrimitive must return a primitive value.');
49
+ }
50
+ return ('string' === r ? String : Number)(t);
51
+ }
52
+ import { polarToCartesian } from './PolarUtils';
53
+ import { mathSign } from './DataUtils';
54
+ export var getActiveCartesianCoordinate = (layout, tooltipTicks, activeIndex, pointer) => {
55
+ var entry = tooltipTicks.find((tick) => tick && tick.index === activeIndex);
56
+ if (entry) {
57
+ if (layout === 'horizontal') {
58
+ return {
59
+ x: entry.coordinate,
60
+ y: pointer.relativeY,
61
+ };
62
+ }
63
+ if (layout === 'vertical') {
64
+ return {
65
+ x: pointer.relativeX,
66
+ y: entry.coordinate,
67
+ };
68
+ }
69
+ }
70
+ return {
71
+ x: 0,
72
+ y: 0,
73
+ };
74
+ };
75
+
76
+ /**
77
+ * Get the active coordinate in polar coordinate system.
78
+ * Internally we only really use x and y, but this returned object is part of public API
79
+ * (because it goes straight to the tooltip content) so we keep all the other properties
80
+ * for backwards compatibility.
81
+ *
82
+ * @param layout - The polar layout type ('centric' or 'radial').
83
+ * @param tooltipTicks - Array of tick items used for tooltips.
84
+ * @param activeIndex - The index of the active tick.
85
+ * @param rangeObj - The range object containing polar chart properties.
86
+ * @returns The active coordinate object with polar properties.
87
+ */
88
+ export var getActivePolarCoordinate = (layout, tooltipTicks, activeIndex, rangeObj) => {
89
+ var entry = tooltipTicks.find((tick) => tick && tick.index === activeIndex);
90
+ if (entry) {
91
+ if (layout === 'centric') {
92
+ var _angle = entry.coordinate;
93
+ var _radius = rangeObj.radius;
94
+ return _objectSpread(
95
+ _objectSpread(
96
+ _objectSpread({}, rangeObj),
97
+ polarToCartesian(rangeObj.cx, rangeObj.cy, _radius, _angle),
98
+ ),
99
+ {},
100
+ {
101
+ angle: _angle,
102
+ radius: _radius,
103
+ },
104
+ );
105
+ }
106
+ var radius = entry.coordinate;
107
+ var angle = rangeObj.angle;
108
+ return _objectSpread(
109
+ _objectSpread(
110
+ _objectSpread({}, rangeObj),
111
+ polarToCartesian(rangeObj.cx, rangeObj.cy, radius, angle),
112
+ ),
113
+ {},
114
+ {
115
+ angle,
116
+ radius,
117
+ },
118
+ );
119
+ }
120
+ return {
121
+ angle: 0,
122
+ clockWise: false,
123
+ cx: 0,
124
+ cy: 0,
125
+ endAngle: 0,
126
+ innerRadius: 0,
127
+ outerRadius: 0,
128
+ radius: 0,
129
+ startAngle: 0,
130
+ x: 0,
131
+ y: 0,
132
+ };
133
+ };
134
+ export function isInCartesianRange(pointer, offset) {
135
+ var x = pointer.relativeX,
136
+ y = pointer.relativeY;
137
+ return (
138
+ x >= offset.left &&
139
+ x <= offset.left + offset.width &&
140
+ y >= offset.top &&
141
+ y <= offset.top + offset.height
142
+ );
143
+ }
144
+ export var calculateActiveTickIndex = (coordinate, ticks, unsortedTicks, axisType, range) => {
145
+ var _ticks$length;
146
+ var len =
147
+ (_ticks$length = ticks === null || ticks === void 0 ? void 0 : ticks.length) !== null &&
148
+ _ticks$length !== void 0
149
+ ? _ticks$length
150
+ : 0;
151
+
152
+ // if there are 1 or fewer ticks or if there is no coordinate then the active tick is at index 0
153
+ if (len <= 1 || coordinate == null) {
154
+ return 0;
155
+ }
156
+ if (
157
+ axisType === 'angleAxis' &&
158
+ range != null &&
159
+ Math.abs(Math.abs(range[1] - range[0]) - 360) <= 1e-6
160
+ ) {
161
+ // ticks are distributed in a circle
162
+ for (var i = 0; i < len; i++) {
163
+ var _unsortedTicks, _unsortedTicks2, _unsortedTicks$i, _unsortedTicks$, _unsortedTicks3;
164
+ var before =
165
+ i > 0
166
+ ? (_unsortedTicks = unsortedTicks[i - 1]) === null || _unsortedTicks === void 0
167
+ ? void 0
168
+ : _unsortedTicks.coordinate
169
+ : (_unsortedTicks2 = unsortedTicks[len - 1]) === null || _unsortedTicks2 === void 0
170
+ ? void 0
171
+ : _unsortedTicks2.coordinate;
172
+ var cur =
173
+ (_unsortedTicks$i = unsortedTicks[i]) === null || _unsortedTicks$i === void 0
174
+ ? void 0
175
+ : _unsortedTicks$i.coordinate;
176
+ var after =
177
+ i >= len - 1
178
+ ? (_unsortedTicks$ = unsortedTicks[0]) === null || _unsortedTicks$ === void 0
179
+ ? void 0
180
+ : _unsortedTicks$.coordinate
181
+ : (_unsortedTicks3 = unsortedTicks[i + 1]) === null || _unsortedTicks3 === void 0
182
+ ? void 0
183
+ : _unsortedTicks3.coordinate;
184
+ var sameDirectionCoord = void 0;
185
+ if (before == null || cur == null || after == null) {
186
+ continue;
187
+ }
188
+ if (mathSign(cur - before) !== mathSign(after - cur)) {
189
+ var diffInterval = [];
190
+ if (mathSign(after - cur) === mathSign(range[1] - range[0])) {
191
+ sameDirectionCoord = after;
192
+ var curInRange = cur + range[1] - range[0];
193
+ diffInterval[0] = Math.min(curInRange, (curInRange + before) / 2);
194
+ diffInterval[1] = Math.max(curInRange, (curInRange + before) / 2);
195
+ } else {
196
+ sameDirectionCoord = before;
197
+ var afterInRange = after + range[1] - range[0];
198
+ diffInterval[0] = Math.min(cur, (afterInRange + cur) / 2);
199
+ diffInterval[1] = Math.max(cur, (afterInRange + cur) / 2);
200
+ }
201
+ var sameInterval = [
202
+ Math.min(cur, (sameDirectionCoord + cur) / 2),
203
+ Math.max(cur, (sameDirectionCoord + cur) / 2),
204
+ ];
205
+ if (
206
+ (coordinate > sameInterval[0] && coordinate <= sameInterval[1]) ||
207
+ (coordinate >= diffInterval[0] && coordinate <= diffInterval[1])
208
+ ) {
209
+ var _unsortedTicks$i2;
210
+ return (_unsortedTicks$i2 = unsortedTicks[i]) === null || _unsortedTicks$i2 === void 0
211
+ ? void 0
212
+ : _unsortedTicks$i2.index;
213
+ }
214
+ } else {
215
+ var minValue = Math.min(before, after);
216
+ var maxValue = Math.max(before, after);
217
+ if (coordinate > (minValue + cur) / 2 && coordinate <= (maxValue + cur) / 2) {
218
+ var _unsortedTicks$i3;
219
+ return (_unsortedTicks$i3 = unsortedTicks[i]) === null || _unsortedTicks$i3 === void 0
220
+ ? void 0
221
+ : _unsortedTicks$i3.index;
222
+ }
223
+ }
224
+ }
225
+ } else if (ticks) {
226
+ // ticks are distributed in a single direction
227
+ for (var _i = 0; _i < len; _i++) {
228
+ var curr = ticks[_i];
229
+ if (curr == null) {
230
+ continue;
231
+ }
232
+ var next = ticks[_i + 1];
233
+ var prev = ticks[_i - 1];
234
+ if (_i === 0 && next != null && coordinate <= (curr.coordinate + next.coordinate) / 2) {
235
+ return curr.index;
236
+ }
237
+ if (_i === len - 1 && prev != null && coordinate > (curr.coordinate + prev.coordinate) / 2) {
238
+ return curr.index;
239
+ }
240
+ if (
241
+ _i > 0 &&
242
+ _i < len - 1 &&
243
+ prev != null &&
244
+ next != null &&
245
+ coordinate > (curr.coordinate + prev.coordinate) / 2 &&
246
+ coordinate <= (curr.coordinate + next.coordinate) / 2
247
+ ) {
248
+ return curr.index;
249
+ }
250
+ }
251
+ }
252
+ return -1;
253
+ };
@@ -0,0 +1,17 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/getAxisTypeBasedOnLayout.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ import { isCategoricalAxis } from './ChartUtils';
4
+
5
+ /**
6
+ * This function evaluates the "auto" axis domain type based on the chart layout and axis type.
7
+ * It outputs a definitive axis domain type that can be used for further processing.
8
+ */
9
+ export function getAxisTypeBasedOnLayout(layout, axisType, axisDomainType) {
10
+ if (axisDomainType !== 'auto') {
11
+ return axisDomainType;
12
+ }
13
+ if (layout == null) {
14
+ return undefined;
15
+ }
16
+ return isCategoricalAxis(layout, axisType) ? 'category' : 'number';
17
+ }
@@ -0,0 +1,8 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/getClassNameFromUnknown.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ export function getClassNameFromUnknown(u) {
4
+ if (u && typeof u === 'object' && 'className' in u && typeof u.className === 'string') {
5
+ return u.className;
6
+ }
7
+ return '';
8
+ }
@@ -0,0 +1,29 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/getEveryNth.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ /**
4
+ * Given an array and a number N, return a new array which contains every nTh
5
+ * element of the input array. For n below 1, an empty array is returned.
6
+ * For n equal to 1, the input array is returned as is.
7
+ * For n greater than the length of the array, an array containing the first element
8
+ * and every nTh element after that (if any) is returned.
9
+ *
10
+ * @param array An input array.
11
+ * @param n A number specifying which elements to take.
12
+ * @returns The result array of the same type as the input array.
13
+ */
14
+ export function getEveryNth(array, n) {
15
+ if (n < 1) {
16
+ return [];
17
+ }
18
+ if (n === 1) {
19
+ return array;
20
+ }
21
+ var result = [];
22
+ for (var i = 0; i < array.length; i += n) {
23
+ var item = array[i];
24
+ if (item !== undefined) {
25
+ result.push(item);
26
+ }
27
+ }
28
+ return result;
29
+ }
@@ -0,0 +1,28 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/getRadiusAndStrokeWidthFromDot.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ import { svgPropertiesNoEventsFromUnknown } from './svgPropertiesNoEvents';
4
+ export function getRadiusAndStrokeWidthFromDot(dot) {
5
+ var props = svgPropertiesNoEventsFromUnknown(dot);
6
+ var defaultR = 3;
7
+ var defaultStrokeWidth = 2;
8
+ if (props != null) {
9
+ var r = props.r,
10
+ strokeWidth = props.strokeWidth;
11
+ var realR = Number(r);
12
+ var realStrokeWidth = Number(strokeWidth);
13
+ if (Number.isNaN(realR) || realR < 0) {
14
+ realR = defaultR;
15
+ }
16
+ if (Number.isNaN(realStrokeWidth) || realStrokeWidth < 0) {
17
+ realStrokeWidth = defaultStrokeWidth;
18
+ }
19
+ return {
20
+ r: realR,
21
+ strokeWidth: realStrokeWidth,
22
+ };
23
+ }
24
+ return {
25
+ r: defaultR,
26
+ strokeWidth: defaultStrokeWidth,
27
+ };
28
+ }
@@ -0,0 +1,96 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/getRelativeCoordinate.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ /**
4
+ * Type guard to check if the pointer event is from an SVG element.
5
+ */
6
+ function isSvgPointer(pointer) {
7
+ return 'getBBox' in pointer.currentTarget && typeof pointer.currentTarget.getBBox === 'function';
8
+ }
9
+
10
+ /**
11
+ * Computes relative element coordinates from mouse or touch event.
12
+ *
13
+ * The output coordinates are relative to the top-left corner of the active element (= currentTarget),
14
+ * where the top-left corner is (0, 0).
15
+ * Moving right, the x-coordinate increases, and moving down, the y-coordinate increases.
16
+ *
17
+ * The coordinates are rounded to the nearest integer and account for CSS transform scale.
18
+ * So element that's scaled will return the same coordinates as element that's not scaled.
19
+ *
20
+ * In other words: you zoom in or out, numbers stay the same.
21
+ *
22
+ * This function works with both HTML elements and SVG elements.
23
+ *
24
+ * It works with both Mouse and Touch events.
25
+ * For Touch events, it returns an array of coordinates, one for each touch point.
26
+ * For Mouse events, it returns a single coordinate object.
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * // In an HTML element event handler. Legend passes the native event as the 3rd argument.
31
+ * <Legend onMouseMove={(_data, _i, e) => {
32
+ * // These coordinates are relative to the top-left corner of the Legend element
33
+ * const { relativeX, relativeY } = getRelativeCoordinate(e);
34
+ * console.log(`Mouse at Legend position: (${relativeX}, ${relativeY})`);
35
+ * }}>
36
+ * ```
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * // In an SVG element event handler. Area is an SVG element, and passes the event as second argument.
41
+ * <Area onMouseMove={(_, e) => {
42
+ * const { relativeX, relativeY } = getRelativeCoordinate(e);
43
+ * console.log(`Mouse at Area position: (${relativeX}, ${relativeY})`);
44
+ * // Here you can call usePlotArea to convert to chart coordinates
45
+ * }}>
46
+ * ```
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * // In a chart root touch handler. Chart root passes the event as second argument.
51
+ * <LineChart onTouchMove={(_, e) => {
52
+ * const touchPoints = getRelativeCoordinate(e);
53
+ * touchPoints.forEach(({ relativeX, relativeY }, index) => {
54
+ * console.log(`Touch point ${index} at LineChart position: (${relativeX}, ${relativeY})`);
55
+ * });
56
+ * }}>
57
+ * ```
58
+ *
59
+ * @since 3.8
60
+ * @param event The mouse or touch event from React event handlers (works with both HTML and SVG elements)
61
+ * @returns Coordinates relative to the top-left corner of the element. Single object for Mouse events, array of objects for Touch events.
62
+ */
63
+
64
+ export function getRelativeCoordinate(event) {
65
+ var rect = event.currentTarget.getBoundingClientRect();
66
+ var scaleX, scaleY;
67
+ if (isSvgPointer(event)) {
68
+ // For SVG elements, use getBBox() to get the intrinsic size in SVG coordinates
69
+ var bbox = event.currentTarget.getBBox();
70
+ scaleX = bbox.width > 0 ? rect.width / bbox.width : 1;
71
+ scaleY = bbox.height > 0 ? rect.height / bbox.height : 1;
72
+ } else {
73
+ // For HTML elements, use offsetWidth/offsetHeight
74
+ var element = event.currentTarget;
75
+ scaleX = element.offsetWidth > 0 ? rect.width / element.offsetWidth : 1;
76
+ scaleY = element.offsetHeight > 0 ? rect.height / element.offsetHeight : 1;
77
+ }
78
+ var getCoordinates = (clientX, clientY) => ({
79
+ /*
80
+ * Here it's important to use:
81
+ * - event.clientX and event.clientY to get the mouse position relative to the viewport, including scroll.
82
+ * - pageX and pageY are not used because they are relative to the whole document, and ignore scroll.
83
+ * - rect.left and rect.top are used to get the position of the chart relative to the viewport.
84
+ * - offsetX and offsetY are not used because they are relative to the offset parent
85
+ * which may or may not be the same as the clientX and clientY, depending on the position of the chart in the DOM
86
+ * and surrounding element styles. CSS position: relative, absolute, fixed, will change the offset parent.
87
+ * - scaleX and scaleY are necessary for when the chart element is scaled using CSS `transform: scale(N)`.
88
+ */
89
+ relativeX: Math.round((clientX - rect.left) / scaleX),
90
+ relativeY: Math.round((clientY - rect.top) / scaleY),
91
+ });
92
+ if ('touches' in event) {
93
+ return Array.from(event.touches).map((touch) => getCoordinates(touch.clientX, touch.clientY));
94
+ }
95
+ return getCoordinates(event.clientX, event.clientY);
96
+ }
@@ -0,0 +1,11 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/getSliced.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ export function getSliced(arr, startIndex, endIndex) {
4
+ if (!Array.isArray(arr)) {
5
+ return arr;
6
+ }
7
+ if (arr && startIndex + endIndex !== 0) {
8
+ return arr.slice(startIndex, endIndex + 1);
9
+ }
10
+ return arr;
11
+ }