@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,354 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/scale/getNiceTickValues.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ function _slicedToArray(r, e) {
4
+ return (
5
+ _arrayWithHoles(r) ||
6
+ _iterableToArrayLimit(r, e) ||
7
+ _unsupportedIterableToArray(r, e) ||
8
+ _nonIterableRest()
9
+ );
10
+ }
11
+ function _nonIterableRest() {
12
+ throw new TypeError(
13
+ 'Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.',
14
+ );
15
+ }
16
+ function _unsupportedIterableToArray(r, a) {
17
+ if (r) {
18
+ if ('string' == typeof r) return _arrayLikeToArray(r, a);
19
+ var t = {}.toString.call(r).slice(8, -1);
20
+ return (
21
+ 'Object' === t && r.constructor && (t = r.constructor.name),
22
+ 'Map' === t || 'Set' === t
23
+ ? Array.from(r)
24
+ : 'Arguments' === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)
25
+ ? _arrayLikeToArray(r, a)
26
+ : void 0
27
+ );
28
+ }
29
+ }
30
+ function _arrayLikeToArray(r, a) {
31
+ (null == a || a > r.length) && (a = r.length);
32
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
33
+ return n;
34
+ }
35
+ function _iterableToArrayLimit(r, l) {
36
+ var t =
37
+ null == r ? null : ('undefined' != typeof Symbol && r[Symbol.iterator]) || r['@@iterator'];
38
+ if (null != t) {
39
+ var e,
40
+ n,
41
+ i,
42
+ u,
43
+ a = [],
44
+ f = !0,
45
+ o = !1;
46
+ try {
47
+ if (((i = (t = t.call(r)).next), 0 === l)) {
48
+ if (Object(t) !== t) return;
49
+ f = !1;
50
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
51
+ } catch (r) {
52
+ ((o = !0), (n = r));
53
+ } finally {
54
+ try {
55
+ if (!f && null != t.return && ((u = t.return()), Object(u) !== u)) return;
56
+ } finally {
57
+ if (o) throw n;
58
+ }
59
+ }
60
+ return a;
61
+ }
62
+ }
63
+ function _arrayWithHoles(r) {
64
+ if (Array.isArray(r)) return r;
65
+ }
66
+ /**
67
+ * @fileOverview calculate tick values of scale
68
+ * @author xile611, arcthur
69
+ * @date 2015-09-17
70
+ */
71
+ import Decimal from 'decimal.js-light';
72
+ import { getDigitCount, rangeStep } from './util/arithmetic';
73
+ /**
74
+ * Calculate a interval of a minimum value and a maximum value
75
+ *
76
+ * @param {Number} min The minimum value
77
+ * @param {Number} max The maximum value
78
+ * @return {Array} An interval
79
+ */
80
+ export var getValidInterval = (_ref) => {
81
+ var _ref2 = _slicedToArray(_ref, 2),
82
+ min = _ref2[0],
83
+ max = _ref2[1];
84
+ var validMin = min,
85
+ validMax = max;
86
+
87
+ // exchange
88
+ if (min > max) {
89
+ validMin = max;
90
+ validMax = min;
91
+ }
92
+ return [validMin, validMax];
93
+ };
94
+
95
+ /**
96
+ * Calculate the step which is easy to understand between ticks, like 10, 20, 25
97
+ *
98
+ * @param roughStep The rough step calculated by dividing the difference by the tickCount
99
+ * @param allowDecimals Allow the ticks to be decimals or not
100
+ * @param correctionFactor A correction factor
101
+ * @return The step which is easy to understand between two ticks
102
+ */
103
+ export var getAdaptiveStep = (roughStep, allowDecimals, correctionFactor) => {
104
+ if (roughStep.lte(0)) {
105
+ return new Decimal(0);
106
+ }
107
+ var digitCount = getDigitCount(roughStep.toNumber());
108
+ // The ratio between the rough step and the smallest number which has a bigger
109
+ // order of magnitudes than the rough step
110
+ var digitCountValue = new Decimal(10).pow(digitCount);
111
+ var stepRatio = roughStep.div(digitCountValue);
112
+ // When an integer and a float multiplied, the accuracy of result may be wrong
113
+ var stepRatioScale = digitCount !== 1 ? 0.05 : 0.1;
114
+ var amendStepRatio = new Decimal(Math.ceil(stepRatio.div(stepRatioScale).toNumber()))
115
+ .add(correctionFactor)
116
+ .mul(stepRatioScale);
117
+ var formatStep = amendStepRatio.mul(digitCountValue);
118
+ return allowDecimals
119
+ ? new Decimal(formatStep.toNumber())
120
+ : new Decimal(Math.ceil(formatStep.toNumber()));
121
+ };
122
+ /**
123
+ * The snap125 step algorithm snaps to nice numbers (1, 2, 2.5, 5) at each
124
+ * order of magnitude, producing human-friendly tick intervals like
125
+ * 0, 5, 10, 15, 20 instead of 0, 4, 8, 12, 16.
126
+ *
127
+ * This is opt-in and can be enabled via the `niceTicks` prop on axis components.
128
+ *
129
+ * @param roughStep The rough step calculated by dividing the difference by the tickCount
130
+ * @param allowDecimals Allow the ticks to be decimals or not
131
+ * @param correctionFactor A correction factor
132
+ * @return The step which is easy to understand between two ticks
133
+ */
134
+ export var getSnap125Step = (roughStep, allowDecimals, correctionFactor) => {
135
+ var _NICE_STEPS$niceIdx;
136
+ if (roughStep.lte(0)) {
137
+ return new Decimal(0);
138
+ }
139
+ var NICE_STEPS = [1, 2, 2.5, 5];
140
+ var roughNum = roughStep.toNumber();
141
+ var exponent = Math.floor(new Decimal(roughNum).abs().log(10).toNumber());
142
+ var magnitude = new Decimal(10).pow(exponent);
143
+
144
+ // normalized is in the range [1, 10)
145
+ var normalized = roughStep.div(magnitude).toNumber();
146
+
147
+ // Find the smallest nice step >= normalized (ceiling)
148
+ var niceIdx = NICE_STEPS.findIndex((s) => s >= normalized - 1e-10);
149
+ if (niceIdx === -1) {
150
+ // normalized > 5 (e.g. 7.3), move to next order of magnitude
151
+ magnitude = magnitude.mul(10);
152
+ niceIdx = 0;
153
+ }
154
+
155
+ // Apply correction factor by stepping through the nice number sequence
156
+ niceIdx += correctionFactor;
157
+ if (niceIdx >= NICE_STEPS.length) {
158
+ var extraMag = Math.floor(niceIdx / NICE_STEPS.length);
159
+ niceIdx %= NICE_STEPS.length;
160
+ magnitude = magnitude.mul(new Decimal(10).pow(extraMag));
161
+ }
162
+ var niceStep =
163
+ (_NICE_STEPS$niceIdx = NICE_STEPS[niceIdx]) !== null && _NICE_STEPS$niceIdx !== void 0
164
+ ? _NICE_STEPS$niceIdx
165
+ : 1;
166
+ var formatStep = new Decimal(niceStep).mul(magnitude);
167
+ return allowDecimals ? formatStep : new Decimal(Math.ceil(formatStep.toNumber()));
168
+ };
169
+
170
+ /**
171
+ * calculate the ticks when the minimum value equals to the maximum value
172
+ *
173
+ * @param value The minimum value which is also the maximum value
174
+ * @param tickCount The count of ticks
175
+ * @param allowDecimals Allow the ticks to be decimals or not
176
+ * @return array of ticks
177
+ */
178
+ export var getTickOfSingleValue = (value, tickCount, allowDecimals) => {
179
+ var step = new Decimal(1);
180
+ // calculate the middle value of ticks
181
+ var middle = new Decimal(value);
182
+ if (!middle.isint() && allowDecimals) {
183
+ var absVal = Math.abs(value);
184
+ if (absVal < 1) {
185
+ // The step should be a float number when the difference is smaller than 1
186
+ step = new Decimal(10).pow(getDigitCount(value) - 1);
187
+ middle = new Decimal(Math.floor(middle.div(step).toNumber())).mul(step);
188
+ } else if (absVal > 1) {
189
+ // Return the maximum integer which is smaller than 'value' when 'value' is greater than 1
190
+ middle = new Decimal(Math.floor(value));
191
+ }
192
+ } else if (value === 0) {
193
+ middle = new Decimal(Math.floor((tickCount - 1) / 2));
194
+ } else if (!allowDecimals) {
195
+ middle = new Decimal(Math.floor(value));
196
+ }
197
+ var middleIndex = Math.floor((tickCount - 1) / 2);
198
+ var ticks = [];
199
+ for (var i = 0; i < tickCount; i++) {
200
+ ticks.push(middle.add(new Decimal(i - middleIndex).mul(step)).toNumber());
201
+ }
202
+ return ticks;
203
+ };
204
+
205
+ /**
206
+ * Calculate the step
207
+ *
208
+ * @param min The minimum value of an interval
209
+ * @param max The maximum value of an interval
210
+ * @param tickCount The count of ticks
211
+ * @param allowDecimals Allow the ticks to be decimals or not
212
+ * @param correctionFactor A correction factor
213
+ * @return The step, minimum value of ticks, maximum value of ticks
214
+ */
215
+ var _calculateStep = function calculateStep(min, max, tickCount, allowDecimals) {
216
+ var correctionFactor = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
217
+ var stepFn = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : getAdaptiveStep;
218
+ // dirty hack (for recharts' test)
219
+ if (!Number.isFinite((max - min) / (tickCount - 1))) {
220
+ return {
221
+ step: new Decimal(0),
222
+ tickMin: new Decimal(0),
223
+ tickMax: new Decimal(0),
224
+ };
225
+ }
226
+
227
+ // The step which is easy to understand between two ticks
228
+ var step = stepFn(new Decimal(max).sub(min).div(tickCount - 1), allowDecimals, correctionFactor);
229
+
230
+ // A medial value of ticks
231
+ var middle;
232
+
233
+ // When 0 is inside the interval, 0 should be a tick
234
+ if (min <= 0 && max >= 0) {
235
+ middle = new Decimal(0);
236
+ } else {
237
+ // calculate the middle value
238
+ middle = new Decimal(min).add(max).div(2);
239
+ // minus modulo value
240
+ middle = middle.sub(new Decimal(middle).mod(step));
241
+ }
242
+ var belowCount = Math.ceil(middle.sub(min).div(step).toNumber());
243
+ var upCount = Math.ceil(new Decimal(max).sub(middle).div(step).toNumber());
244
+ var scaleCount = belowCount + upCount + 1;
245
+ if (scaleCount > tickCount) {
246
+ // When more ticks need to cover the interval, step should be bigger.
247
+ return _calculateStep(min, max, tickCount, allowDecimals, correctionFactor + 1, stepFn);
248
+ }
249
+ if (scaleCount < tickCount) {
250
+ // When less ticks can cover the interval, we should add some additional ticks
251
+ upCount = max > 0 ? upCount + (tickCount - scaleCount) : upCount;
252
+ belowCount = max > 0 ? belowCount : belowCount + (tickCount - scaleCount);
253
+ }
254
+ return {
255
+ step,
256
+ tickMin: middle.sub(new Decimal(belowCount).mul(step)),
257
+ tickMax: middle.add(new Decimal(upCount).mul(step)),
258
+ };
259
+ };
260
+
261
+ /**
262
+ * Calculate the ticks of an interval. Ticks can appear outside the interval
263
+ * if it makes them more rounded and nice.
264
+ *
265
+ * @param tuple of [min,max] min: The minimum value, max: The maximum value
266
+ * @param tickCount The count of ticks
267
+ * @param allowDecimals Allow the ticks to be decimals or not
268
+ * @param niceTicksMode The algorithm to use for calculating nice ticks.
269
+ * @return array of ticks
270
+ */
271
+ export { _calculateStep as calculateStep };
272
+ export var getNiceTickValues = function getNiceTickValues(_ref3) {
273
+ var _ref4 = _slicedToArray(_ref3, 2),
274
+ min = _ref4[0],
275
+ max = _ref4[1];
276
+ var tickCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
277
+ var allowDecimals = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
278
+ var niceTicksMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'auto';
279
+ // More than two ticks should be return
280
+ var count = Math.max(tickCount, 2);
281
+ var _getValidInterval = getValidInterval([min, max]),
282
+ _getValidInterval2 = _slicedToArray(_getValidInterval, 2),
283
+ cormin = _getValidInterval2[0],
284
+ cormax = _getValidInterval2[1];
285
+ if (cormin === -Infinity || cormax === Infinity) {
286
+ var _values =
287
+ cormax === Infinity
288
+ ? [cormin, ...Array(tickCount - 1).fill(Infinity)]
289
+ : [...Array(tickCount - 1).fill(-Infinity), cormax];
290
+ return min > max ? _values.reverse() : _values;
291
+ }
292
+ if (cormin === cormax) {
293
+ return getTickOfSingleValue(cormin, tickCount, allowDecimals);
294
+ }
295
+ var stepFn = niceTicksMode === 'snap125' ? getSnap125Step : getAdaptiveStep;
296
+
297
+ // Get the step between two ticks
298
+ var _calculateStep2 = _calculateStep(cormin, cormax, count, allowDecimals, 0, stepFn),
299
+ step = _calculateStep2.step,
300
+ tickMin = _calculateStep2.tickMin,
301
+ tickMax = _calculateStep2.tickMax;
302
+ var values = rangeStep(tickMin, tickMax.add(new Decimal(0.1).mul(step)), step);
303
+ return min > max ? values.reverse() : values;
304
+ };
305
+
306
+ /**
307
+ * Calculate the ticks of an interval.
308
+ * Ticks will be constrained to the interval [min, max] even if it makes them less rounded and nice.
309
+ *
310
+ * @param tuple of [min,max] min: The minimum value, max: The maximum value
311
+ * @param tickCount The count of ticks. This function may return less than tickCount ticks if the interval is too small.
312
+ * @param allowDecimals Allow the ticks to be decimals or not
313
+ * @param niceTicksMode The algorithm to use for calculating nice ticks. See {@link NiceTicksAlgorithm}.
314
+ * @return array of ticks
315
+ */
316
+ export var getTickValuesFixedDomain = function getTickValuesFixedDomain(_ref5, tickCount) {
317
+ var _ref6 = _slicedToArray(_ref5, 2),
318
+ min = _ref6[0],
319
+ max = _ref6[1];
320
+ var allowDecimals = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
321
+ var niceTicksMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'auto';
322
+ // More than two ticks should be return
323
+ var _getValidInterval3 = getValidInterval([min, max]),
324
+ _getValidInterval4 = _slicedToArray(_getValidInterval3, 2),
325
+ cormin = _getValidInterval4[0],
326
+ cormax = _getValidInterval4[1];
327
+ if (cormin === -Infinity || cormax === Infinity) {
328
+ return [min, max];
329
+ }
330
+ if (cormin === cormax) {
331
+ return [cormin];
332
+ }
333
+ var stepFn = niceTicksMode === 'snap125' ? getSnap125Step : getAdaptiveStep;
334
+ var count = Math.max(tickCount, 2);
335
+ var step = stepFn(new Decimal(cormax).sub(cormin).div(count - 1), allowDecimals, 0);
336
+ var values = [...rangeStep(new Decimal(cormin), new Decimal(cormax), step), cormax];
337
+ if (allowDecimals === false) {
338
+ /*
339
+ * allowDecimals is false means that we want to have integer ticks.
340
+ * The step is guaranteed to be an integer in the code above which is great start
341
+ * but when the first step is not an integer, it will start stepping from a decimal value anyway.
342
+ * So we need to round all the values to integers after the fact.
343
+ * The domain boundary (cormax) is appended after the rangeStep values. When
344
+ * cormax rounds down to the same integer as the last rangeStep value, we end up
345
+ * with a duplicate trailing tick. Remove it.
346
+ */
347
+ values = values.map((value) => Math.round(value));
348
+ var last = values.length - 1;
349
+ if (last > 0 && values[last] === values[last - 1]) {
350
+ values = values.slice(0, last);
351
+ }
352
+ }
353
+ return min > max ? values.reverse() : values;
354
+ };
@@ -0,0 +1,3 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/scale/index.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ export { getNiceTickValues, getTickValuesFixedDomain } from './getNiceTickValues';
@@ -0,0 +1,51 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/scale/util/arithmetic.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ /**
4
+ * @fileOverview Some common arithmetic methods
5
+ * @author xile611
6
+ * @date 2015-09-17
7
+ */
8
+ import Decimal from 'decimal.js-light';
9
+
10
+ /**
11
+ * Get the digit count of a number.
12
+ * If the absolute value is in the interval [0.1, 1), the result is 0.
13
+ * If the absolute value is in the interval [0.01, 0.1), the digit count is -1.
14
+ * If the absolute value is in the interval [0.001, 0.01), the digit count is -2.
15
+ *
16
+ * @param {Number} value The number
17
+ * @return {Integer} Digit count
18
+ */
19
+ function getDigitCount(value) {
20
+ var result;
21
+ if (value === 0) {
22
+ result = 1;
23
+ } else {
24
+ result = Math.floor(new Decimal(value).abs().log(10).toNumber()) + 1;
25
+ }
26
+ return result;
27
+ }
28
+
29
+ /**
30
+ * Get the data in the interval [start, end) with a fixed step.
31
+ * Also handles JS calculation precision issues.
32
+ *
33
+ * @param {Decimal} start Start point
34
+ * @param {Decimal} end End point, not included
35
+ * @param {Decimal} step Step size
36
+ * @return {Array} Array of numbers
37
+ */
38
+ function rangeStep(start, end, step) {
39
+ var num = new Decimal(start);
40
+ var i = 0;
41
+ var result = [];
42
+
43
+ // magic number to prevent infinite loop
44
+ while (num.lt(end) && i < 100000) {
45
+ result.push(num.toNumber());
46
+ num = num.add(step);
47
+ i++;
48
+ }
49
+ return result;
50
+ }
51
+ export { rangeStep, getDigitCount };
@@ -0,0 +1,10 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/util/stacks/getStackSeriesIdentifier.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ /**
4
+ * Returns identifier for stack series which is one individual graphical item in the stack.
5
+ * @param graphicalItem - The graphical item representing the series in the stack.
6
+ * @return The identifier for the series in the stack
7
+ */
8
+ export function getStackSeriesIdentifier(graphicalItem) {
9
+ return graphicalItem === null || graphicalItem === void 0 ? void 0 : graphicalItem.id;
10
+ }
@@ -0,0 +1,29 @@
1
+ // Port of recharts' util/svgPropertiesAndEvents.ts — filters a props object to
2
+ // valid SVG attributes + data-* attributes + event handlers. The key
3
+ // classifiers are vendored verbatim; only the descriptor check is octane's.
4
+ import { isValidElement } from 'octane';
5
+ import { isEventKey } from '../util/excludeEventProps';
6
+ import { isDataAttribute, isSvgElementPropKey } from '../util/svgPropertiesNoEvents';
7
+
8
+ export function svgPropertiesAndEvents(obj: Record<string, any>): Record<string, any> {
9
+ const result: Record<string, any> = {};
10
+ for (const key in obj) {
11
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
12
+ if (isSvgElementPropKey(key) || isDataAttribute(key) || isEventKey(key)) {
13
+ result[key] = obj[key];
14
+ }
15
+ }
16
+ }
17
+ return result;
18
+ }
19
+
20
+ export function svgPropertiesAndEventsFromUnknown(input: unknown): Record<string, any> | null {
21
+ if (input == null) return null;
22
+ if (isValidElement(input)) {
23
+ return svgPropertiesAndEvents((input as any).props);
24
+ }
25
+ if (typeof input === 'object' && !Array.isArray(input)) {
26
+ return svgPropertiesAndEvents(input as Record<string, any>);
27
+ }
28
+ return null;
29
+ }