@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,133 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/cartesian/getEquidistantTicks.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ import { isVisible } from '../util/TickUtils';
4
+ import { getEveryNth } from '../util/getEveryNth';
5
+ export function getEquidistantTicks(sign, boundaries, getTickSize, ticks, minTickGap) {
6
+ // If the ticks are readonly, then the slice might not be necessary
7
+ var result = (ticks || []).slice();
8
+ var initialStart = boundaries.start,
9
+ end = boundaries.end;
10
+ var index = 0;
11
+ // Premature optimisation idea 1: Estimate a lower bound, and start from there.
12
+ // For now, start from every tick
13
+ var stepsize = 1;
14
+ var start = initialStart;
15
+ var _loop = function _loop() {
16
+ // Given stepsize, evaluate whether every stepsize-th tick can be shown.
17
+ // If it can not, then increase the stepsize by 1, and try again.
18
+
19
+ var entry = ticks === null || ticks === void 0 ? void 0 : ticks[index];
20
+
21
+ // Break condition - If we have evaluated all the ticks, then we are done.
22
+ if (entry === undefined) {
23
+ return {
24
+ v: getEveryNth(ticks, stepsize),
25
+ };
26
+ }
27
+
28
+ // Check if the element collides with the next element
29
+ var i = index;
30
+ var size;
31
+ var getSize = () => {
32
+ if (size === undefined) {
33
+ size = getTickSize(entry, i);
34
+ }
35
+ return size;
36
+ };
37
+ var tickCoord = entry.coordinate;
38
+ // We will always show the first tick.
39
+ var isShow = index === 0 || isVisible(sign, tickCoord, getSize, start, end);
40
+ if (!isShow) {
41
+ // Start all over with a larger stepsize
42
+ index = 0;
43
+ start = initialStart;
44
+ stepsize += 1;
45
+ }
46
+ if (isShow) {
47
+ // If it can be shown, update the start
48
+ start = tickCoord + sign * (getSize() / 2 + minTickGap);
49
+ index += stepsize;
50
+ }
51
+ },
52
+ _ret;
53
+ while (stepsize <= result.length) {
54
+ _ret = _loop();
55
+ if (_ret) return _ret.v;
56
+ }
57
+ return [];
58
+ }
59
+ export function getEquidistantPreserveEndTicks(sign, boundaries, getTickSize, ticks, minTickGap) {
60
+ // If the ticks are readonly, then the slice might not be necessary
61
+ // Reworked logic for getEquidistantPreserveEndTicks
62
+ var result = (ticks || []).slice();
63
+ var len = result.length;
64
+ if (len === 0) {
65
+ return [];
66
+ }
67
+ var initialStart = boundaries.start,
68
+ end = boundaries.end;
69
+
70
+ // Start with stepsize = 1 (every tick) up to the maximum possible stepsize (len)
71
+ for (var stepsize = 1; stepsize <= len; stepsize++) {
72
+ // 1. Calculate the offset so the last tick (index len - 1) is always included in the sequence.
73
+ var offset = (len - 1) % stepsize;
74
+ var start = initialStart; // `start` tracks the coordinate of the last successfully drawn tick + gap
75
+ var ok = true;
76
+
77
+ // 2. Iterate through the end-anchored sequence: offset, offset + stepsize, ..., len - 1
78
+ var _loop2 = function _loop2() {
79
+ var entry = ticks[index];
80
+ if (entry == null) {
81
+ return 0; // continue
82
+ }
83
+ var i = index;
84
+ var size;
85
+
86
+ // Use a function to get size, as in the original code
87
+ var getSize = () => {
88
+ if (size === undefined) {
89
+ size = getTickSize(entry, i);
90
+ }
91
+ return size;
92
+ };
93
+ var tickCoord = entry.coordinate;
94
+
95
+ // 3. Apply visibility logic (including the first tick special case)
96
+ // The reviewer says *not* to unconditionally bypass checks for the last tick.
97
+ var isShow = index === offset || isVisible(sign, tickCoord, getSize, start, end);
98
+ if (!isShow) {
99
+ // If any tick in this end-anchored sequence fails visibility/collision,
100
+ // reject this stepsize and move to the next iteration (larger stepsize).
101
+ ok = false;
102
+ return 1; // break
103
+ }
104
+
105
+ // 4. If showable, update the 'start' coordinate for the next collision check
106
+ if (isShow) {
107
+ start = tickCoord + sign * (getSize() / 2 + minTickGap);
108
+ }
109
+ },
110
+ _ret2;
111
+ for (var index = offset; index < len; index += stepsize) {
112
+ _ret2 = _loop2();
113
+ if (_ret2 === 0) continue;
114
+ if (_ret2 === 1) break;
115
+ }
116
+
117
+ // 5. If the entire sequence for this stepsize passed the visibility check, return the result
118
+ if (ok) {
119
+ // Build the final result array explicitly using the validated stepsize and offset.
120
+ var finalTicks = [];
121
+ for (var _index = offset; _index < len; _index += stepsize) {
122
+ var tick = ticks[_index];
123
+ if (tick != null) {
124
+ finalTicks.push(tick);
125
+ }
126
+ }
127
+ return finalTicks;
128
+ }
129
+ }
130
+
131
+ // If no stepsize works (this shouldn't happen unless minTickGap is huge), return an empty array.
132
+ return [];
133
+ }
@@ -0,0 +1,280 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/cartesian/getTicks.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 { mathSign, isNumber } from '../util/DataUtils';
53
+ import { getStringSize } from '../util/DOMUtils';
54
+ import { Global } from '../util/Global';
55
+ import {
56
+ isVisible,
57
+ getTickBoundaries,
58
+ getNumberIntervalTicks,
59
+ getAngledTickWidth,
60
+ } from '../util/TickUtils';
61
+ import { getEquidistantTicks, getEquidistantPreserveEndTicks } from './getEquidistantTicks';
62
+ function getTicksEnd(sign, boundaries, getTickSize, ticks, minTickGap) {
63
+ var result = (ticks || []).slice();
64
+ var len = result.length;
65
+ var start = boundaries.start;
66
+ var end = boundaries.end;
67
+ var _loop = function _loop(i) {
68
+ var initialEntry = result[i];
69
+ if (initialEntry == null) {
70
+ return 1; // continue
71
+ }
72
+ var entry = initialEntry;
73
+ var size;
74
+ var getSize = () => {
75
+ if (size === undefined) {
76
+ size = getTickSize(initialEntry, i);
77
+ }
78
+ return size;
79
+ };
80
+ if (i === len - 1) {
81
+ var gap = sign * (entry.coordinate + (sign * getSize()) / 2 - end);
82
+ result[i] = entry = _objectSpread(
83
+ _objectSpread({}, entry),
84
+ {},
85
+ {
86
+ tickCoord: gap > 0 ? entry.coordinate - gap * sign : entry.coordinate,
87
+ },
88
+ );
89
+ } else {
90
+ result[i] = entry = _objectSpread(
91
+ _objectSpread({}, entry),
92
+ {},
93
+ {
94
+ tickCoord: entry.coordinate,
95
+ },
96
+ );
97
+ }
98
+ if (entry.tickCoord != null) {
99
+ var isShow = isVisible(sign, entry.tickCoord, getSize, start, end);
100
+ if (isShow) {
101
+ end = entry.tickCoord - sign * (getSize() / 2 + minTickGap);
102
+ result[i] = _objectSpread(
103
+ _objectSpread({}, entry),
104
+ {},
105
+ {
106
+ isShow: true,
107
+ },
108
+ );
109
+ }
110
+ }
111
+ };
112
+ for (var i = len - 1; i >= 0; i--) {
113
+ if (_loop(i)) continue;
114
+ }
115
+ return result;
116
+ }
117
+ function getTicksStart(sign, boundaries, getTickSize, ticks, minTickGap, preserveEnd) {
118
+ // This method is mutating the array so clone is indeed necessary here
119
+ var result = (ticks || []).slice();
120
+ var len = result.length;
121
+ var start = boundaries.start,
122
+ end = boundaries.end;
123
+ if (preserveEnd) {
124
+ // Try to guarantee the tail to be displayed
125
+ var tail = ticks[len - 1];
126
+ if (tail != null) {
127
+ var tailSize = getTickSize(tail, len - 1);
128
+ var tailGap = sign * (tail.coordinate + (sign * tailSize) / 2 - end);
129
+ result[len - 1] = tail = _objectSpread(
130
+ _objectSpread({}, tail),
131
+ {},
132
+ {
133
+ tickCoord: tailGap > 0 ? tail.coordinate - tailGap * sign : tail.coordinate,
134
+ },
135
+ );
136
+ if (tail.tickCoord != null) {
137
+ var isTailShow = isVisible(sign, tail.tickCoord, () => tailSize, start, end);
138
+ if (isTailShow) {
139
+ end = tail.tickCoord - sign * (tailSize / 2 + minTickGap);
140
+ result[len - 1] = _objectSpread(
141
+ _objectSpread({}, tail),
142
+ {},
143
+ {
144
+ isShow: true,
145
+ },
146
+ );
147
+ }
148
+ }
149
+ }
150
+ }
151
+ var count = preserveEnd ? len - 1 : len;
152
+ var _loop2 = function _loop2(i) {
153
+ var initialEntry = result[i];
154
+ if (initialEntry == null) {
155
+ return 1; // continue
156
+ }
157
+ var entry = initialEntry;
158
+ var size;
159
+ var getSize = () => {
160
+ if (size === undefined) {
161
+ size = getTickSize(initialEntry, i);
162
+ }
163
+ return size;
164
+ };
165
+ if (i === 0) {
166
+ var gap = sign * (entry.coordinate - (sign * getSize()) / 2 - start);
167
+ result[i] = entry = _objectSpread(
168
+ _objectSpread({}, entry),
169
+ {},
170
+ {
171
+ tickCoord: gap < 0 ? entry.coordinate - gap * sign : entry.coordinate,
172
+ },
173
+ );
174
+ } else {
175
+ result[i] = entry = _objectSpread(
176
+ _objectSpread({}, entry),
177
+ {},
178
+ {
179
+ tickCoord: entry.coordinate,
180
+ },
181
+ );
182
+ }
183
+ if (entry.tickCoord != null) {
184
+ var isShow = isVisible(sign, entry.tickCoord, getSize, start, end);
185
+ if (isShow) {
186
+ start = entry.tickCoord + sign * (getSize() / 2 + minTickGap);
187
+ result[i] = _objectSpread(
188
+ _objectSpread({}, entry),
189
+ {},
190
+ {
191
+ isShow: true,
192
+ },
193
+ );
194
+ }
195
+ }
196
+ };
197
+ for (var i = 0; i < count; i++) {
198
+ if (_loop2(i)) continue;
199
+ }
200
+ return result;
201
+ }
202
+ export function getTicks(props, fontSize, letterSpacing) {
203
+ var tick = props.tick,
204
+ ticks = props.ticks,
205
+ viewBox = props.viewBox,
206
+ minTickGap = props.minTickGap,
207
+ orientation = props.orientation,
208
+ interval = props.interval,
209
+ tickFormatter = props.tickFormatter,
210
+ unit = props.unit,
211
+ angle = props.angle;
212
+ if (!ticks || !ticks.length || !tick) {
213
+ return [];
214
+ }
215
+ if (isNumber(interval) || Global.isSsr) {
216
+ var _getNumberIntervalTic;
217
+ return (_getNumberIntervalTic = getNumberIntervalTicks(
218
+ ticks,
219
+ isNumber(interval) ? interval : 0,
220
+ )) !== null && _getNumberIntervalTic !== void 0
221
+ ? _getNumberIntervalTic
222
+ : [];
223
+ }
224
+ var candidates = [];
225
+ var sizeKey = orientation === 'top' || orientation === 'bottom' ? 'width' : 'height';
226
+ var unitSize =
227
+ unit && sizeKey === 'width'
228
+ ? getStringSize(unit, {
229
+ fontSize,
230
+ letterSpacing,
231
+ })
232
+ : {
233
+ width: 0,
234
+ height: 0,
235
+ };
236
+ var getTickSize = (content, index) => {
237
+ var value =
238
+ typeof tickFormatter === 'function' ? tickFormatter(content.value, index) : content.value;
239
+ // Recharts only supports angles when sizeKey === 'width'
240
+ return sizeKey === 'width'
241
+ ? getAngledTickWidth(
242
+ getStringSize(value, {
243
+ fontSize,
244
+ letterSpacing,
245
+ }),
246
+ unitSize,
247
+ angle,
248
+ )
249
+ : getStringSize(value, {
250
+ fontSize,
251
+ letterSpacing,
252
+ })[sizeKey];
253
+ };
254
+ var tick0 = ticks[0];
255
+ var tick1 = ticks[1];
256
+ var sign =
257
+ ticks.length >= 2 && tick0 != null && tick1 != null
258
+ ? mathSign(tick1.coordinate - tick0.coordinate)
259
+ : 1;
260
+ var boundaries = getTickBoundaries(viewBox, sign, sizeKey);
261
+ if (interval === 'equidistantPreserveStart') {
262
+ return getEquidistantTicks(sign, boundaries, getTickSize, ticks, minTickGap);
263
+ }
264
+ if (interval === 'equidistantPreserveEnd') {
265
+ return getEquidistantPreserveEndTicks(sign, boundaries, getTickSize, ticks, minTickGap);
266
+ }
267
+ if (interval === 'preserveStart' || interval === 'preserveStartEnd') {
268
+ candidates = getTicksStart(
269
+ sign,
270
+ boundaries,
271
+ getTickSize,
272
+ ticks,
273
+ minTickGap,
274
+ interval === 'preserveStartEnd',
275
+ );
276
+ } else {
277
+ candidates = getTicksEnd(sign, boundaries, getTickSize, ticks, minTickGap);
278
+ }
279
+ return candidates.filter((entry) => entry.isShow);
280
+ }
@@ -0,0 +1,33 @@
1
+ // Port of cartesian/useAnimatedLineLength.ts — monotonically-growing visible
2
+ // path length across data changes (drives the line-draw entrance dasharray).
3
+ import { useCallback, useRef } from 'octane';
4
+ import { round } from '../util/round';
5
+
6
+ export function useAnimatedLineLength(points: unknown) {
7
+ const startingLengthRef = useRef(0);
8
+ const maxAnimatedLengthRef = useRef(0);
9
+ const reachedFullRef = useRef(false);
10
+ const prevPointsRef = useRef(points);
11
+ if (prevPointsRef.current !== points) {
12
+ startingLengthRef.current = maxAnimatedLengthRef.current;
13
+ prevPointsRef.current = points;
14
+ }
15
+ // Stable callback (reads only refs) — never re-triggers consumers.
16
+ return useCallback((animationElapsedTime: number, totalLength: number) => {
17
+ if (reachedFullRef.current) {
18
+ return null;
19
+ }
20
+ const visibleLength = Math.min(
21
+ round(startingLengthRef.current + animationElapsedTime * totalLength),
22
+ totalLength,
23
+ );
24
+ if (animationElapsedTime > 0 && totalLength > 0) {
25
+ maxAnimatedLengthRef.current = Math.max(maxAnimatedLengthRef.current, visibleLength);
26
+ if (visibleLength >= totalLength) {
27
+ reachedFullRef.current = true;
28
+ return null;
29
+ }
30
+ }
31
+ return visibleLength;
32
+ }, []);
33
+ }
@@ -0,0 +1,22 @@
1
+ // Port of chart/BarChart.tsx.
2
+ import { arrayTooltipSearcher } from '../state/optionsSlice';
3
+ import { CartesianChart } from './CartesianChart.tsrx';
4
+
5
+ const allowedTooltipTypes = ['axis', 'item'];
6
+
7
+ /**
8
+ * @consumes ResponsiveContainerContext
9
+ * @provides CartesianViewBoxContext
10
+ * @provides CartesianChartContext
11
+ */
12
+ export function BarChart(props) {
13
+ const { ref, ...rest } = props;
14
+ return <CartesianChart
15
+ chartName="BarChart"
16
+ defaultTooltipEventType="axis"
17
+ validateTooltipEventTypes={allowedTooltipTypes}
18
+ tooltipPayloadSearcher={arrayTooltipSearcher}
19
+ categoricalChartProps={rest}
20
+ ref={ref}
21
+ />;
22
+ }
@@ -0,0 +1,2 @@
1
+ // Type declaration for the .tsrx component (resolved by relative path).
2
+ export declare const BarChart: (props: Record<string, unknown>) => unknown;
@@ -0,0 +1,76 @@
1
+ // Port of chart/CartesianChart.tsx — the store provider + reporter components
2
+ // every cartesian chart (BarChart, LineChart, …) shares.
3
+ import { RechartsStoreProvider } from '../state/RechartsStoreProvider.tsrx';
4
+ import { ChartDataContextProvider } from '../context/chartDataContext.ts';
5
+ import { ReportMainChartProps } from '../state/ReportMainChartProps';
6
+ import { ReportChartProps } from '../state/ReportChartProps';
7
+ import { ReportEventSettings } from '../state/ReportEventSettings';
8
+ import { CategoricalChart } from './CategoricalChart.tsrx';
9
+ import { resolveDefaultProps } from '../util/resolveDefaultProps';
10
+ import { initialEventSettingsState } from '../state/eventSettingsSlice';
11
+
12
+ const defaultMargin = { top: 5, right: 5, bottom: 5, left: 5 };
13
+
14
+ export const defaultCartesianChartProps = {
15
+ accessibilityLayer: true,
16
+ barCategoryGap: '10%',
17
+ barGap: 4,
18
+ layout: 'horizontal',
19
+ margin: defaultMargin,
20
+ responsive: false,
21
+ reverseStackOrder: false,
22
+ stackOffset: 'none',
23
+ syncMethod: 'index',
24
+ ...initialEventSettingsState,
25
+ };
26
+
27
+ /**
28
+ * One-time, immutable options deciding chart behavior — usually filled in by
29
+ * the convenience wrappers (BarChart, LineChart, …).
30
+ */
31
+ export function CartesianChart(props) @{
32
+ const rootChartProps = resolveDefaultProps(
33
+ props.categoricalChartProps,
34
+ defaultCartesianChartProps,
35
+ );
36
+ const {
37
+ chartName,
38
+ defaultTooltipEventType,
39
+ validateTooltipEventTypes,
40
+ tooltipPayloadSearcher,
41
+ categoricalChartProps,
42
+ ref,
43
+ } = props;
44
+ const options = {
45
+ chartName,
46
+ defaultTooltipEventType,
47
+ validateTooltipEventTypes,
48
+ tooltipPayloadSearcher,
49
+ eventEmitter: undefined,
50
+ };
51
+ <RechartsStoreProvider
52
+ preloadedState={{ options }}
53
+ reduxStoreName={categoricalChartProps.id ?? chartName}
54
+ >
55
+ <ChartDataContextProvider chartData={categoricalChartProps.data} />
56
+ <ReportMainChartProps layout={rootChartProps.layout} margin={rootChartProps.margin} />
57
+ <ReportEventSettings
58
+ throttleDelay={rootChartProps.throttleDelay}
59
+ throttledEvents={rootChartProps.throttledEvents}
60
+ />
61
+ <ReportChartProps
62
+ baseValue={rootChartProps.baseValue}
63
+ accessibilityLayer={rootChartProps.accessibilityLayer}
64
+ barCategoryGap={rootChartProps.barCategoryGap}
65
+ maxBarSize={rootChartProps.maxBarSize}
66
+ stackOffset={rootChartProps.stackOffset}
67
+ barGap={rootChartProps.barGap}
68
+ barSize={rootChartProps.barSize}
69
+ syncId={rootChartProps.syncId}
70
+ syncMethod={rootChartProps.syncMethod}
71
+ className={rootChartProps.className}
72
+ reverseStackOrder={rootChartProps.reverseStackOrder}
73
+ />
74
+ <CategoricalChart {...rootChartProps} ref={ref} />
75
+ </RechartsStoreProvider>
76
+ }
@@ -0,0 +1,10 @@
1
+ // Type declaration for the .tsrx component (resolved by relative path).
2
+ export declare const defaultCartesianChartProps: Record<string, unknown>;
3
+ export declare const CartesianChart: (props: {
4
+ chartName: string;
5
+ defaultTooltipEventType: string;
6
+ validateTooltipEventTypes: readonly string[];
7
+ tooltipPayloadSearcher: unknown;
8
+ categoricalChartProps: Record<string, unknown>;
9
+ ref?: unknown;
10
+ }) => unknown;
@@ -0,0 +1,54 @@
1
+ // Port of chart/CategoricalChart.tsx — the wrapper-div + root-svg pairing
2
+ // (or, in compact/panorama mode, just the bare surface).
3
+ import { RootSurface } from '../container/RootSurface.tsrx';
4
+ import { RechartsWrapper } from './RechartsWrapper.tsrx';
5
+ import { ClipPathProvider } from '../container/ClipPathProvider.tsrx';
6
+ import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
7
+ import { ReportChartSize } from '../context/chartLayoutContext.ts';
8
+
9
+ export function CategoricalChart(props) {
10
+ const {
11
+ width,
12
+ height,
13
+ responsive,
14
+ children,
15
+ className,
16
+ style,
17
+ compact,
18
+ title,
19
+ desc,
20
+ ref,
21
+ ...others
22
+ } = props;
23
+ const attrs = svgPropertiesNoEvents(others);
24
+ // "compact" is the Brush panorama mode (but it's public, so it can render
25
+ // outside Brush too).
26
+ if (compact) {
27
+ return <>
28
+ <ReportChartSize width={width} height={height} />
29
+ <RootSurface otherAttributes={attrs} title={title} desc={desc}>{children}</RootSurface>
30
+ </>;
31
+ }
32
+ return <RechartsWrapper
33
+ className={className}
34
+ style={style}
35
+ width={width}
36
+ height={height}
37
+ responsive={responsive ?? false}
38
+ onClick={props.onClick}
39
+ onMouseLeave={props.onMouseLeave}
40
+ onMouseEnter={props.onMouseEnter}
41
+ onMouseMove={props.onMouseMove}
42
+ onMouseDown={props.onMouseDown}
43
+ onMouseUp={props.onMouseUp}
44
+ onContextMenu={props.onContextMenu}
45
+ onDoubleClick={props.onDoubleClick}
46
+ onTouchStart={props.onTouchStart}
47
+ onTouchMove={props.onTouchMove}
48
+ onTouchEnd={props.onTouchEnd}
49
+ >
50
+ <RootSurface otherAttributes={attrs} title={title} desc={desc} ref={ref}>
51
+ <ClipPathProvider>{children}</ClipPathProvider>
52
+ </RootSurface>
53
+ </RechartsWrapper>;
54
+ }
@@ -0,0 +1,22 @@
1
+ // Port of chart/LineChart.tsx.
2
+ import { arrayTooltipSearcher } from '../state/optionsSlice';
3
+ import { CartesianChart } from './CartesianChart.tsrx';
4
+
5
+ const allowedTooltipTypes = ['axis'];
6
+
7
+ /**
8
+ * @consumes ResponsiveContainerContext
9
+ * @provides CartesianViewBoxContext
10
+ * @provides CartesianChartContext
11
+ */
12
+ export function LineChart(props) {
13
+ const { ref, ...rest } = props;
14
+ return <CartesianChart
15
+ chartName="LineChart"
16
+ defaultTooltipEventType="axis"
17
+ validateTooltipEventTypes={allowedTooltipTypes}
18
+ tooltipPayloadSearcher={arrayTooltipSearcher}
19
+ categoricalChartProps={rest}
20
+ ref={ref}
21
+ />;
22
+ }
@@ -0,0 +1,2 @@
1
+ // Type declaration for the .tsrx component (resolved by relative path).
2
+ export declare const LineChart: (props: Record<string, unknown>) => unknown;