@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,263 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/state/selectors/barSelectors.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ import { createSelector } from 'reselect';
4
+ import {
5
+ selectAxisWithScale,
6
+ selectCartesianAxisSize,
7
+ selectStackGroups,
8
+ selectTicksOfGraphicalItem,
9
+ selectUnfilteredCartesianItems,
10
+ } from './axisSelectors';
11
+ import { isNullish } from '../../util/DataUtils';
12
+ import { getBandSizeOfAxis } from '../../util/ChartUtils';
13
+ import { computeBarRectangles } from '../../cartesian/Bar';
14
+ import { selectChartLayout } from '../../context/chartLayoutContext';
15
+ import { selectChartDataWithIndexesIfNotInPanoramaPosition3 } from './dataSelectors';
16
+ import { selectAxisViewBox, selectChartOffsetInternal } from './selectChartOffsetInternal';
17
+ import {
18
+ selectBarCategoryGap,
19
+ selectBarGap,
20
+ selectRootBarSize,
21
+ selectRootMaxBarSize,
22
+ } from './rootPropsSelectors';
23
+ import { combineBarSizeList } from './combiners/combineBarSizeList';
24
+ import { combineAllBarPositions } from './combiners/combineAllBarPositions';
25
+ import { combineStackedData } from './combiners/combineStackedData';
26
+ import {
27
+ selectXAxisIdFromGraphicalItemId,
28
+ selectYAxisIdFromGraphicalItemId,
29
+ } from './graphicalItemSelectors';
30
+ import { combineBarPosition } from './combiners/combineBarPosition';
31
+ var pickIsPanorama = (_state, _id, isPanorama) => isPanorama;
32
+ var pickBarId = (_state, id) => id;
33
+ var selectSynchronisedBarSettings = createSelector(
34
+ [selectUnfilteredCartesianItems, pickBarId],
35
+ (graphicalItems, id) =>
36
+ graphicalItems.filter((item) => item.type === 'bar').find((item) => item.id === id),
37
+ );
38
+ export var selectMaxBarSize = createSelector([selectSynchronisedBarSettings], (barSettings) =>
39
+ barSettings === null || barSettings === void 0 ? void 0 : barSettings.maxBarSize,
40
+ );
41
+ var pickCells = (_state, _id, _isPanorama, cells) => cells;
42
+ export var selectAllVisibleBars = createSelector(
43
+ [
44
+ selectChartLayout,
45
+ selectUnfilteredCartesianItems,
46
+ selectXAxisIdFromGraphicalItemId,
47
+ selectYAxisIdFromGraphicalItemId,
48
+ pickIsPanorama,
49
+ ],
50
+ (layout, allItems, xAxisId, yAxisId, isPanorama) =>
51
+ allItems
52
+ .filter((i) => {
53
+ if (layout === 'horizontal') {
54
+ return i.xAxisId === xAxisId;
55
+ }
56
+ return i.yAxisId === yAxisId;
57
+ })
58
+ .filter((i) => i.isPanorama === isPanorama)
59
+ .filter((i) => i.hide === false)
60
+ .filter((i) => i.type === 'bar'),
61
+ );
62
+ var selectBarStackGroups = (state, id, isPanorama) => {
63
+ var layout = selectChartLayout(state);
64
+ var xAxisId = selectXAxisIdFromGraphicalItemId(state, id);
65
+ var yAxisId = selectYAxisIdFromGraphicalItemId(state, id);
66
+ if (xAxisId == null || yAxisId == null) {
67
+ return undefined;
68
+ }
69
+ if (layout === 'horizontal') {
70
+ return selectStackGroups(state, 'yAxis', yAxisId, isPanorama);
71
+ }
72
+ return selectStackGroups(state, 'xAxis', xAxisId, isPanorama);
73
+ };
74
+ export var selectBarCartesianAxisSize = (state, id) => {
75
+ var layout = selectChartLayout(state);
76
+ var xAxisId = selectXAxisIdFromGraphicalItemId(state, id);
77
+ var yAxisId = selectYAxisIdFromGraphicalItemId(state, id);
78
+ if (xAxisId == null || yAxisId == null) {
79
+ return undefined;
80
+ }
81
+ if (layout === 'horizontal') {
82
+ return selectCartesianAxisSize(state, 'xAxis', xAxisId);
83
+ }
84
+ return selectCartesianAxisSize(state, 'yAxis', yAxisId);
85
+ };
86
+ export var selectBarSizeList = createSelector(
87
+ [selectAllVisibleBars, selectRootBarSize, selectBarCartesianAxisSize],
88
+ combineBarSizeList,
89
+ );
90
+ export var selectBarBandSize = (state, id, isPanorama) => {
91
+ var _ref, _getBandSizeOfAxis;
92
+ var barSettings = selectSynchronisedBarSettings(state, id);
93
+ if (barSettings == null) {
94
+ return 0;
95
+ }
96
+ var xAxisId = selectXAxisIdFromGraphicalItemId(state, id);
97
+ var yAxisId = selectYAxisIdFromGraphicalItemId(state, id);
98
+ if (xAxisId == null || yAxisId == null) {
99
+ return 0;
100
+ }
101
+ var layout = selectChartLayout(state);
102
+ var globalMaxBarSize = selectRootMaxBarSize(state);
103
+ var childMaxBarSize = barSettings.maxBarSize;
104
+ var maxBarSize = isNullish(childMaxBarSize) ? globalMaxBarSize : childMaxBarSize;
105
+ var axis, ticks;
106
+ if (layout === 'horizontal') {
107
+ axis = selectAxisWithScale(state, 'xAxis', xAxisId, isPanorama);
108
+ ticks = selectTicksOfGraphicalItem(state, 'xAxis', xAxisId, isPanorama);
109
+ } else {
110
+ axis = selectAxisWithScale(state, 'yAxis', yAxisId, isPanorama);
111
+ ticks = selectTicksOfGraphicalItem(state, 'yAxis', yAxisId, isPanorama);
112
+ }
113
+ return (_ref =
114
+ (_getBandSizeOfAxis = getBandSizeOfAxis(axis, ticks, true)) !== null &&
115
+ _getBandSizeOfAxis !== void 0
116
+ ? _getBandSizeOfAxis
117
+ : maxBarSize) !== null && _ref !== void 0
118
+ ? _ref
119
+ : 0;
120
+ };
121
+ export var selectAxisBandSize = (state, id, isPanorama) => {
122
+ var layout = selectChartLayout(state);
123
+ var xAxisId = selectXAxisIdFromGraphicalItemId(state, id);
124
+ var yAxisId = selectYAxisIdFromGraphicalItemId(state, id);
125
+ if (xAxisId == null || yAxisId == null) {
126
+ return undefined;
127
+ }
128
+ var axis, ticks;
129
+ if (layout === 'horizontal') {
130
+ axis = selectAxisWithScale(state, 'xAxis', xAxisId, isPanorama);
131
+ ticks = selectTicksOfGraphicalItem(state, 'xAxis', xAxisId, isPanorama);
132
+ } else {
133
+ axis = selectAxisWithScale(state, 'yAxis', yAxisId, isPanorama);
134
+ ticks = selectTicksOfGraphicalItem(state, 'yAxis', yAxisId, isPanorama);
135
+ }
136
+ return getBandSizeOfAxis(axis, ticks);
137
+ };
138
+ export var selectAllBarPositions = createSelector(
139
+ [
140
+ selectBarSizeList,
141
+ selectRootMaxBarSize,
142
+ selectBarGap,
143
+ selectBarCategoryGap,
144
+ selectBarBandSize,
145
+ selectAxisBandSize,
146
+ selectMaxBarSize,
147
+ ],
148
+ combineAllBarPositions,
149
+ );
150
+ var selectXAxisWithScale = (state, id, isPanorama) => {
151
+ var xAxisId = selectXAxisIdFromGraphicalItemId(state, id);
152
+ if (xAxisId == null) {
153
+ return undefined;
154
+ }
155
+ return selectAxisWithScale(state, 'xAxis', xAxisId, isPanorama);
156
+ };
157
+ var selectYAxisWithScale = (state, id, isPanorama) => {
158
+ var yAxisId = selectYAxisIdFromGraphicalItemId(state, id);
159
+ if (yAxisId == null) {
160
+ return undefined;
161
+ }
162
+ return selectAxisWithScale(state, 'yAxis', yAxisId, isPanorama);
163
+ };
164
+ var selectXAxisTicks = (state, id, isPanorama) => {
165
+ var xAxisId = selectXAxisIdFromGraphicalItemId(state, id);
166
+ if (xAxisId == null) {
167
+ return undefined;
168
+ }
169
+ return selectTicksOfGraphicalItem(state, 'xAxis', xAxisId, isPanorama);
170
+ };
171
+ var selectYAxisTicks = (state, id, isPanorama) => {
172
+ var yAxisId = selectYAxisIdFromGraphicalItemId(state, id);
173
+ if (yAxisId == null) {
174
+ return undefined;
175
+ }
176
+ return selectTicksOfGraphicalItem(state, 'yAxis', yAxisId, isPanorama);
177
+ };
178
+ export var selectBarPosition = createSelector(
179
+ [selectAllBarPositions, selectSynchronisedBarSettings],
180
+ combineBarPosition,
181
+ );
182
+ export var selectStackedDataOfItem = createSelector(
183
+ [selectBarStackGroups, selectSynchronisedBarSettings],
184
+ combineStackedData,
185
+ );
186
+ export var selectBarRectangles = createSelector(
187
+ [
188
+ selectChartOffsetInternal,
189
+ selectAxisViewBox,
190
+ selectXAxisWithScale,
191
+ selectYAxisWithScale,
192
+ selectXAxisTicks,
193
+ selectYAxisTicks,
194
+ selectBarPosition,
195
+ selectChartLayout,
196
+ selectChartDataWithIndexesIfNotInPanoramaPosition3,
197
+ selectAxisBandSize,
198
+ selectStackedDataOfItem,
199
+ selectSynchronisedBarSettings,
200
+ pickCells,
201
+ ],
202
+ (
203
+ offset,
204
+ axisViewBox,
205
+ xAxis,
206
+ yAxis,
207
+ xAxisTicks,
208
+ yAxisTicks,
209
+ pos,
210
+ layout,
211
+ _ref2,
212
+ bandSize,
213
+ stackedData,
214
+ barSettings,
215
+ cells,
216
+ ) => {
217
+ var chartData = _ref2.chartData,
218
+ dataStartIndex = _ref2.dataStartIndex,
219
+ dataEndIndex = _ref2.dataEndIndex;
220
+ if (
221
+ barSettings == null ||
222
+ pos == null ||
223
+ axisViewBox == null ||
224
+ (layout !== 'horizontal' && layout !== 'vertical') ||
225
+ xAxis == null ||
226
+ yAxis == null ||
227
+ xAxisTicks == null ||
228
+ yAxisTicks == null ||
229
+ bandSize == null
230
+ ) {
231
+ return undefined;
232
+ }
233
+ var data = barSettings.data;
234
+ var displayedData;
235
+ if (data != null && data.length > 0) {
236
+ displayedData = data;
237
+ } else {
238
+ displayedData =
239
+ chartData === null || chartData === void 0
240
+ ? void 0
241
+ : chartData.slice(dataStartIndex, dataEndIndex + 1);
242
+ }
243
+ if (displayedData == null) {
244
+ return undefined;
245
+ }
246
+ return computeBarRectangles({
247
+ layout,
248
+ barSettings,
249
+ pos,
250
+ parentViewBox: axisViewBox,
251
+ bandSize,
252
+ xAxis,
253
+ yAxis,
254
+ xAxisTicks,
255
+ yAxisTicks,
256
+ stackedData,
257
+ displayedData,
258
+ offset,
259
+ cells,
260
+ dataStartIndex,
261
+ });
262
+ },
263
+ );
@@ -0,0 +1,65 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/state/selectors/barStackSelectors.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ import { createSelector } from 'reselect';
4
+ import { selectUnfilteredCartesianItems } from './axisSelectors';
5
+ import { selectBarRectangles } from './barSelectors';
6
+ var pickStackId = (state, stackId) => stackId;
7
+ var pickIsPanorama = (state, stackId, isPanorama) => isPanorama;
8
+ export var selectAllBarsInStack = createSelector(
9
+ [pickStackId, selectUnfilteredCartesianItems, pickIsPanorama],
10
+ (stackId, allItems, isPanorama) => {
11
+ return allItems
12
+ .filter((i) => i.type === 'bar')
13
+ .filter((i) => i.stackId === stackId)
14
+ .filter((i) => i.isPanorama === isPanorama)
15
+ .filter((i) => !i.hide);
16
+ },
17
+ );
18
+ var selectAllBarIdsInStack = createSelector([selectAllBarsInStack], (allBars) => {
19
+ return allBars.map((bar) => bar.id);
20
+ });
21
+ /**
22
+ * Takes two rectangles and returns a new rectangle that encompasses both.
23
+ * It takes the minimum x and y, and the maximum width and height.
24
+ * It handles overlapping rectangles, and rectangles with a gap between them.
25
+ * @param rect1
26
+ * @param rect2
27
+ */
28
+ export var expandRectangle = (rect1, rect2) => {
29
+ if (!rect1) {
30
+ return rect2;
31
+ }
32
+ if (!rect2) {
33
+ return rect1;
34
+ }
35
+ var x = Math.min(rect1.x, rect1.x + rect1.width, rect2.x, rect2.x + rect2.width);
36
+ var y = Math.min(rect1.y, rect1.y + rect1.height, rect2.y, rect2.y + rect2.height);
37
+ var maxX = Math.max(rect1.x, rect1.x + rect1.width, rect2.x, rect2.x + rect2.width);
38
+ var maxY = Math.max(rect1.y, rect1.y + rect1.height, rect2.y, rect2.y + rect2.height);
39
+ var width = maxX - x;
40
+ var height = maxY - y;
41
+ return {
42
+ x,
43
+ y,
44
+ width,
45
+ height,
46
+ };
47
+ };
48
+ var combineStackRects = (state, stackId, isPanorama) => {
49
+ var allBarIds = selectAllBarIdsInStack(state, stackId, isPanorama);
50
+ var stackRects = [];
51
+ allBarIds.forEach((barId) => {
52
+ var rectangles = selectBarRectangles(state, barId, isPanorama, undefined);
53
+ rectangles === null ||
54
+ rectangles === void 0 ||
55
+ rectangles.forEach((rect) => {
56
+ var rectIndex = rect.originalDataIndex;
57
+ stackRects[rectIndex] = expandRectangle(stackRects[rectIndex], rect);
58
+ });
59
+ });
60
+ return stackRects;
61
+ };
62
+ export var selectStackRects = createSelector(
63
+ [(state) => state, pickStackId, pickIsPanorama],
64
+ combineStackRects,
65
+ );
@@ -0,0 +1,21 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/state/selectors/brushSelectors.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ import { createSelector } from 'reselect';
4
+ import { selectChartOffsetInternal } from './selectChartOffsetInternal';
5
+ import { selectMargin } from './containerSelectors';
6
+ import { isNumber } from '../../util/DataUtils';
7
+ export var selectBrushSettings = (state) => state.brush;
8
+ export var selectBrushDimensions = createSelector(
9
+ [selectBrushSettings, selectChartOffsetInternal, selectMargin],
10
+ (brushSettings, offset, margin) => ({
11
+ height: brushSettings.height,
12
+ x: isNumber(brushSettings.x) ? brushSettings.x : offset.left,
13
+ y: isNumber(brushSettings.y)
14
+ ? brushSettings.y
15
+ : offset.top +
16
+ offset.height +
17
+ offset.brushBottom -
18
+ ((margin === null || margin === void 0 ? void 0 : margin.bottom) || 0),
19
+ width: isNumber(brushSettings.width) ? brushSettings.width : offset.width,
20
+ }),
21
+ );
@@ -0,0 +1,18 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineActiveLabel.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ import { isNan } from '../../../util/DataUtils';
4
+ export var combineActiveLabel = (tooltipTicks, activeIndex) => {
5
+ var _tooltipTicks$n;
6
+ var n = Number(activeIndex);
7
+ if (isNan(n) || activeIndex == null) {
8
+ return undefined;
9
+ }
10
+ return n >= 0
11
+ ? tooltipTicks === null ||
12
+ tooltipTicks === void 0 ||
13
+ (_tooltipTicks$n = tooltipTicks[n]) === null ||
14
+ _tooltipTicks$n === void 0
15
+ ? void 0
16
+ : _tooltipTicks$n.value
17
+ : undefined;
18
+ };
@@ -0,0 +1,75 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineActiveTooltipIndex.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ import { isWellBehavedNumber } from '../../../util/isWellBehavedNumber';
4
+ import { getValueByDataKey } from '../../../util/ChartUtils';
5
+ import { isWellFormedNumberDomain } from '../../../util/isDomainSpecifiedByUser';
6
+ function toFiniteNumber(value) {
7
+ if (typeof value === 'number') {
8
+ return Number.isFinite(value) ? value : undefined;
9
+ }
10
+ if (value instanceof Date) {
11
+ var numericValue = value.valueOf();
12
+ return Number.isFinite(numericValue) ? numericValue : undefined;
13
+ }
14
+ var parsed = Number(value);
15
+ return Number.isFinite(parsed) ? parsed : undefined;
16
+ }
17
+ function isValueWithinNumberDomain(value, domain) {
18
+ var numericValue = toFiniteNumber(value);
19
+ var lowerBound = domain[0];
20
+ var upperBound = domain[1];
21
+ if (numericValue === undefined) {
22
+ return false;
23
+ }
24
+ var min = Math.min(lowerBound, upperBound);
25
+ var max = Math.max(lowerBound, upperBound);
26
+ return numericValue >= min && numericValue <= max;
27
+ }
28
+ function isValueWithinDomain(entry, axisDataKey, domain) {
29
+ if (domain == null || axisDataKey == null) {
30
+ return true;
31
+ }
32
+ var value = getValueByDataKey(entry, axisDataKey);
33
+ if (value == null) {
34
+ return true;
35
+ }
36
+ if (!isWellFormedNumberDomain(domain)) {
37
+ return true;
38
+ }
39
+ return isValueWithinNumberDomain(value, domain);
40
+ }
41
+ export var combineActiveTooltipIndex = (tooltipInteraction, chartData, axisDataKey, domain) => {
42
+ var desiredIndex =
43
+ tooltipInteraction === null || tooltipInteraction === void 0
44
+ ? void 0
45
+ : tooltipInteraction.index;
46
+ if (desiredIndex == null) {
47
+ return null;
48
+ }
49
+ var indexAsNumber = Number(desiredIndex);
50
+ if (!isWellBehavedNumber(indexAsNumber)) {
51
+ // this is for charts like Sankey and Treemap that do not support numerical indexes. We need a proper solution for this before we can start supporting keyboard events on these charts.
52
+ return desiredIndex;
53
+ }
54
+
55
+ /*
56
+ * Zero is a trivial limit for single-dimensional charts like Line and Area,
57
+ * but this also needs a support for multidimensional charts like Sankey and Treemap! TODO
58
+ */
59
+ var lowerLimit = 0;
60
+ var upperLimit = +Infinity;
61
+ if (chartData.length > 0) {
62
+ upperLimit = chartData.length - 1;
63
+ }
64
+
65
+ // now let's clamp the desiredIndex between the limits
66
+ var clampedIndex = Math.max(lowerLimit, Math.min(indexAsNumber, upperLimit));
67
+ var entry = chartData[clampedIndex];
68
+ if (entry == null) {
69
+ return String(clampedIndex);
70
+ }
71
+ if (!isValueWithinDomain(entry, axisDataKey, domain)) {
72
+ return null;
73
+ }
74
+ return String(clampedIndex);
75
+ };
@@ -0,0 +1,169 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineAllBarPositions.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 { getPercentValue, isNullish } from '../../../util/DataUtils';
53
+ import { isWellBehavedNumber } from '../../../util/isWellBehavedNumber';
54
+ function getBarPositions(barGap, barCategoryGap, bandSize, sizeList, maxBarSize) {
55
+ var _sizeList$;
56
+ var len = sizeList.length;
57
+ if (len < 1) {
58
+ return undefined;
59
+ }
60
+ var realBarGap = getPercentValue(barGap, bandSize, 0, true);
61
+ var result;
62
+ var initialValue = [];
63
+
64
+ // whether is barSize set by user
65
+ // Okay but why does it check only for the first element? What if the first element is set but others are not?
66
+ if (
67
+ isWellBehavedNumber(
68
+ (_sizeList$ = sizeList[0]) === null || _sizeList$ === void 0 ? void 0 : _sizeList$.barSize,
69
+ )
70
+ ) {
71
+ var useFull = false;
72
+ var fullBarSize = bandSize / len;
73
+ var sum = sizeList.reduce((res, entry) => res + (entry.barSize || 0), 0);
74
+ sum += (len - 1) * realBarGap;
75
+ if (sum >= bandSize) {
76
+ sum -= (len - 1) * realBarGap;
77
+ realBarGap = 0;
78
+ }
79
+ if (sum >= bandSize && fullBarSize > 0) {
80
+ useFull = true;
81
+ fullBarSize *= 0.9;
82
+ sum = len * fullBarSize;
83
+ }
84
+ var offset = Math.round((bandSize - sum) / 2);
85
+ var prev = {
86
+ offset: offset - realBarGap,
87
+ size: 0,
88
+ };
89
+ result = sizeList.reduce((res, entry) => {
90
+ var _entry$barSize;
91
+ var newPosition = {
92
+ stackId: entry.stackId,
93
+ dataKeys: entry.dataKeys,
94
+ position: {
95
+ offset: prev.offset + prev.size + realBarGap,
96
+ size: useFull
97
+ ? fullBarSize
98
+ : (_entry$barSize = entry.barSize) !== null && _entry$barSize !== void 0
99
+ ? _entry$barSize
100
+ : 0,
101
+ },
102
+ };
103
+ var newRes = [...res, newPosition];
104
+ prev = newPosition.position;
105
+ return newRes;
106
+ }, initialValue);
107
+ } else {
108
+ var _offset = getPercentValue(barCategoryGap, bandSize, 0, true);
109
+ if (bandSize - 2 * _offset - (len - 1) * realBarGap <= 0) {
110
+ realBarGap = 0;
111
+ }
112
+ var originalSize = (bandSize - 2 * _offset - (len - 1) * realBarGap) / len;
113
+ if (originalSize > 1) {
114
+ originalSize = Math.round(originalSize);
115
+ }
116
+ var size = isWellBehavedNumber(maxBarSize) ? Math.min(originalSize, maxBarSize) : originalSize;
117
+ result = sizeList.reduce(
118
+ (res, entry, i) => [
119
+ ...res,
120
+ {
121
+ stackId: entry.stackId,
122
+ dataKeys: entry.dataKeys,
123
+ position: {
124
+ offset: _offset + (originalSize + realBarGap) * i + (originalSize - size) / 2,
125
+ size,
126
+ },
127
+ },
128
+ ],
129
+ initialValue,
130
+ );
131
+ }
132
+ return result;
133
+ }
134
+ export var combineAllBarPositions = (
135
+ sizeList,
136
+ globalMaxBarSize,
137
+ barGap,
138
+ barCategoryGap,
139
+ barBandSize,
140
+ bandSize,
141
+ childMaxBarSize,
142
+ ) => {
143
+ var maxBarSize = isNullish(childMaxBarSize) ? globalMaxBarSize : childMaxBarSize;
144
+ var allBarPositions = getBarPositions(
145
+ barGap,
146
+ barCategoryGap,
147
+ barBandSize !== bandSize ? barBandSize : bandSize,
148
+ sizeList,
149
+ maxBarSize,
150
+ );
151
+ if (barBandSize !== bandSize && allBarPositions != null) {
152
+ allBarPositions = allBarPositions.map((pos) =>
153
+ _objectSpread(
154
+ _objectSpread({}, pos),
155
+ {},
156
+ {
157
+ position: _objectSpread(
158
+ _objectSpread({}, pos.position),
159
+ {},
160
+ {
161
+ offset: pos.position.offset - barBandSize / 2,
162
+ },
163
+ ),
164
+ },
165
+ ),
166
+ );
167
+ }
168
+ return allBarPositions;
169
+ };
@@ -0,0 +1,11 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineAxisRangeWithReverse.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ export var combineAxisRangeWithReverse = (axisSettings, axisRange) => {
4
+ if (!axisSettings || !axisRange) {
5
+ return undefined;
6
+ }
7
+ if (axisSettings !== null && axisSettings !== void 0 && axisSettings.reversed) {
8
+ return [axisRange[1], axisRange[0]];
9
+ }
10
+ return axisRange;
11
+ };
@@ -0,0 +1,17 @@
1
+ // Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineBarPosition.js (framework-agnostic).
2
+ // Do not edit — update by re-vendoring when the recharts devDependency moves.
3
+ export var combineBarPosition = (allBarPositions, barSettings) => {
4
+ if (allBarPositions == null || barSettings == null) {
5
+ return undefined;
6
+ }
7
+ var position = allBarPositions.find(
8
+ (p) =>
9
+ p.stackId === barSettings.stackId &&
10
+ barSettings.dataKey != null &&
11
+ p.dataKeys.includes(barSettings.dataKey),
12
+ );
13
+ if (position == null) {
14
+ return undefined;
15
+ }
16
+ return position.position;
17
+ };