@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,40 @@
1
+ // Port of state/SetTooltipEntrySettings.tsx — graphical items register their
2
+ // tooltip payload settings (panorama items never contribute).
3
+ import { useLayoutEffect, useRef } from 'octane';
4
+ import { useAppDispatch } from './hooks';
5
+ import {
6
+ addTooltipEntrySettings,
7
+ removeTooltipEntrySettings,
8
+ replaceTooltipEntrySettings,
9
+ } from './tooltipSlice';
10
+ import { useIsPanorama } from '../context/PanoramaContext';
11
+
12
+ export function SetTooltipEntrySettings(props: { tooltipEntrySettings: unknown }): null {
13
+ const { tooltipEntrySettings } = props;
14
+ const dispatch = useAppDispatch();
15
+ const isPanorama = useIsPanorama();
16
+ const prevSettingsRef = useRef<unknown>(null);
17
+ useLayoutEffect(() => {
18
+ if (isPanorama) {
19
+ // Panorama graphical items should never contribute to Tooltip payload.
20
+ return;
21
+ }
22
+ if (prevSettingsRef.current === null) {
23
+ dispatch(addTooltipEntrySettings(tooltipEntrySettings));
24
+ } else if (prevSettingsRef.current !== tooltipEntrySettings) {
25
+ dispatch(
26
+ replaceTooltipEntrySettings({ prev: prevSettingsRef.current, next: tooltipEntrySettings }),
27
+ );
28
+ }
29
+ prevSettingsRef.current = tooltipEntrySettings;
30
+ }, [tooltipEntrySettings, dispatch, isPanorama]);
31
+ useLayoutEffect(() => {
32
+ return () => {
33
+ if (prevSettingsRef.current) {
34
+ dispatch(removeTooltipEntrySettings(prevSettingsRef.current));
35
+ prevSettingsRef.current = null;
36
+ }
37
+ };
38
+ }, [dispatch]);
39
+ return null;
40
+ }
@@ -0,0 +1,36 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/state/brushSlice.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ import { createSlice } from '@reduxjs/toolkit';
4
+
5
+ /**
6
+ * From all Brush properties, only height has a default value and will always be defined.
7
+ * Other properties are nullable and will be computed from offsets and margins if they are not set.
8
+ */
9
+
10
+ var initialState = {
11
+ x: 0,
12
+ y: 0,
13
+ width: 0,
14
+ height: 0,
15
+ padding: {
16
+ top: 0,
17
+ right: 0,
18
+ bottom: 0,
19
+ left: 0,
20
+ },
21
+ };
22
+ export var brushSlice = createSlice({
23
+ name: 'brush',
24
+ initialState,
25
+ reducers: {
26
+ setBrushSettings(_state, action) {
27
+ if (action.payload == null) {
28
+ return initialState;
29
+ }
30
+ return action.payload;
31
+ },
32
+ },
33
+ });
34
+ var setBrushSettings = brushSlice.actions.setBrushSettings;
35
+ export { setBrushSettings };
36
+ export var brushReducer = brushSlice.reducer;
@@ -0,0 +1,256 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/state/cartesianAxisSlice.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 { createSlice, prepareAutoBatched } from '@reduxjs/toolkit';
53
+ import { castDraft } from 'immer';
54
+
55
+ /**
56
+ * @inline
57
+ */
58
+
59
+ export var defaultAxisId = 0;
60
+
61
+ /**
62
+ * Properties shared in X, Y, and Z axes.
63
+ * User defined axis settings, coming from props.
64
+ */
65
+
66
+ /**
67
+ * Controls how Recharts calculates "nice" tick values for numerical axes.
68
+ *
69
+ * - `'none'`: Recharts does not apply any tick-rounding algorithm; tick positions are
70
+ * determined entirely by d3, evenly spaced but not rounded to human-friendly numbers.
71
+ * There is no domain-extension logic applied in this mode.
72
+ *
73
+ * - `'auto'` *(default)*: Recharts automatically decides whether and how to apply tick
74
+ * niceties based on the domain definition. When the domain contains an `'auto'` keyword,
75
+ * Recharts uses the `'adaptive'` algorithm and may extend the domain slightly to
76
+ * produce clean tick labels. Otherwise, it applies the same algorithm while keeping
77
+ * ticks within the fixed domain. This mirrors the default behavior from Recharts v2.
78
+ *
79
+ * - `'adaptive'`: Always applies the space-efficient algorithm (`getAdaptiveStep`),
80
+ * which fills the available range as densely as possible while still rounding steps
81
+ * to reasonable numbers (e.g. 10, 20, 25). May produce less "round-looking" labels
82
+ * than `'snap125'`, but wastes less space. The domain-extension logic still applies
83
+ * when the domain contains an `'auto'` keyword.
84
+ *
85
+ * - `'snap125'`: Always applies the round-numbers algorithm (`getSnap125Step`), which
86
+ * snaps step sizes to values from the set {1, 2, 2.5, 5} × 10ⁿ. Produces very
87
+ * human-friendly labels (e.g. 0, 5, 10, 15, 20) but may leave blank space at the
88
+ * edges of the chart. The domain-extension logic still applies when the domain
89
+ * contains an `'auto'` keyword.
90
+ *
91
+ * @see {@link https://recharts.github.io/guide/axisTicks/}
92
+ * @inline
93
+ */
94
+
95
+ /**
96
+ * These are the external props, visible for users as they set them using our public API.
97
+ * There is all sorts of internal computed things based on these, but they will come through selectors.
98
+ *
99
+ * Properties shared between X and Y axes
100
+ */
101
+
102
+ /**
103
+ * Z axis is special because it's never displayed. It controls the size of Scatter dots,
104
+ * but it never displays ticks anywhere.
105
+ */
106
+
107
+ var initialState = {
108
+ xAxis: {},
109
+ yAxis: {},
110
+ zAxis: {},
111
+ };
112
+
113
+ /**
114
+ * This is the slice where each individual Axis element pushes its own configuration.
115
+ * Prefer to use this one instead of axisSlice.
116
+ */
117
+ var cartesianAxisSlice = createSlice({
118
+ name: 'cartesianAxis',
119
+ initialState,
120
+ reducers: {
121
+ addXAxis: {
122
+ reducer(state, action) {
123
+ state.xAxis[action.payload.id] = castDraft(action.payload);
124
+ },
125
+ prepare: prepareAutoBatched(),
126
+ },
127
+ replaceXAxis: {
128
+ reducer(state, action) {
129
+ var _action$payload = action.payload,
130
+ prev = _action$payload.prev,
131
+ next = _action$payload.next;
132
+ if (state.xAxis[prev.id] !== undefined) {
133
+ if (prev.id !== next.id) {
134
+ delete state.xAxis[prev.id];
135
+ }
136
+ state.xAxis[next.id] = castDraft(next);
137
+ }
138
+ },
139
+ prepare: prepareAutoBatched(),
140
+ },
141
+ removeXAxis: {
142
+ reducer(state, action) {
143
+ delete state.xAxis[action.payload.id];
144
+ },
145
+ prepare: prepareAutoBatched(),
146
+ },
147
+ addYAxis: {
148
+ reducer(state, action) {
149
+ state.yAxis[action.payload.id] = castDraft(action.payload);
150
+ },
151
+ prepare: prepareAutoBatched(),
152
+ },
153
+ replaceYAxis: {
154
+ reducer(state, action) {
155
+ var _action$payload2 = action.payload,
156
+ prev = _action$payload2.prev,
157
+ next = _action$payload2.next;
158
+ if (state.yAxis[prev.id] !== undefined) {
159
+ if (prev.id !== next.id) {
160
+ delete state.yAxis[prev.id];
161
+ }
162
+ state.yAxis[next.id] = castDraft(next);
163
+ }
164
+ },
165
+ prepare: prepareAutoBatched(),
166
+ },
167
+ removeYAxis: {
168
+ reducer(state, action) {
169
+ delete state.yAxis[action.payload.id];
170
+ },
171
+ prepare: prepareAutoBatched(),
172
+ },
173
+ addZAxis: {
174
+ reducer(state, action) {
175
+ state.zAxis[action.payload.id] = castDraft(action.payload);
176
+ },
177
+ prepare: prepareAutoBatched(),
178
+ },
179
+ replaceZAxis: {
180
+ reducer(state, action) {
181
+ var _action$payload3 = action.payload,
182
+ prev = _action$payload3.prev,
183
+ next = _action$payload3.next;
184
+ if (state.zAxis[prev.id] !== undefined) {
185
+ if (prev.id !== next.id) {
186
+ delete state.zAxis[prev.id];
187
+ }
188
+ state.zAxis[next.id] = castDraft(next);
189
+ }
190
+ },
191
+ prepare: prepareAutoBatched(),
192
+ },
193
+ removeZAxis: {
194
+ reducer(state, action) {
195
+ delete state.zAxis[action.payload.id];
196
+ },
197
+ prepare: prepareAutoBatched(),
198
+ },
199
+ updateYAxisWidth(state, action) {
200
+ var _action$payload4 = action.payload,
201
+ id = _action$payload4.id,
202
+ width = _action$payload4.width;
203
+ var axis = state.yAxis[id];
204
+ if (axis) {
205
+ var _history$;
206
+ var history = axis.widthHistory || [];
207
+ // An oscillation is detected when the new width is the same as the width before the last one.
208
+ // This is a simple A -> B -> A pattern. If the next width is B, and the difference is less than 1 pixel, we ignore it.
209
+ if (
210
+ history.length === 3 &&
211
+ history[0] === history[2] &&
212
+ width === history[1] &&
213
+ width !== axis.width &&
214
+ Math.abs(
215
+ width - ((_history$ = history[0]) !== null && _history$ !== void 0 ? _history$ : 0),
216
+ ) <= 1
217
+ ) {
218
+ return;
219
+ }
220
+ var newHistory = [...history, width].slice(-3);
221
+ state.yAxis[id] = _objectSpread(
222
+ _objectSpread({}, axis),
223
+ {},
224
+ {
225
+ width,
226
+ widthHistory: newHistory,
227
+ },
228
+ );
229
+ }
230
+ },
231
+ },
232
+ });
233
+ var _cartesianAxisSlice$a = cartesianAxisSlice.actions,
234
+ addXAxis = _cartesianAxisSlice$a.addXAxis,
235
+ replaceXAxis = _cartesianAxisSlice$a.replaceXAxis,
236
+ removeXAxis = _cartesianAxisSlice$a.removeXAxis,
237
+ addYAxis = _cartesianAxisSlice$a.addYAxis,
238
+ replaceYAxis = _cartesianAxisSlice$a.replaceYAxis,
239
+ removeYAxis = _cartesianAxisSlice$a.removeYAxis,
240
+ addZAxis = _cartesianAxisSlice$a.addZAxis,
241
+ replaceZAxis = _cartesianAxisSlice$a.replaceZAxis,
242
+ removeZAxis = _cartesianAxisSlice$a.removeZAxis,
243
+ updateYAxisWidth = _cartesianAxisSlice$a.updateYAxisWidth;
244
+ export {
245
+ addXAxis,
246
+ replaceXAxis,
247
+ removeXAxis,
248
+ addYAxis,
249
+ replaceYAxis,
250
+ removeYAxis,
251
+ addZAxis,
252
+ replaceZAxis,
253
+ removeZAxis,
254
+ updateYAxisWidth,
255
+ };
256
+ export var cartesianAxisReducer = cartesianAxisSlice.reducer;
@@ -0,0 +1,67 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/state/chartDataSlice.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ import { createSlice } from '@reduxjs/toolkit';
4
+ import { castDraft } from 'immer';
5
+
6
+ /**
7
+ * This is the data that's coming through main chart `data` prop
8
+ * Recharts is very flexible in what it accepts so the type is very flexible too.
9
+ * This will typically be an object, and various components will provide various `dataKey`
10
+ * that dictates how to pull data from that object.
11
+ *
12
+ * TL;DR: before dataKey
13
+ *
14
+ * @inline
15
+ */
16
+
17
+ /**
18
+ * So this is the same unknown type as ChartData but this is after the dataKey has been applied.
19
+ * We still don't know what the type is - that depends on what exactly it was before the dataKey application,
20
+ * and the dataKey can return whatever anyway - but let's keep it separate as a form of documentation.
21
+ *
22
+ * TL;DR: ChartData after dataKey.
23
+ */
24
+
25
+ export var initialChartDataState = {
26
+ chartData: undefined,
27
+ computedData: undefined,
28
+ dataStartIndex: 0,
29
+ dataEndIndex: 0,
30
+ };
31
+ var chartDataSlice = createSlice({
32
+ name: 'chartData',
33
+ initialState: initialChartDataState,
34
+ reducers: {
35
+ setChartData(state, action) {
36
+ state.chartData = castDraft(action.payload);
37
+ if (action.payload == null) {
38
+ state.dataStartIndex = 0;
39
+ state.dataEndIndex = 0;
40
+ return;
41
+ }
42
+ if (action.payload.length > 0 && state.dataEndIndex !== action.payload.length - 1) {
43
+ state.dataEndIndex = action.payload.length - 1;
44
+ }
45
+ },
46
+ setComputedData(state, action) {
47
+ state.computedData = action.payload;
48
+ },
49
+ setDataStartEndIndexes(state, action) {
50
+ var _action$payload = action.payload,
51
+ startIndex = _action$payload.startIndex,
52
+ endIndex = _action$payload.endIndex;
53
+ if (startIndex != null) {
54
+ state.dataStartIndex = startIndex;
55
+ }
56
+ if (endIndex != null) {
57
+ state.dataEndIndex = endIndex;
58
+ }
59
+ },
60
+ },
61
+ });
62
+ var _chartDataSlice$actio = chartDataSlice.actions,
63
+ setChartData = _chartDataSlice$actio.setChartData,
64
+ setDataStartEndIndexes = _chartDataSlice$actio.setDataStartEndIndexes,
65
+ setComputedData = _chartDataSlice$actio.setComputedData;
66
+ export { setChartData, setDataStartEndIndexes, setComputedData };
67
+ export var chartDataReducer = chartDataSlice.reducer;
@@ -0,0 +1,53 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/state/errorBarSlice.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ import { createSlice } from '@reduxjs/toolkit';
4
+
5
+ /**
6
+ * ErrorBars have lot more settings but all the others are scoped to the component itself.
7
+ * Only some of them required to be reported to the global store because XAxis and YAxis need to know
8
+ * if the error bar is contributing to extending the axis domain.
9
+ */
10
+
11
+ var initialState = {};
12
+ var errorBarSlice = createSlice({
13
+ name: 'errorBars',
14
+ initialState,
15
+ reducers: {
16
+ addErrorBar: (state, action) => {
17
+ var _action$payload = action.payload,
18
+ itemId = _action$payload.itemId,
19
+ errorBar = _action$payload.errorBar;
20
+ if (!state[itemId]) {
21
+ state[itemId] = [];
22
+ }
23
+ state[itemId].push(errorBar);
24
+ },
25
+ replaceErrorBar: (state, action) => {
26
+ var _action$payload2 = action.payload,
27
+ itemId = _action$payload2.itemId,
28
+ prev = _action$payload2.prev,
29
+ next = _action$payload2.next;
30
+ if (state[itemId]) {
31
+ state[itemId] = state[itemId].map((e) =>
32
+ e.dataKey === prev.dataKey && e.direction === prev.direction ? next : e,
33
+ );
34
+ }
35
+ },
36
+ removeErrorBar: (state, action) => {
37
+ var _action$payload3 = action.payload,
38
+ itemId = _action$payload3.itemId,
39
+ errorBar = _action$payload3.errorBar;
40
+ if (state[itemId]) {
41
+ state[itemId] = state[itemId].filter(
42
+ (e) => e.dataKey !== errorBar.dataKey || e.direction !== errorBar.direction,
43
+ );
44
+ }
45
+ },
46
+ },
47
+ });
48
+ var _errorBarSlice$action = errorBarSlice.actions,
49
+ addErrorBar = _errorBarSlice$action.addErrorBar,
50
+ replaceErrorBar = _errorBarSlice$action.replaceErrorBar,
51
+ removeErrorBar = _errorBarSlice$action.removeErrorBar;
52
+ export { addErrorBar, replaceErrorBar, removeErrorBar };
53
+ export var errorBarReducer = errorBarSlice.reducer;
@@ -0,0 +1,25 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/state/eventSettingsSlice.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ import { createSlice } from '@reduxjs/toolkit';
4
+ import { castDraft } from 'immer';
5
+ export var initialEventSettingsState = {
6
+ throttleDelay: 'raf',
7
+ throttledEvents: ['mousemove', 'touchmove', 'pointermove', 'scroll', 'wheel'],
8
+ };
9
+ var eventSettingsSlice = createSlice({
10
+ name: 'eventSettings',
11
+ initialState: initialEventSettingsState,
12
+ reducers: {
13
+ setEventSettings: (state, action) => {
14
+ if (action.payload.throttleDelay != null) {
15
+ state.throttleDelay = action.payload.throttleDelay;
16
+ }
17
+ if (action.payload.throttledEvents != null) {
18
+ state.throttledEvents = castDraft(action.payload.throttledEvents);
19
+ }
20
+ },
21
+ },
22
+ });
23
+ var setEventSettings = eventSettingsSlice.actions.setEventSettings;
24
+ export { setEventSettings };
25
+ export var eventSettingsReducer = eventSettingsSlice.reducer;
@@ -0,0 +1,127 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/state/externalEventsMiddleware.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ import { createAction, createListenerMiddleware } from '@reduxjs/toolkit';
4
+ import {
5
+ selectActiveLabel,
6
+ selectActiveTooltipCoordinate,
7
+ selectActiveTooltipDataKey,
8
+ selectActiveTooltipIndex,
9
+ selectIsTooltipActive,
10
+ } from './selectors/tooltipSelectors';
11
+ import { createEventProxy } from '../util/createEventProxy';
12
+ export var externalEventAction = createAction('externalEvent');
13
+ export var externalEventsMiddleware = createListenerMiddleware();
14
+
15
+ /*
16
+ * We need a Map keyed by event type because this middleware handles MULTIPLE different event types
17
+ * (click, mouseenter, mouseleave, mousedown, mouseup, contextmenu, dblclick, touchstart, touchmove, touchend)
18
+ * from the same DOM element. Different event types should NOT cancel each other's animation frames.
19
+ * For example, a click event and a mousemove event can happen in quick succession and both should be processed.
20
+ * This is different from mouseMoveMiddleware which only handles one event type and uses a single rafId.
21
+ */
22
+ var rafIdMap = new Map();
23
+ var timeoutIdMap = new Map();
24
+ var latestEventMap = new Map();
25
+ externalEventsMiddleware.startListening({
26
+ actionCreator: externalEventAction,
27
+ effect: (action, listenerApi) => {
28
+ var _action$payload = action.payload,
29
+ handler = _action$payload.handler,
30
+ reactEvent = _action$payload.reactEvent;
31
+ if (handler == null) {
32
+ return;
33
+ }
34
+ var eventType = reactEvent.type;
35
+ var eventProxy = createEventProxy(reactEvent);
36
+ latestEventMap.set(eventType, {
37
+ handler,
38
+ reactEvent: eventProxy,
39
+ });
40
+
41
+ // Cancel any pending execution for this event type
42
+ var existingRafId = rafIdMap.get(eventType);
43
+ if (existingRafId !== undefined) {
44
+ cancelAnimationFrame(existingRafId);
45
+ rafIdMap.delete(eventType);
46
+ }
47
+ var state = listenerApi.getState();
48
+ var _state$eventSettings = state.eventSettings,
49
+ throttleDelay = _state$eventSettings.throttleDelay,
50
+ throttledEvents = _state$eventSettings.throttledEvents;
51
+
52
+ /*
53
+ * reactEvent.type gives us the event type as a string, e.g., 'click', 'mousemove', etc.
54
+ * which is the same as the names used in throttledEvents array
55
+ * but that array is strictly typed as ReadonlyArray<keyof GlobalEventHandlersEventMap> | 'all' | undefined
56
+ * so that we can have relevant autocomplete and type checking elsewhere.
57
+ * This makes TypeScript panic because it refuses to call .includes() on ReadonlyArray<keyof GlobalEventHandlersEventMap>
58
+ * with a string argument.
59
+ * To satisfy TypeScript, we need to explicitly typecast throttledEvents here.
60
+ */
61
+ var eventListAsString = throttledEvents;
62
+
63
+ // Check if this event type should be throttled
64
+ // throttledEvents can be 'all' or an array of event names
65
+ var isThrottled =
66
+ eventListAsString === 'all' ||
67
+ (eventListAsString === null || eventListAsString === void 0
68
+ ? void 0
69
+ : eventListAsString.includes(eventType));
70
+ var existingTimeoutId = timeoutIdMap.get(eventType);
71
+ if (existingTimeoutId !== undefined && (typeof throttleDelay !== 'number' || !isThrottled)) {
72
+ clearTimeout(existingTimeoutId);
73
+ timeoutIdMap.delete(eventType);
74
+ }
75
+ var callback = () => {
76
+ var latestAction = latestEventMap.get(eventType);
77
+ try {
78
+ if (!latestAction) {
79
+ // This happens if the event was consumed by the leading edge and no new event came in
80
+ return;
81
+ }
82
+ var latestHandler = latestAction.handler,
83
+ latestEvent = latestAction.reactEvent;
84
+ var currentState = listenerApi.getState();
85
+ var nextState = {
86
+ activeCoordinate: selectActiveTooltipCoordinate(currentState),
87
+ activeDataKey: selectActiveTooltipDataKey(currentState),
88
+ activeIndex: selectActiveTooltipIndex(currentState),
89
+ activeLabel: selectActiveLabel(currentState),
90
+ activeTooltipIndex: selectActiveTooltipIndex(currentState),
91
+ isTooltipActive: selectIsTooltipActive(currentState),
92
+ };
93
+ if (latestHandler) {
94
+ latestHandler(nextState, latestEvent);
95
+ }
96
+ } finally {
97
+ rafIdMap.delete(eventType);
98
+ timeoutIdMap.delete(eventType);
99
+ latestEventMap.delete(eventType);
100
+ }
101
+ };
102
+ if (!isThrottled) {
103
+ // Execute immediately
104
+ callback();
105
+ return;
106
+ }
107
+ if (throttleDelay === 'raf') {
108
+ var rafId = requestAnimationFrame(callback);
109
+ rafIdMap.set(eventType, rafId);
110
+ } else if (typeof throttleDelay === 'number') {
111
+ if (!timeoutIdMap.has(eventType)) {
112
+ /*
113
+ * Leading edge execution - execute immediately on the first event
114
+ * and then start the cooldown period to throttle subsequent events.
115
+ */
116
+ callback();
117
+
118
+ // Start cooldown
119
+ var timeoutId = setTimeout(callback, throttleDelay);
120
+ timeoutIdMap.set(eventType, timeoutId);
121
+ }
122
+ } else {
123
+ // Should not happen based on type, but fallback to immediate
124
+ callback();
125
+ }
126
+ },
127
+ });
@@ -0,0 +1,91 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/state/graphicalItemsSlice.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ import { createSlice, current, prepareAutoBatched } from '@reduxjs/toolkit';
4
+ import { castDraft } from 'immer';
5
+
6
+ /**
7
+ * Unique ID of the graphical item.
8
+ * This is used to identify the graphical item in the state and in the React tree.
9
+ * This is required for every graphical item - it's either provided by the user or generated automatically.
10
+ */
11
+
12
+ var initialState = {
13
+ cartesianItems: [],
14
+ polarItems: [],
15
+ };
16
+ var graphicalItemsSlice = createSlice({
17
+ name: 'graphicalItems',
18
+ initialState,
19
+ reducers: {
20
+ addCartesianGraphicalItem: {
21
+ reducer(state, action) {
22
+ state.cartesianItems.push(castDraft(action.payload));
23
+ },
24
+ prepare: prepareAutoBatched(),
25
+ },
26
+ replaceCartesianGraphicalItem: {
27
+ reducer(state, action) {
28
+ var _action$payload = action.payload,
29
+ prev = _action$payload.prev,
30
+ next = _action$payload.next;
31
+ var index = current(state).cartesianItems.indexOf(castDraft(prev));
32
+ if (index > -1) {
33
+ state.cartesianItems[index] = castDraft(next);
34
+ }
35
+ },
36
+ prepare: prepareAutoBatched(),
37
+ },
38
+ removeCartesianGraphicalItem: {
39
+ reducer(state, action) {
40
+ var index = current(state).cartesianItems.indexOf(castDraft(action.payload));
41
+ if (index > -1) {
42
+ state.cartesianItems.splice(index, 1);
43
+ }
44
+ },
45
+ prepare: prepareAutoBatched(),
46
+ },
47
+ addPolarGraphicalItem: {
48
+ reducer(state, action) {
49
+ state.polarItems.push(castDraft(action.payload));
50
+ },
51
+ prepare: prepareAutoBatched(),
52
+ },
53
+ removePolarGraphicalItem: {
54
+ reducer(state, action) {
55
+ var index = current(state).polarItems.indexOf(castDraft(action.payload));
56
+ if (index > -1) {
57
+ state.polarItems.splice(index, 1);
58
+ }
59
+ },
60
+ prepare: prepareAutoBatched(),
61
+ },
62
+ replacePolarGraphicalItem: {
63
+ reducer(state, action) {
64
+ var _action$payload2 = action.payload,
65
+ prev = _action$payload2.prev,
66
+ next = _action$payload2.next;
67
+ var index = current(state).polarItems.indexOf(castDraft(prev));
68
+ if (index > -1) {
69
+ state.polarItems[index] = castDraft(next);
70
+ }
71
+ },
72
+ prepare: prepareAutoBatched(),
73
+ },
74
+ },
75
+ });
76
+ var _graphicalItemsSlice$ = graphicalItemsSlice.actions,
77
+ addCartesianGraphicalItem = _graphicalItemsSlice$.addCartesianGraphicalItem,
78
+ replaceCartesianGraphicalItem = _graphicalItemsSlice$.replaceCartesianGraphicalItem,
79
+ removeCartesianGraphicalItem = _graphicalItemsSlice$.removeCartesianGraphicalItem,
80
+ addPolarGraphicalItem = _graphicalItemsSlice$.addPolarGraphicalItem,
81
+ removePolarGraphicalItem = _graphicalItemsSlice$.removePolarGraphicalItem,
82
+ replacePolarGraphicalItem = _graphicalItemsSlice$.replacePolarGraphicalItem;
83
+ export {
84
+ addCartesianGraphicalItem,
85
+ replaceCartesianGraphicalItem,
86
+ removeCartesianGraphicalItem,
87
+ addPolarGraphicalItem,
88
+ removePolarGraphicalItem,
89
+ replacePolarGraphicalItem,
90
+ };
91
+ export var graphicalItemsReducer = graphicalItemsSlice.reducer;