vccs 0.1.0 → 0.3.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 (273) hide show
  1. package/README.md +151 -0
  2. package/dist/animation/Animate.d.ts +1 -1
  3. package/dist/cartesian/area/type.d.ts +3 -3
  4. package/dist/cartesian/bar/type.d.ts +1 -13
  5. package/dist/cartesian/brush/components/Slide.d.ts +1 -1
  6. package/dist/cartesian/brush/components/TravellerLayer.d.ts +1 -1
  7. package/dist/cartesian/brush/type.d.ts +2 -1
  8. package/dist/cartesian/cartesian-axis/CartesianAxis.d.ts +2 -1
  9. package/dist/cartesian/funnel/Funnel.d.ts +2 -0
  10. package/dist/cartesian/funnel/index.d.ts +2 -0
  11. package/dist/cartesian/funnel/type.d.ts +74 -6
  12. package/dist/cartesian/index.d.ts +2 -0
  13. package/dist/cartesian/line/Line.d.ts +7 -13
  14. package/dist/cartesian/line/type.d.ts +4 -17
  15. package/dist/cartesian/reference-area/ReferenceArea.d.ts +16 -16
  16. package/dist/cartesian/reference-dot/ReferenceDot.d.ts +143 -0
  17. package/dist/cartesian/reference-dot/index.d.ts +2 -0
  18. package/dist/cartesian/reference-line/ReferenceLine.d.ts +8 -8
  19. package/dist/cartesian/scatter/Scatter.d.ts +1 -1
  20. package/dist/chart/FunnelChart.d.ts +1 -0
  21. package/dist/chart/RechartsWrapper.d.ts +7 -3
  22. package/dist/chart/Surface.d.ts +2 -1
  23. package/dist/chart/Treemap.d.ts +237 -0
  24. package/dist/chart/generateCategoricalChart.d.ts +2 -1
  25. package/dist/chart/index.d.ts +2 -0
  26. package/dist/chart/treemapUtils.d.ts +22 -0
  27. package/dist/components/Customized.d.ts +23 -0
  28. package/dist/components/Text.d.ts +4 -4
  29. package/dist/components/Tooltip.d.ts +1 -1
  30. package/dist/components/index.d.ts +2 -0
  31. package/dist/components/label/Label.d.ts +3 -3
  32. package/dist/components/label/types.d.ts +1 -1
  33. package/dist/container/Surface.d.ts +3 -2
  34. package/dist/es/animation/Animate.mjs +48 -22
  35. package/dist/es/cartesian/GraphicalItemClipPath.mjs +16 -15
  36. package/dist/es/cartesian/area/ActivePoints.mjs +44 -40
  37. package/dist/es/cartesian/area/Area.mjs +42 -31
  38. package/dist/es/cartesian/area/ClipRect.mjs +79 -58
  39. package/dist/es/cartesian/area/RenderArea.mjs +142 -108
  40. package/dist/es/cartesian/area/hooks/useArea.mjs +71 -47
  41. package/dist/es/cartesian/area/type.mjs +13 -15
  42. package/dist/es/cartesian/area/utils.mjs +69 -49
  43. package/dist/es/cartesian/axis/XAxis.mjs +87 -73
  44. package/dist/es/cartesian/axis/YAxis.mjs +67 -56
  45. package/dist/es/cartesian/bar/Bar.mjs +78 -71
  46. package/dist/es/cartesian/bar/components/BarBackground.mjs +22 -19
  47. package/dist/es/cartesian/bar/components/BarRectangles.mjs +117 -80
  48. package/dist/es/cartesian/bar/hooks/useBar.mjs +49 -37
  49. package/dist/es/cartesian/bar/type.mjs +11 -25
  50. package/dist/es/cartesian/bar/utils.mjs +97 -70
  51. package/dist/es/cartesian/cartesian-axis/CartesianAxis.mjs +165 -115
  52. package/dist/es/cartesian/cartesian-grid/Background.mjs +19 -16
  53. package/dist/es/cartesian/cartesian-grid/CartesianGrid.mjs +116 -97
  54. package/dist/es/cartesian/cartesian-grid/HorizontalGridLines.mjs +24 -23
  55. package/dist/es/cartesian/cartesian-grid/HorizontalStripes.mjs +24 -24
  56. package/dist/es/cartesian/cartesian-grid/VerticalGridLines.mjs +23 -22
  57. package/dist/es/cartesian/cartesian-grid/VerticalStripes.mjs +24 -24
  58. package/dist/es/cartesian/cartesian-grid/const.mjs +317 -10
  59. package/dist/es/cartesian/cartesian-grid/utils.mjs +18 -13
  60. package/dist/es/cartesian/error-bar/ErrorBar.mjs +111 -83
  61. package/dist/es/cartesian/error-bar/ErrorBarContext.mjs +13 -12
  62. package/dist/es/cartesian/funnel/Funnel.mjs +162 -0
  63. package/dist/es/cartesian/funnel/type.mjs +78 -0
  64. package/dist/es/cartesian/funnel/utils.mjs +102 -0
  65. package/dist/es/cartesian/line/ActivePoints.mjs +45 -41
  66. package/dist/es/cartesian/line/Line.mjs +41 -37
  67. package/dist/es/cartesian/line/StaticLine.mjs +191 -122
  68. package/dist/es/cartesian/line/hooks/useLine.mjs +60 -44
  69. package/dist/es/cartesian/line/type.mjs +13 -18
  70. package/dist/es/cartesian/line/utils.mjs +27 -26
  71. package/dist/es/cartesian/reference-area/ReferenceArea.mjs +79 -78
  72. package/dist/es/cartesian/reference-dot/ReferenceDot.mjs +134 -0
  73. package/dist/es/cartesian/reference-line/ReferenceLine.mjs +93 -84
  74. package/dist/es/cartesian/scatter/Scatter.mjs +168 -140
  75. package/dist/es/cartesian/scatter/hooks/useScatter.mjs +18 -14
  76. package/dist/es/cartesian/useNeedsClip.mjs +18 -9
  77. package/dist/es/cartesian/utils/get-ticks.mjs +103 -68
  78. package/dist/es/cartesian/z-axis/ZAxis.mjs +30 -28
  79. package/dist/es/chart/AreaChart.mjs +5 -5
  80. package/dist/es/chart/BarChart.mjs +5 -5
  81. package/dist/es/chart/ComposedChart.mjs +5 -5
  82. package/dist/es/chart/FunnelChart.mjs +11 -0
  83. package/dist/es/chart/LegendPortalContext.mjs +3 -3
  84. package/dist/es/chart/LineChart.mjs +5 -5
  85. package/dist/es/chart/PieChart.mjs +5 -5
  86. package/dist/es/chart/RadarChart.mjs +5 -5
  87. package/dist/es/chart/RadialBarChart.mjs +5 -5
  88. package/dist/es/chart/RechartsWrapper.mjs +113 -89
  89. package/dist/es/chart/ScatterChart.mjs +5 -5
  90. package/dist/es/chart/Surface.mjs +3 -3
  91. package/dist/es/chart/Surface.vue_vue_type_script_setup_true_lang.mjs +51 -45
  92. package/dist/es/chart/TooltipPortalContext.mjs +3 -3
  93. package/dist/es/chart/Treemap.mjs +379 -0
  94. package/dist/es/chart/const.mjs +2 -2
  95. package/dist/es/chart/generateCategoricalChart.mjs +99 -89
  96. package/dist/es/chart/provideClipPathId.mjs +12 -7
  97. package/dist/es/chart/treemapUtils.mjs +32 -0
  98. package/dist/es/components/Cell.mjs +16 -4
  99. package/dist/es/components/Customized.mjs +43 -0
  100. package/dist/es/components/Text.mjs +3 -3
  101. package/dist/es/components/Text.vue_vue_type_script_setup_true_lang.mjs +106 -69
  102. package/dist/es/components/Tooltip.mjs +274 -199
  103. package/dist/es/components/label/Label.mjs +30 -26
  104. package/dist/es/components/label/LabelList.mjs +45 -39
  105. package/dist/es/components/label/types.mjs +10 -6
  106. package/dist/es/components/label/utils.mjs +194 -162
  107. package/dist/es/components/legend/Legend.mjs +82 -71
  108. package/dist/es/components/legend/LegendSymbol.mjs +40 -38
  109. package/dist/es/components/legend/hooks/useLegend.mjs +71 -46
  110. package/dist/es/components/legend/hooks/useLegendContent.mjs +52 -31
  111. package/dist/es/components/legend/type.mjs +2 -2
  112. package/dist/es/components/legend/utils.mjs +19 -11
  113. package/dist/es/components/utils.mjs +35 -22
  114. package/dist/es/container/ClipPath.mjs +14 -14
  115. package/dist/es/container/Layer.mjs +9 -7
  116. package/dist/es/container/ResponsiveContainer.mjs +3 -3
  117. package/dist/es/container/ResponsiveContainer.vue_vue_type_script_setup_true_lang.mjs +109 -77
  118. package/dist/es/container/Surface.mjs +25 -23
  119. package/dist/es/container/useSizeContext.mjs +3 -3
  120. package/dist/es/context/ChartDataContextProvider.mjs +19 -13
  121. package/dist/es/context/PanoramaContextProvider.mjs +15 -10
  122. package/dist/es/context/accessibilityContext.mjs +3 -3
  123. package/dist/es/context/cartesianLabelListContext.mjs +3 -3
  124. package/dist/es/context/chartLayoutContext.mjs +33 -30
  125. package/dist/es/context/cursorLayerContext.mjs +3 -3
  126. package/dist/es/context/graphicalLayerContext.mjs +3 -3
  127. package/dist/es/context/labelLayerContext.mjs +3 -3
  128. package/dist/es/context/polarLabelViewBoxContext.mjs +5 -5
  129. package/dist/es/context/useTooltipAxis.mjs +14 -12
  130. package/dist/es/events/useChartSynchronisation.mjs +91 -66
  131. package/dist/es/hooks/publicHooks.mjs +207 -0
  132. package/dist/es/hooks/useIsAnimating.mjs +28 -0
  133. package/dist/es/hooks/useSetupGraphicalItem.mjs +52 -43
  134. package/dist/es/index.mjs +54 -42
  135. package/dist/es/polar/pie/Pie.mjs +131 -115
  136. package/dist/es/polar/pie/type.mjs +8 -10
  137. package/dist/es/polar/radar/PolarAngleAxis.mjs +103 -84
  138. package/dist/es/polar/radar/PolarGrid.mjs +72 -59
  139. package/dist/es/polar/radar/PolarRadiusAxis.mjs +90 -65
  140. package/dist/es/polar/radar/Radar.mjs +181 -145
  141. package/dist/es/polar/radial-bar/RadialBar.mjs +161 -140
  142. package/dist/es/polar/radial-bar/type.mjs +9 -9
  143. package/dist/es/shape/Cross.mjs +11 -10
  144. package/dist/es/shape/Curve.mjs +71 -44
  145. package/dist/es/shape/Dot.mjs +12 -11
  146. package/dist/es/shape/Polygon.mjs +19 -0
  147. package/dist/es/shape/Rectangle.mjs +41 -30
  148. package/dist/es/shape/Sector.mjs +105 -79
  149. package/dist/es/shape/Symbols.mjs +45 -34
  150. package/dist/es/shape/Trapezoid.mjs +50 -0
  151. package/dist/es/state/ReportChartProps.mjs +23 -24
  152. package/dist/es/state/ReportMainChartProps.mjs +26 -21
  153. package/dist/es/state/ReportPolarOptions.mjs +23 -22
  154. package/dist/es/state/SetGraphicalItem.mjs +42 -27
  155. package/dist/es/state/SetLegendPayload.mjs +17 -13
  156. package/dist/es/state/SetTooltipEntrySettings.mjs +14 -12
  157. package/dist/es/state/brushSlice.mjs +12 -8
  158. package/dist/es/state/cartesianAxisSlice.mjs +23 -17
  159. package/dist/es/state/chartDataSlice.mjs +18 -13
  160. package/dist/es/state/externalEventsMiddleware.mjs +25 -15
  161. package/dist/es/state/graphicalItemsSlice.mjs +29 -25
  162. package/dist/es/state/hooks.mjs +24 -3
  163. package/dist/es/state/keyboardEventsMiddleware.mjs +50 -42
  164. package/dist/es/state/layoutSlice.mjs +18 -12
  165. package/dist/es/state/legendSlice.mjs +19 -14
  166. package/dist/es/state/mouseEventsMiddleware.mjs +31 -24
  167. package/dist/es/state/optionsSlice.mjs +14 -11
  168. package/dist/es/state/polarAxisSlice.mjs +15 -13
  169. package/dist/es/state/polarOptionsSlice.mjs +8 -6
  170. package/dist/es/state/reduxDevtoolsJsonStringifyReplacer.mjs +5 -3
  171. package/dist/es/state/referenceElementsSlice.mjs +21 -19
  172. package/dist/es/state/rootPropsSlice.mjs +20 -9
  173. package/dist/es/state/selectors/areaSelectors.mjs +65 -55
  174. package/dist/es/state/selectors/axisSelectors.mjs +784 -569
  175. package/dist/es/state/selectors/barSelectors.mjs +225 -162
  176. package/dist/es/state/selectors/brushSelectors.mjs +15 -14
  177. package/dist/es/state/selectors/combiners/combineActiveLabel.mjs +6 -5
  178. package/dist/es/state/selectors/combiners/combineActiveTooltipIndex.mjs +36 -27
  179. package/dist/es/state/selectors/combiners/combineAxisRangeWithReverse.mjs +5 -3
  180. package/dist/es/state/selectors/combiners/combineCoordinateForDefaultIndex.mjs +13 -11
  181. package/dist/es/state/selectors/combiners/combineTooltipInteractionState.mjs +26 -21
  182. package/dist/es/state/selectors/combiners/combineTooltipPayloadConfigurations.mjs +10 -6
  183. package/dist/es/state/selectors/common.mjs +2 -2
  184. package/dist/es/state/selectors/containerSelectors.mjs +5 -2
  185. package/dist/es/state/selectors/dataSelectors.mjs +28 -9
  186. package/dist/es/state/selectors/funnelSelectors.mjs +38 -0
  187. package/dist/es/state/selectors/legendSelectors.mjs +7 -6
  188. package/dist/es/state/selectors/lineSelectors.mjs +54 -47
  189. package/dist/es/state/selectors/pickAxisId.mjs +2 -2
  190. package/dist/es/state/selectors/pickAxisType.mjs +2 -2
  191. package/dist/es/state/selectors/pieSelectors.mjs +116 -81
  192. package/dist/es/state/selectors/polarAxisSelectors.mjs +113 -94
  193. package/dist/es/state/selectors/polarGridSelectors.mjs +13 -11
  194. package/dist/es/state/selectors/polarScaleSelectors.mjs +49 -46
  195. package/dist/es/state/selectors/polarSelectors.mjs +79 -62
  196. package/dist/es/state/selectors/radarSelectors.mjs +111 -91
  197. package/dist/es/state/selectors/radialBarSelectors.mjs +230 -183
  198. package/dist/es/state/selectors/rootPropsSelectors.mjs +11 -5
  199. package/dist/es/state/selectors/scatterSelectors.mjs +111 -95
  200. package/dist/es/state/selectors/selectActivePropsFromChartPointer.mjs +19 -17
  201. package/dist/es/state/selectors/selectAllAxes.mjs +8 -3
  202. package/dist/es/state/selectors/selectChartOffset.mjs +59 -50
  203. package/dist/es/state/selectors/selectChartOffsetInternal.mjs +55 -44
  204. package/dist/es/state/selectors/selectTooltipEventType.mjs +15 -14
  205. package/dist/es/state/selectors/selectTooltipPayloadSearcher.mjs +3 -3
  206. package/dist/es/state/selectors/selectTooltipSettings.mjs +2 -2
  207. package/dist/es/state/selectors/selectTooltipState.mjs +2 -2
  208. package/dist/es/state/selectors/selectors.mjs +94 -75
  209. package/dist/es/state/selectors/tooltipSelectors.mjs +253 -204
  210. package/dist/es/state/selectors/touchSelectors.mjs +17 -14
  211. package/dist/es/state/store.mjs +46 -46
  212. package/dist/es/state/tooltipSlice.mjs +64 -37
  213. package/dist/es/state/touchEventsMiddleware.mjs +35 -29
  214. package/dist/es/state/utils/useReportScale.mjs +16 -13
  215. package/dist/es/synchronisation/syncSelectors.mjs +3 -3
  216. package/dist/es/synchronisation/useChartSynchronisation.mjs +33 -19
  217. package/dist/es/types/common.mjs +12 -0
  218. package/dist/es/types/event.mjs +164 -2
  219. package/dist/es/utils/ReduceCSSCalc.mjs +81 -49
  220. package/dist/es/utils/VueUtils.mjs +35 -14
  221. package/dist/es/utils/attrs.mjs +43 -26
  222. package/dist/es/utils/cartesian.mjs +47 -15
  223. package/dist/es/utils/cell.mjs +28 -0
  224. package/dist/es/utils/chart.mjs +298 -197
  225. package/dist/es/utils/const.mjs +30 -2
  226. package/dist/es/utils/createCategoricalInverse.mjs +46 -0
  227. package/dist/es/utils/createContext.mjs +28 -9
  228. package/dist/es/utils/data-utils.mjs +9 -8
  229. package/dist/es/utils/data.mjs +35 -21
  230. package/dist/es/utils/events.mjs +5 -3
  231. package/dist/es/utils/getLinearRegression.mjs +28 -11
  232. package/dist/es/utils/grid.mjs +20 -5
  233. package/dist/es/utils/isDomainSpecifiedByUser.mjs +105 -54
  234. package/dist/es/utils/legend.mjs +13 -12
  235. package/dist/es/utils/log.mjs +10 -7
  236. package/dist/es/utils/payload/getUniqPayload.mjs +6 -4
  237. package/dist/es/utils/polar.mjs +37 -30
  238. package/dist/es/utils/props.mjs +16 -10
  239. package/dist/es/utils/resolveDefaultProps.mjs +23 -4
  240. package/dist/es/utils/scale/getNiceTickValues.mjs +127 -49
  241. package/dist/es/utils/scale/utils/arithmetic.mjs +49 -19
  242. package/dist/es/utils/scale/utils/utils.mjs +43 -24
  243. package/dist/es/utils/scale.mjs +46 -0
  244. package/dist/es/utils/style.mjs +24 -13
  245. package/dist/es/utils/tick.mjs +34 -23
  246. package/dist/es/utils/tooltip/translate.mjs +63 -49
  247. package/dist/es/utils/validate.mjs +40 -29
  248. package/dist/hooks/publicHooks.d.ts +143 -0
  249. package/dist/hooks/useIsAnimating.d.ts +14 -0
  250. package/dist/index.d.ts +1 -0
  251. package/dist/polar/pie/type.d.ts +2 -2
  252. package/dist/polar/radar/Radar.d.ts +4 -4
  253. package/dist/shape/Curve.d.ts +2 -1
  254. package/dist/shape/Polygon.d.ts +9 -0
  255. package/dist/shape/Rectangle.d.ts +0 -4
  256. package/dist/shape/Sector.d.ts +2 -2
  257. package/dist/shape/Symbols.d.ts +2 -1
  258. package/dist/shape/Trapezoid.d.ts +30 -0
  259. package/dist/shape/index.d.ts +2 -0
  260. package/dist/shape/types.d.ts +4 -5
  261. package/dist/state/ReportChartProps.d.ts +3 -3
  262. package/dist/state/graphicalItemsSlice.d.ts +1 -1
  263. package/dist/state/rootPropsSlice.d.ts +2 -2
  264. package/dist/state/selectors/axisSelectors.d.ts +5 -0
  265. package/dist/types/axis.d.ts +2 -2
  266. package/dist/types/bar.d.ts +2 -6
  267. package/dist/types/categorical.d.ts +2 -2
  268. package/dist/types/common.d.ts +7 -1
  269. package/dist/types/tooltip.d.ts +2 -2
  270. package/dist/utils/cell.d.ts +11 -0
  271. package/dist/utils/createCategoricalInverse.d.ts +16 -0
  272. package/dist/utils/scale.d.ts +23 -0
  273. package/package.json +2 -1
@@ -1,77 +1,91 @@
1
- import { isCategoricalAxis as e, isNan as t, isNumOrStr as n, isNumber as r, isWellBehavedNumber as i } from "../../utils/validate.mjs";
2
- import { selectChartDataWithIndexes as a, selectChartDataWithIndexesIfNotInPanorama as o } from "./dataSelectors.mjs";
3
- import { selectChartHeight as s, selectChartWidth as c } from "./containerSelectors.mjs";
4
- import { selectAllXAxes as l, selectAllYAxes as u } from "./selectAllAxes.mjs";
5
- import { selectChartOffset as d } from "./selectChartOffset.mjs";
6
- import { selectBrushDimensions as f, selectBrushSettings as p } from "./brushSelectors.mjs";
7
- import { selectBarCategoryGap as ee, selectChartName as m, selectStackOffsetType as h } from "./rootPropsSelectors.mjs";
8
- import { combineAxisRangeWithReverse as g } from "./combiners/combineAxisRangeWithReverse.mjs";
9
- import { getPercentValue as te, hasDuplicate as ne, mathSign as re } from "../../utils/data.mjs";
10
- import { selectChartLayout as _ } from "./common.mjs";
11
- import { selectAngleAxis as ie, selectAngleAxisRange as ae, selectRadiusAxis as oe, selectRadiusAxisRange as se } from "./polarAxisSelectors.mjs";
12
- import { pickAxisType as v } from "./pickAxisType.mjs";
13
- import { pickAxisId as y } from "./pickAxisId.mjs";
14
- import { checkDomainOfScale as ce, getDomainOfStackGroups as le, getStackedData as ue, getValueByDataKey as b } from "../../utils/chart.mjs";
15
- import { isWellFormedNumberDomain as de, numericalDomainSpecifiedWithoutRequiringData as fe, parseNumericalUserDomain as pe } from "../../utils/isDomainSpecifiedByUser.mjs";
16
- import { getNiceTickValues as me, getTickValuesFixedDomain as he } from "../../utils/scale/getNiceTickValues.mjs";
17
- import { createSelector as x } from "@reduxjs/toolkit";
18
- import { range as ge, upperFirst as _e } from "lodash-es";
19
- import * as S from "victory-vendor/d3-scale";
1
+ import { isCategoricalAxis, isNan, isNumOrStr, isNumber, isWellBehavedNumber } from "../../utils/validate.mjs";
2
+ import { selectChartDataWithIndexes, selectChartDataWithIndexesIfNotInPanorama } from "./dataSelectors.mjs";
3
+ import { selectChartHeight, selectChartWidth } from "./containerSelectors.mjs";
4
+ import { selectAllXAxes, selectAllYAxes } from "./selectAllAxes.mjs";
5
+ import { selectChartOffset } from "./selectChartOffset.mjs";
6
+ import { selectBrushDimensions, selectBrushSettings } from "./brushSelectors.mjs";
7
+ import { selectBarCategoryGap, selectChartName, selectStackOffsetType } from "./rootPropsSelectors.mjs";
8
+ import { combineAxisRangeWithReverse } from "./combiners/combineAxisRangeWithReverse.mjs";
9
+ import { getPercentValue, hasDuplicate, mathSign } from "../../utils/data.mjs";
10
+ import { selectChartLayout } from "./common.mjs";
11
+ import { selectAngleAxis, selectAngleAxisRange, selectRadiusAxis, selectRadiusAxisRange } from "./polarAxisSelectors.mjs";
12
+ import { pickAxisType } from "./pickAxisType.mjs";
13
+ import { pickAxisId } from "./pickAxisId.mjs";
14
+ import { checkDomainOfScale, getDomainOfStackGroups, getStackedData, getValueByDataKey } from "../../utils/chart.mjs";
15
+ import { isWellFormedNumberDomain, numericalDomainSpecifiedWithoutRequiringData, parseNumericalUserDomain } from "../../utils/isDomainSpecifiedByUser.mjs";
16
+ import { combineInverseScaleFunction, createCategoricalInverse } from "../../utils/createCategoricalInverse.mjs";
17
+ import { getNiceTickValues, getTickValuesFixedDomain } from "../../utils/scale/getNiceTickValues.mjs";
18
+ import { createSelector } from "@reduxjs/toolkit";
19
+ import { range, upperFirst } from "lodash-es";
20
+ import * as d3Scales from "victory-vendor/d3-scale";
20
21
  //#region src/state/selectors/axisSelectors.ts
21
- var C = [0, "auto"], ve = {
22
- allowDataOverflow: !1,
23
- allowDecimals: !0,
24
- allowDuplicatedCategory: !0,
22
+ var defaultNumericDomain = [0, "auto"];
23
+ /**
24
+ * If an axis is not explicitly defined as an element,
25
+ * we still need to render something in the chart and we need
26
+ * some object to hold the domain and default settings.
27
+ */
28
+ var implicitXAxis = {
29
+ allowDataOverflow: false,
30
+ allowDecimals: true,
31
+ allowDuplicatedCategory: true,
25
32
  angle: 0,
26
33
  dataKey: void 0,
27
34
  domain: void 0,
28
35
  height: 30,
29
- hide: !0,
36
+ hide: true,
30
37
  id: void 0,
31
- includeHidden: !1,
38
+ includeHidden: false,
32
39
  interval: "preserveEnd",
33
40
  minTickGap: 5,
34
- mirror: !1,
41
+ mirror: false,
35
42
  name: void 0,
36
43
  orientation: "bottom",
37
44
  padding: {
38
45
  left: 0,
39
46
  right: 0
40
47
  },
41
- reversed: !1,
48
+ reversed: false,
42
49
  scale: "auto",
43
- tick: !0,
50
+ tick: true,
44
51
  tickCount: 5,
45
52
  tickFormatter: void 0,
46
53
  ticks: void 0,
47
54
  type: "category",
48
55
  unit: void 0
49
56
  };
50
- function w(e, t) {
51
- return e.cartesianAxis.xAxis[t] ?? ve;
52
- }
53
- var ye = {
54
- allowDataOverflow: !1,
55
- allowDecimals: !0,
56
- allowDuplicatedCategory: !0,
57
+ function selectXAxisSettings(state, axisId) {
58
+ const axis = state.cartesianAxis.xAxis[axisId];
59
+ if (axis == null) return implicitXAxis;
60
+ return axis;
61
+ }
62
+ /**
63
+ * If an axis is not explicitly defined as an element,
64
+ * we still need to render something in the chart and we need
65
+ * some object to hold the domain and default settings.
66
+ */
67
+ var implicitYAxis = {
68
+ allowDataOverflow: false,
69
+ allowDecimals: true,
70
+ allowDuplicatedCategory: true,
57
71
  angle: 0,
58
72
  dataKey: void 0,
59
- domain: C,
60
- hide: !0,
73
+ domain: defaultNumericDomain,
74
+ hide: true,
61
75
  id: void 0,
62
- includeHidden: !1,
76
+ includeHidden: false,
63
77
  interval: "preserveEnd",
64
78
  minTickGap: 5,
65
- mirror: !1,
79
+ mirror: false,
66
80
  name: void 0,
67
81
  orientation: "left",
68
82
  padding: {
69
83
  top: 0,
70
84
  bottom: 0
71
85
  },
72
- reversed: !1,
86
+ reversed: false,
73
87
  scale: "auto",
74
- tick: !0,
88
+ tick: true,
75
89
  tickCount: 5,
76
90
  tickFormatter: void 0,
77
91
  ticks: void 0,
@@ -79,15 +93,17 @@ var ye = {
79
93
  unit: void 0,
80
94
  width: 60
81
95
  };
82
- function T(e, t) {
83
- return e.cartesianAxis.yAxis[t] ?? ye;
96
+ function selectYAxisSettings(state, axisId) {
97
+ const axis = state.cartesianAxis.yAxis[axisId];
98
+ if (axis == null) return implicitYAxis;
99
+ return axis;
84
100
  }
85
- var be = {
101
+ var implicitZAxis = {
86
102
  domain: [0, "auto"],
87
- includeHidden: !1,
88
- reversed: !1,
89
- allowDataOverflow: !1,
90
- allowDuplicatedCategory: !1,
103
+ includeHidden: false,
104
+ reversed: false,
105
+ allowDataOverflow: false,
106
+ allowDuplicatedCategory: false,
91
107
  dataKey: void 0,
92
108
  id: void 0,
93
109
  name: "",
@@ -96,598 +112,797 @@ var be = {
96
112
  type: "number",
97
113
  unit: ""
98
114
  };
99
- function E(e, t) {
100
- return e.cartesianAxis.zAxis[t] ?? be;
101
- }
102
- function D(e, t, n) {
103
- switch (t) {
104
- case "xAxis": return w(e, n);
105
- case "yAxis": return T(e, n);
106
- case "zAxis": return E(e, n);
107
- case "angleAxis": return ie(e, n);
108
- case "radiusAxis": return oe(e, n);
109
- default: throw Error(`Unexpected axis type: ${t}`);
115
+ function selectZAxisSettings(state, axisId) {
116
+ const axis = state.cartesianAxis.zAxis[axisId];
117
+ if (axis == null) return implicitZAxis;
118
+ return axis;
119
+ }
120
+ function selectBaseAxis(state, axisType, axisId) {
121
+ switch (axisType) {
122
+ case "xAxis": return selectXAxisSettings(state, axisId);
123
+ case "yAxis": return selectYAxisSettings(state, axisId);
124
+ case "zAxis": return selectZAxisSettings(state, axisId);
125
+ case "angleAxis": return selectAngleAxis(state, axisId);
126
+ case "radiusAxis": return selectRadiusAxis(state, axisId);
127
+ default: throw new Error(`Unexpected axis type: ${axisType}`);
110
128
  }
111
129
  }
112
- function xe(e, t, n) {
113
- switch (t) {
114
- case "xAxis": return w(e, n);
115
- case "yAxis": return T(e, n);
116
- default: throw Error(`Unexpected axis type: ${t}`);
130
+ function selectCartesianAxisSettings(state, axisType, axisId) {
131
+ switch (axisType) {
132
+ case "xAxis": return selectXAxisSettings(state, axisId);
133
+ case "yAxis": return selectYAxisSettings(state, axisId);
134
+ default: throw new Error(`Unexpected axis type: ${axisType}`);
117
135
  }
118
136
  }
119
- function O(e, t, n = 0) {
120
- switch (t) {
121
- case "xAxis": return w(e, n);
122
- case "yAxis": return T(e, n);
123
- case "angleAxis": return ie(e, n);
124
- case "radiusAxis": return oe(e, n);
125
- default: throw Error(`Unexpected axis type: ${t}`);
137
+ /**
138
+ * Selects either an X or Y axis. Doesn't work with Z axis - for that, instead use selectBaseAxis.
139
+ * @param state Root state
140
+ * @param axisType xAxis | yAxis
141
+ * @param axisId xAxisId | yAxisId
142
+ * @returns axis settings object
143
+ */
144
+ function selectAxisSettings(state, axisType, axisId = 0) {
145
+ switch (axisType) {
146
+ case "xAxis": return selectXAxisSettings(state, axisId);
147
+ case "yAxis": return selectYAxisSettings(state, axisId);
148
+ case "angleAxis": return selectAngleAxis(state, axisId);
149
+ case "radiusAxis": return selectRadiusAxis(state, axisId);
150
+ default: throw new Error(`Unexpected axis type: ${axisType}`);
126
151
  }
127
152
  }
128
- function k(e) {
129
- return e.graphicalItems.cartesianItems.some((e) => e.type === "bar") || e.graphicalItems.polarItems.some((e) => e.type === "radialBar");
130
- }
131
- function A(e, t) {
132
- return (n) => {
133
- switch (e) {
134
- case "xAxis": return "xAxisId" in n && n.xAxisId === t;
135
- case "yAxis": return "yAxisId" in n && n.yAxisId === t;
136
- case "zAxis": return "zAxisId" in n && n.zAxisId === t;
137
- case "angleAxis": return "angleAxisId" in n && n.angleAxisId === t;
138
- case "radiusAxis": return "radiusAxisId" in n && n.radiusAxisId === t;
139
- default: return !1;
153
+ /**
154
+ * @param state RechartsRootState
155
+ * @return boolean true if there is at least one Bar or RadialBar
156
+ */
157
+ function selectHasBar(state) {
158
+ return state.graphicalItems.cartesianItems.some((item) => item.type === "bar") || state.graphicalItems.polarItems.some((item) => item.type === "radialBar");
159
+ }
160
+ /**
161
+ * Filters CartesianGraphicalItemSettings by the relevant axis ID
162
+ * @param axisType 'xAxis' | 'yAxis' | 'zAxis' | 'radiusAxis' | 'angleAxis'
163
+ * @param axisId from props, defaults to 0
164
+ *
165
+ * @returns Predicate function that return true for CartesianGraphicalItemSettings that are relevant to the specified axis
166
+ */
167
+ function itemAxisPredicate(axisType, axisId) {
168
+ return (item) => {
169
+ switch (axisType) {
170
+ case "xAxis": return "xAxisId" in item && item.xAxisId === axisId;
171
+ case "yAxis": return "yAxisId" in item && item.yAxisId === axisId;
172
+ case "zAxis": return "zAxisId" in item && item.zAxisId === axisId;
173
+ case "angleAxis": return "angleAxisId" in item && item.angleAxisId === axisId;
174
+ case "radiusAxis": return "radiusAxisId" in item && item.radiusAxisId === axisId;
175
+ default: return false;
140
176
  }
141
177
  };
142
178
  }
143
- function j(e) {
144
- return e.graphicalItems.cartesianItems;
145
- }
146
- var Se = x([v, y], A);
147
- function M(e, t, n) {
148
- return e.filter(n).filter((e) => t?.includeHidden === !0 ? !0 : !e.hide);
149
- }
150
- var N = x([
151
- j,
152
- D,
153
- Se
154
- ], M);
155
- function P(e) {
156
- return e.filter((e) => e.stackId === void 0);
157
- }
158
- var Ce = x([N], P);
159
- function F(e) {
160
- return e.map((e) => e.data).filter(Boolean).flat(1);
161
- }
162
- var we = x([N], F);
163
- function Te(e, { chartData: t = [], dataStartIndex: n, dataEndIndex: r }) {
164
- return e.length > 0 ? e : t.slice(n, r + 1);
165
- }
166
- var I = x([we, o], Te);
167
- function Ee(e, t, n) {
168
- return t?.dataKey == null ? n.length > 0 ? n.map((e) => e.dataKey).flatMap((t) => e.map((e) => ({ value: b(e, t) }))) : e.map((e) => ({ value: e })) : e.map((e) => ({ value: b(e, t.dataKey) }));
169
- }
170
- var L = x([
171
- I,
172
- D,
173
- N
174
- ], Ee);
175
- function De(e, t) {
176
- switch (e) {
177
- case "xAxis": return t.direction === "x";
178
- case "yAxis": return t.direction === "y";
179
- default: return !1;
179
+ function selectUnfilteredCartesianItems(state) {
180
+ return state.graphicalItems.cartesianItems;
181
+ }
182
+ var selectAxisPredicate = createSelector([pickAxisType, pickAxisId], itemAxisPredicate);
183
+ function combineGraphicalItemsSettings(graphicalItems, axisSettings, axisPredicate) {
184
+ return graphicalItems.filter(axisPredicate).filter((item) => {
185
+ if (axisSettings?.includeHidden === true) return true;
186
+ return !item.hide;
187
+ });
188
+ }
189
+ var selectCartesianItemsSettings = createSelector([
190
+ selectUnfilteredCartesianItems,
191
+ selectBaseAxis,
192
+ selectAxisPredicate
193
+ ], combineGraphicalItemsSettings);
194
+ function filterGraphicalNotStackedItems(cartesianItems) {
195
+ return cartesianItems.filter((item) => item.stackId === void 0);
196
+ }
197
+ var selectCartesianItemsSettingsExceptStacked = createSelector([selectCartesianItemsSettings], filterGraphicalNotStackedItems);
198
+ function combineGraphicalItemsData(cartesianItems) {
199
+ return cartesianItems.map((item) => item.data).filter(Boolean).flat(1);
200
+ }
201
+ /**
202
+ * This is a "cheap" selector - it returns the data but doesn't iterate them, so it is not sensitive on the array length.
203
+ * Also does not apply dataKey yet.
204
+ * @param state RechartsRootState
205
+ * @returns data defined on the chart graphical items, such as Line or Scatter or Pie, and filtered with appropriate dataKey
206
+ */
207
+ var selectCartesianGraphicalItemsData = createSelector([selectCartesianItemsSettings], combineGraphicalItemsData);
208
+ function combineDisplayedData(graphicalItemsData, { chartData = [], dataStartIndex, dataEndIndex }) {
209
+ if (graphicalItemsData.length > 0) return graphicalItemsData;
210
+ return chartData.slice(dataStartIndex, dataEndIndex + 1);
211
+ }
212
+ /**
213
+ * This selector will return all data there is in the chart: graphical items, chart root, all together.
214
+ * Useful for figuring out an axis domain (because that needs to know of everything),
215
+ * not useful for rendering individual graphical elements (because they need to know which data is theirs and which is not).
216
+ *
217
+ * This function will discard the original indexes, so it is also not useful for anything that depends on ordering.
218
+ */
219
+ var selectDisplayedData = createSelector([selectCartesianGraphicalItemsData, selectChartDataWithIndexesIfNotInPanorama], combineDisplayedData);
220
+ function combineAppliedValues(data, axisSettings, items) {
221
+ if (axisSettings?.dataKey != null) return data.map((item) => ({ value: getValueByDataKey(item, axisSettings.dataKey) }));
222
+ if (items.length > 0) return items.map((item) => item.dataKey).flatMap((dataKey) => data.map((entry) => ({ value: getValueByDataKey(entry, dataKey) })));
223
+ return data.map((entry) => ({ value: entry }));
224
+ }
225
+ /**
226
+ * This selector will return all values with the appropriate dataKey applied on them.
227
+ * Which dataKey is appropriate depends on where it is defined.
228
+ *
229
+ * This is an expensive selector - it will iterate all data and compute their value using the provided dataKey.
230
+ */
231
+ var selectAllAppliedValues = createSelector([
232
+ selectDisplayedData,
233
+ selectBaseAxis,
234
+ selectCartesianItemsSettings
235
+ ], combineAppliedValues);
236
+ function isErrorBarRelevantForAxisType(axisType, errorBar) {
237
+ switch (axisType) {
238
+ case "xAxis": return errorBar.direction === "x";
239
+ case "yAxis": return errorBar.direction === "y";
240
+ default: return false;
180
241
  }
181
242
  }
182
- function R(e) {
183
- return e.filter((e) => n(e) || e instanceof Date).map(Number).filter((e) => t(e) === !1);
243
+ function onlyAllowNumbers(data) {
244
+ return data.filter((v) => isNumOrStr(v) || v instanceof Date).map(Number).filter((n) => isNan(n) === false);
245
+ }
246
+ /**
247
+ * @param entry One item in the 'data' array. Could be anything really - this is defined externally. This is the raw, before dataKey application
248
+ * @param appliedValue This is the result of applying the 'main' dataKey on the `entry`.
249
+ * @param relevantErrorBars Error bars that are relevant for the current axis and layout and all that.
250
+ * @return either undefined or an array of ErrorValue
251
+ */
252
+ function getErrorDomainByDataKey(entry, appliedValue, relevantErrorBars) {
253
+ if (!relevantErrorBars || typeof appliedValue !== "number" || isNan(appliedValue)) return [];
254
+ if (!relevantErrorBars.length) return [];
255
+ return onlyAllowNumbers(relevantErrorBars.flatMap((eb) => {
256
+ const errorValue = getValueByDataKey(entry, eb.dataKey);
257
+ let lowBound, highBound;
258
+ if (Array.isArray(errorValue)) [lowBound, highBound] = errorValue;
259
+ else lowBound = highBound = errorValue;
260
+ if (!isWellBehavedNumber(lowBound) || !isWellBehavedNumber(highBound)) return;
261
+ return [appliedValue - lowBound, appliedValue + highBound];
262
+ }));
184
263
  }
185
- function Oe(e, n, r) {
186
- return !r || typeof n != "number" || t(n) || !r.length ? [] : R(r.flatMap((t) => {
187
- let r = b(e, t.dataKey), a, o;
188
- if (Array.isArray(r) ? [a, o] = r : a = o = r, !(!i(a) || !i(o))) return [n - a, n + o];
264
+ function combineStackGroups(displayedData, items, stackOffsetType) {
265
+ const itemsGroup = items.reduce((acc, item) => {
266
+ if (item.stackId == null) return acc;
267
+ if (acc[item.stackId] == null) acc[item.stackId] = [];
268
+ acc[item.stackId].push(item);
269
+ return acc;
270
+ }, {});
271
+ return Object.fromEntries(Object.entries(itemsGroup).map(([stackId, graphicalItems]) => {
272
+ return [stackId, {
273
+ stackedData: getStackedData(displayedData, graphicalItems.map((i) => i.dataKey), stackOffsetType),
274
+ graphicalItems
275
+ }];
189
276
  }));
190
277
  }
191
- function ke(e, t, n) {
192
- let r = t.reduce((e, t) => t.stackId == null ? e : (e[t.stackId] ?? (e[t.stackId] = []), e[t.stackId].push(t), e), {});
193
- return Object.fromEntries(Object.entries(r).map(([t, r]) => [t, {
194
- stackedData: ue(e, r.map((e) => e.dataKey), n),
195
- graphicalItems: r
196
- }]));
197
- }
198
- var Ae = x([
199
- I,
200
- N,
201
- h
202
- ], ke);
203
- function je(e, { dataStartIndex: t, dataEndIndex: n }, r) {
204
- if (r === "zAxis") return;
205
- let i = le(e, t, n);
206
- if (!(i != null && i[0] === 0 && i[1] === 0)) return i;
207
- }
208
- var Me = x([
209
- Ae,
210
- a,
211
- v
212
- ], je);
213
- function Ne(e, t, n, r) {
214
- return n.length > 0 ? e.flatMap((e) => n.flatMap((n) => {
215
- let i = n.errorBars?.filter((e) => De(r, e)), a = b(e, t.dataKey || n.dataKey);
216
- return {
217
- value: a,
218
- errorDomain: Oe(e, a, i)
219
- };
220
- })).filter(Boolean) : t?.dataKey == null ? e.map((e) => ({
221
- value: e,
278
+ /**
279
+ * Stack groups are groups of graphical items that stack on each other.
280
+ * Stack is a function of axis type (X, Y), axis ID, and stack ID.
281
+ * Graphical items that do not have a stack ID are not going to be present in stack groups.
282
+ */
283
+ var selectStackGroups = createSelector([
284
+ selectDisplayedData,
285
+ selectCartesianItemsSettings,
286
+ selectStackOffsetType
287
+ ], combineStackGroups);
288
+ function combineDomainOfStackGroups(stackGroups, { dataStartIndex, dataEndIndex }, axisType) {
289
+ if (axisType === "zAxis") return;
290
+ const domainOfStackGroups = getDomainOfStackGroups(stackGroups, dataStartIndex, dataEndIndex);
291
+ if (domainOfStackGroups != null && domainOfStackGroups[0] === 0 && domainOfStackGroups[1] === 0) return;
292
+ return domainOfStackGroups;
293
+ }
294
+ var selectDomainOfStackGroups = createSelector([
295
+ selectStackGroups,
296
+ selectChartDataWithIndexes,
297
+ pickAxisType
298
+ ], combineDomainOfStackGroups);
299
+ function combineAppliedNumericalValuesIncludingErrorValues(data, axisSettings, items, axisType) {
300
+ if (items.length > 0) return data.flatMap((entry) => {
301
+ return items.flatMap((item) => {
302
+ const relevantErrorBars = item.errorBars?.filter((errorBar) => isErrorBarRelevantForAxisType(axisType, errorBar));
303
+ const valueByDataKey = getValueByDataKey(entry, axisSettings.dataKey || item.dataKey);
304
+ return {
305
+ value: valueByDataKey,
306
+ errorDomain: getErrorDomainByDataKey(entry, valueByDataKey, relevantErrorBars)
307
+ };
308
+ });
309
+ }).filter(Boolean);
310
+ if (axisSettings?.dataKey != null) return data.map((item) => ({
311
+ value: getValueByDataKey(item, axisSettings.dataKey),
222
312
  errorDomain: []
223
- })) : e.map((e) => ({
224
- value: b(e, t.dataKey),
313
+ }));
314
+ return data.map((entry) => ({
315
+ value: entry,
225
316
  errorDomain: []
226
317
  }));
227
318
  }
228
- var Pe = x(I, D, Ce, v, Ne);
229
- function Fe(e) {
230
- let { value: t } = e;
231
- if (n(t) || t instanceof Date) return t;
232
- }
233
- function Ie(e) {
234
- let t = R(e.flatMap((e) => [e.value, e.errorDomain]).flat(1));
235
- if (t.length !== 0) return [Math.min(...t), Math.max(...t)];
236
- }
237
- function Le(e, t, n) {
238
- let r = e.map(Fe).filter((e) => e != null);
239
- return n && (t.dataKey == null || t.allowDuplicatedCategory && ne(r)) ? ge(0, e.length) : t.allowDuplicatedCategory ? r : Array.from(new Set(r));
240
- }
241
- function z(e) {
242
- if (e == null || !("domain" in e)) return C;
243
- if (e.domain != null) return e.domain;
244
- if (e.ticks != null) {
245
- if (e.type === "number") {
246
- let t = R(e.ticks);
247
- return [Math.min(...t), Math.max(...t)];
319
+ var selectAllAppliedNumericalValuesIncludingErrorValues = createSelector(selectDisplayedData, selectBaseAxis, selectCartesianItemsSettingsExceptStacked, pickAxisType, combineAppliedNumericalValuesIncludingErrorValues);
320
+ function onlyAllowNumbersAndStringsAndDates(item) {
321
+ const { value } = item;
322
+ if (isNumOrStr(value) || value instanceof Date) return value;
323
+ }
324
+ function computeNumericalDomain(dataWithErrorDomains) {
325
+ const onlyNumbers = onlyAllowNumbers(dataWithErrorDomains.flatMap((d) => [d.value, d.errorDomain]).flat(1));
326
+ if (onlyNumbers.length === 0) return;
327
+ return [Math.min(...onlyNumbers), Math.max(...onlyNumbers)];
328
+ }
329
+ function computeDomainOfTypeCategory(allDataSquished, axisSettings, isCategorical) {
330
+ const categoricalDomain = allDataSquished.map(onlyAllowNumbersAndStringsAndDates).filter((v) => v != null);
331
+ if (isCategorical && (axisSettings.dataKey == null || axisSettings.allowDuplicatedCategory && hasDuplicate(categoricalDomain))) return range(0, allDataSquished.length);
332
+ if (axisSettings.allowDuplicatedCategory) return categoricalDomain;
333
+ return Array.from(new Set(categoricalDomain));
334
+ }
335
+ function getDomainDefinition(axisSettings) {
336
+ if (axisSettings == null || !("domain" in axisSettings)) return defaultNumericDomain;
337
+ if (axisSettings.domain != null) return axisSettings.domain;
338
+ if (axisSettings.ticks != null) {
339
+ if (axisSettings.type === "number") {
340
+ const allValues = onlyAllowNumbers(axisSettings.ticks);
341
+ return [Math.min(...allValues), Math.max(...allValues)];
248
342
  }
249
- if (e.type === "category") return e.ticks.map(String);
343
+ if (axisSettings.type === "category") return axisSettings.ticks.map(String);
250
344
  }
251
- return e?.domain ?? C;
252
- }
253
- function B(...e) {
254
- let t = e.filter(Boolean);
255
- if (t.length === 0) return;
256
- let n = t.flat().filter(r);
257
- return [Math.min(...n), Math.max(...n)];
258
- }
259
- function Re(e) {
260
- return e.referenceElements.dots;
261
- }
262
- function V(e, t, n) {
263
- return e.filter((e) => e.ifOverflow === "extendDomain").filter((e) => t === "xAxis" ? e.xAxisId === n : e.yAxisId === n);
264
- }
265
- var ze = x([
266
- Re,
267
- v,
268
- y
269
- ], V);
270
- function Be(e) {
271
- return e.referenceElements.areas;
272
- }
273
- var Ve = x([
274
- Be,
275
- v,
276
- y
277
- ], V);
278
- function He(e) {
279
- return e.referenceElements.lines;
280
- }
281
- var Ue = x([
282
- He,
283
- v,
284
- y
285
- ], V);
286
- function H(e, t) {
287
- let n = R(e.map((e) => t === "xAxis" ? e.x : e.y));
288
- if (n.length !== 0) return [Math.min(...n), Math.max(...n)];
289
- }
290
- var We = x(ze, v, H);
291
- function Ge(e, t) {
292
- let n = R(e.flatMap((e) => [t === "xAxis" ? e.x1 : e.y1, t === "xAxis" ? e.x2 : e.y2]));
293
- if (n.length !== 0) return [Math.min(...n), Math.max(...n)];
294
- }
295
- var Ke = x([Ve, v], Ge);
296
- function qe(e, t) {
297
- let n = R(e.map((e) => t === "xAxis" ? e.x : e.y));
298
- if (n.length !== 0) return [Math.min(...n), Math.max(...n)];
299
- }
300
- var Je = x(We, x(Ue, v, qe), Ke, (e, t, n) => B(e, n, t)), Ye = x([D], z);
301
- function Xe(e, t, n, r, i) {
302
- return fe(t, e.allowDataOverflow) ?? pe(t, B(n, i, Ie(r)), e.allowDataOverflow);
303
- }
304
- var Ze = x([
305
- D,
306
- Ye,
307
- Me,
308
- Pe,
309
- Je
310
- ], Xe), Qe = [0, 1];
311
- function $e(t, n, r, i, a, o, s) {
312
- if ((t == null || r == null || r.length === 0) && s === void 0) return;
313
- let { dataKey: c, type: l } = t, u = e(n, o);
314
- if (u && c == null) {
315
- let e = Array.isArray(t.domain) ? t.domain.length : 0;
316
- return ge(0, Math.max(r.length, e));
345
+ return axisSettings?.domain ?? defaultNumericDomain;
346
+ }
347
+ function mergeDomains(...domains) {
348
+ const allDomains = domains.filter(Boolean);
349
+ if (allDomains.length === 0) return;
350
+ const allNumbers = allDomains.flat().filter(isNumber);
351
+ return [Math.min(...allNumbers), Math.max(...allNumbers)];
352
+ }
353
+ function selectReferenceDots(state) {
354
+ return state.referenceElements.dots;
355
+ }
356
+ function filterReferenceElements(elements, axisType, axisId) {
357
+ return elements.filter((el) => el.ifOverflow === "extendDomain").filter((el) => {
358
+ if (axisType === "xAxis") return el.xAxisId === axisId;
359
+ return el.yAxisId === axisId;
360
+ });
361
+ }
362
+ var selectReferenceDotsByAxis = createSelector([
363
+ selectReferenceDots,
364
+ pickAxisType,
365
+ pickAxisId
366
+ ], filterReferenceElements);
367
+ function selectReferenceAreas(state) {
368
+ return state.referenceElements.areas;
369
+ }
370
+ var selectReferenceAreasByAxis = createSelector([
371
+ selectReferenceAreas,
372
+ pickAxisType,
373
+ pickAxisId
374
+ ], filterReferenceElements);
375
+ function selectReferenceLines(state) {
376
+ return state.referenceElements.lines;
377
+ }
378
+ var selectReferenceLinesByAxis = createSelector([
379
+ selectReferenceLines,
380
+ pickAxisType,
381
+ pickAxisId
382
+ ], filterReferenceElements);
383
+ function combineDotsDomain(dots, axisType) {
384
+ const allCoords = onlyAllowNumbers(dots.map((dot) => axisType === "xAxis" ? dot.x : dot.y));
385
+ if (allCoords.length === 0) return;
386
+ return [Math.min(...allCoords), Math.max(...allCoords)];
387
+ }
388
+ var selectReferenceDotsDomain = createSelector(selectReferenceDotsByAxis, pickAxisType, combineDotsDomain);
389
+ function combineAreasDomain(areas, axisType) {
390
+ const allCoords = onlyAllowNumbers(areas.flatMap((area) => [axisType === "xAxis" ? area.x1 : area.y1, axisType === "xAxis" ? area.x2 : area.y2]));
391
+ if (allCoords.length === 0) return;
392
+ return [Math.min(...allCoords), Math.max(...allCoords)];
393
+ }
394
+ var selectReferenceAreasDomain = createSelector([selectReferenceAreasByAxis, pickAxisType], combineAreasDomain);
395
+ function combineLinesDomain(lines, axisType) {
396
+ const allCoords = onlyAllowNumbers(lines.map((line) => axisType === "xAxis" ? line.x : line.y));
397
+ if (allCoords.length === 0) return;
398
+ return [Math.min(...allCoords), Math.max(...allCoords)];
399
+ }
400
+ var selectReferenceElementsDomain = createSelector(selectReferenceDotsDomain, createSelector(selectReferenceLinesByAxis, pickAxisType, combineLinesDomain), selectReferenceAreasDomain, (dotsDomain, linesDomain, areasDomain) => {
401
+ return mergeDomains(dotsDomain, areasDomain, linesDomain);
402
+ });
403
+ var selectDomainDefinition = createSelector([selectBaseAxis], getDomainDefinition);
404
+ function combineNumericalDomain(axisSettings, domainDefinition, domainOfStackGroups, allDataWithErrorDomains, referenceElementsDomain) {
405
+ const domainFromUserPreference = numericalDomainSpecifiedWithoutRequiringData(domainDefinition, axisSettings.allowDataOverflow);
406
+ if (domainFromUserPreference != null) return domainFromUserPreference;
407
+ return parseNumericalUserDomain(domainDefinition, mergeDomains(domainOfStackGroups, referenceElementsDomain, computeNumericalDomain(allDataWithErrorDomains)), axisSettings.allowDataOverflow);
408
+ }
409
+ var selectNumericalDomain = createSelector([
410
+ selectBaseAxis,
411
+ selectDomainDefinition,
412
+ selectDomainOfStackGroups,
413
+ selectAllAppliedNumericalValuesIncludingErrorValues,
414
+ selectReferenceElementsDomain
415
+ ], combineNumericalDomain);
416
+ /**
417
+ * Expand by design maps everything between 0 and 1,
418
+ * there is nothing to compute.
419
+ * See https://d3js.org/d3-shape/stack#stack-offsets
420
+ */
421
+ var expandDomain = [0, 1];
422
+ function combineAxisDomain(axisSettings, layout, displayedData, allAppliedValues, stackOffsetType, axisType, numericalDomain) {
423
+ if ((axisSettings == null || displayedData == null || displayedData.length === 0) && numericalDomain === void 0) return;
424
+ const { dataKey, type } = axisSettings;
425
+ const isCategorical = isCategoricalAxis(layout, axisType);
426
+ if (isCategorical && dataKey == null) {
427
+ const domainLen = Array.isArray(axisSettings.domain) ? axisSettings.domain.length : 0;
428
+ return range(0, Math.max(displayedData.length, domainLen));
317
429
  }
318
- return l === "category" ? Le(i, t, u) : a === "expand" ? Qe : s;
319
- }
320
- var U = x([
321
- D,
322
- _,
323
- I,
324
- L,
325
- h,
326
- v,
327
- Ze
328
- ], $e);
329
- function et(e, t, n) {
330
- if (e == null) return;
331
- let { scale: r, type: i } = e;
332
- if (r === "auto") return i === "category" && n && (n.includes("LineChart") || n.includes("AreaChart") || n.includes("ComposedChart") && !t) ? "point" : i === "category" ? "band" : "linear";
333
- if (typeof r == "string") {
334
- let e = `scale${_e(r)}`;
335
- return e in S ? e : "point";
430
+ if (type === "category") return computeDomainOfTypeCategory(allAppliedValues, axisSettings, isCategorical);
431
+ if (stackOffsetType === "expand") return expandDomain;
432
+ return numericalDomain;
433
+ }
434
+ var selectAxisDomain = createSelector([
435
+ selectBaseAxis,
436
+ selectChartLayout,
437
+ selectDisplayedData,
438
+ selectAllAppliedValues,
439
+ selectStackOffsetType,
440
+ pickAxisType,
441
+ selectNumericalDomain
442
+ ], combineAxisDomain);
443
+ function combineRealScaleType(axisConfig, hasBar, chartType) {
444
+ if (axisConfig == null) return;
445
+ const { scale, type } = axisConfig;
446
+ if (scale === "auto") {
447
+ if (type === "category" && chartType && (chartType.includes("LineChart") || chartType.includes("AreaChart") || chartType.includes("ComposedChart") && !hasBar)) return "point";
448
+ if (type === "category") return "band";
449
+ return "linear";
336
450
  }
337
- }
338
- var W = x([
339
- D,
340
- k,
341
- m
342
- ], et);
343
- function tt(e) {
344
- if (e == null) return;
345
- if (e in S) return S[e]();
346
- let t = `scale${_e(e)}`;
347
- if (t in S) return S[t]();
348
- }
349
- function G(e, t, n, r) {
350
- if (n == null || r == null) return;
351
- if (typeof e.scale == "function") return e.scale.copy().domain(n).range(r);
352
- let i = tt(t);
353
- if (i == null) return;
354
- let a = i.domain(n).range(r);
355
- return ce(a), a;
356
- }
357
- function nt(e, t, n) {
358
- let r = z(t);
359
- if (!(n !== "auto" && n !== "linear")) {
360
- if (t != null && t.tickCount && Array.isArray(r) && (r[0] === "auto" || r[1] === "auto") && de(e)) return me(e, t.tickCount, t.allowDecimals);
361
- if (t != null && t.tickCount && t.type === "number" && e != null) return he(e, t.tickCount, t.allowDecimals);
451
+ if (typeof scale === "string") {
452
+ const name = `scale${upperFirst(scale)}`;
453
+ return name in d3Scales ? name : "point";
362
454
  }
363
455
  }
364
- var K = x([
365
- U,
366
- O,
367
- W
368
- ], nt);
369
- function rt(e, t, n, r) {
370
- if (r !== "angleAxis" && e?.type === "number" && de(t) && Array.isArray(n) && n.length > 0) {
371
- let e = t[0], r = n[0], i = t[1], a = n[n.length - 1];
372
- return [Math.min(e, r), Math.max(i, a)];
456
+ var selectRealScaleType = createSelector([
457
+ selectBaseAxis,
458
+ selectHasBar,
459
+ selectChartName
460
+ ], combineRealScaleType);
461
+ function getD3ScaleFromType(realScaleType) {
462
+ if (realScaleType == null) return;
463
+ if (realScaleType in d3Scales) return d3Scales[realScaleType]();
464
+ const name = `scale${upperFirst(realScaleType)}`;
465
+ if (name in d3Scales) return d3Scales[name]();
466
+ }
467
+ function combineScaleFunction(axis, realScaleType, axisDomain, axisRange) {
468
+ if (axisDomain == null || axisRange == null) return;
469
+ if (typeof axis.scale === "function") return axis.scale.copy().domain(axisDomain).range(axisRange);
470
+ const d3ScaleFunction = getD3ScaleFromType(realScaleType);
471
+ if (d3ScaleFunction == null) return;
472
+ const scale = d3ScaleFunction.domain(axisDomain).range(axisRange);
473
+ checkDomainOfScale(scale);
474
+ return scale;
475
+ }
476
+ function combineNiceTicks(axisDomain, axisSettings, realScaleType) {
477
+ const domainDefinition = getDomainDefinition(axisSettings);
478
+ if (realScaleType !== "auto" && realScaleType !== "linear") return;
479
+ if (axisSettings != null && axisSettings.tickCount && Array.isArray(domainDefinition) && (domainDefinition[0] === "auto" || domainDefinition[1] === "auto") && isWellFormedNumberDomain(axisDomain)) return getNiceTickValues(axisDomain, axisSettings.tickCount, axisSettings.allowDecimals);
480
+ if (axisSettings != null && axisSettings.tickCount && axisSettings.type === "number" && axisDomain != null) return getTickValuesFixedDomain(axisDomain, axisSettings.tickCount, axisSettings.allowDecimals);
481
+ }
482
+ var selectNiceTicks = createSelector([
483
+ selectAxisDomain,
484
+ selectAxisSettings,
485
+ selectRealScaleType
486
+ ], combineNiceTicks);
487
+ function combineAxisDomainWithNiceTicks(axisSettings, domain, niceTicks, axisType) {
488
+ if (axisType !== "angleAxis" && axisSettings?.type === "number" && isWellFormedNumberDomain(domain) && Array.isArray(niceTicks) && niceTicks.length > 0) {
489
+ const minFromDomain = domain[0];
490
+ const minFromTicks = niceTicks[0];
491
+ const maxFromDomain = domain[1];
492
+ const maxFromTicks = niceTicks[niceTicks.length - 1];
493
+ return [Math.min(minFromDomain, minFromTicks), Math.max(maxFromDomain, maxFromTicks)];
373
494
  }
374
- return t;
375
- }
376
- var it = x([
377
- D,
378
- U,
379
- K,
380
- v
381
- ], rt), at = x(x(L, D, (e, t) => {
382
- if (!t || t.type !== "number") return;
383
- let n = Infinity, r = Array.from(R(e.map((e) => e.value))).sort((e, t) => e - t);
384
- if (r.length < 2) return Infinity;
385
- let i = r[r.length - 1] - r[0];
386
- if (i === 0) return Infinity;
387
- for (let e = 0; e < r.length - 1; e++) {
388
- let t = r[e + 1] - r[e];
389
- n = Math.min(n, t);
495
+ return domain;
496
+ }
497
+ var selectAxisDomainIncludingNiceTicks = createSelector([
498
+ selectBaseAxis,
499
+ selectAxisDomain,
500
+ selectNiceTicks,
501
+ pickAxisType
502
+ ], combineAxisDomainWithNiceTicks);
503
+ var selectCalculatedPadding = createSelector(createSelector(selectAllAppliedValues, selectBaseAxis, (allDataSquished, axisSettings) => {
504
+ if (!axisSettings || axisSettings.type !== "number") return;
505
+ let smallestDistanceBetweenValues = Infinity;
506
+ const sortedValues = Array.from(onlyAllowNumbers(allDataSquished.map((d) => d.value))).sort((a, b) => a - b);
507
+ if (sortedValues.length < 2) return Infinity;
508
+ const diff = sortedValues[sortedValues.length - 1] - sortedValues[0];
509
+ if (diff === 0) return Infinity;
510
+ for (let i = 0; i < sortedValues.length - 1; i++) {
511
+ const distance = sortedValues[i + 1] - sortedValues[i];
512
+ smallestDistanceBetweenValues = Math.min(smallestDistanceBetweenValues, distance);
390
513
  }
391
- return n / i;
392
- }), _, ee, d, (e, t, n, r) => r, (e, t, n, r, a) => {
393
- if (!i(e)) return 0;
394
- let o = t === "vertical" ? r.height : r.width;
395
- if (a === "gap") return e * o / 2;
396
- if (a === "no-gap") {
397
- let t = te(n, e * o), r = e * o / 2;
398
- return r - t - (r - t) / o * t;
514
+ return smallestDistanceBetweenValues / diff;
515
+ }), selectChartLayout, selectBarCategoryGap, selectChartOffset, (_1, _2, _3, padding) => padding, (smallestDistanceInPercent, layout, barCategoryGap, offset, padding) => {
516
+ if (!isWellBehavedNumber(smallestDistanceInPercent)) return 0;
517
+ const rangeWidth = layout === "vertical" ? offset.height : offset.width;
518
+ if (padding === "gap") return smallestDistanceInPercent * rangeWidth / 2;
519
+ if (padding === "no-gap") {
520
+ const gap = getPercentValue(barCategoryGap, smallestDistanceInPercent * rangeWidth);
521
+ const halfBand = smallestDistanceInPercent * rangeWidth / 2;
522
+ return halfBand - gap - (halfBand - gap) / rangeWidth * gap;
399
523
  }
400
524
  return 0;
401
- }), ot = (e, t) => {
402
- let n = w(e, t);
403
- return n == null || typeof n.padding != "string" ? 0 : at(e, "xAxis", t, n.padding);
404
- }, st = (e, t) => {
405
- let n = T(e, t);
406
- return n == null || typeof n.padding != "string" ? 0 : at(e, "yAxis", t, n.padding);
407
- }, ct = x(w, ot, (e, t) => {
408
- if (e == null) return {
525
+ });
526
+ var selectCalculatedXAxisPadding = (state, axisId) => {
527
+ const xAxisSettings = selectXAxisSettings(state, axisId);
528
+ if (xAxisSettings == null || typeof xAxisSettings.padding !== "string") return 0;
529
+ return selectCalculatedPadding(state, "xAxis", axisId, xAxisSettings.padding);
530
+ };
531
+ var selectCalculatedYAxisPadding = (state, axisId) => {
532
+ const yAxisSettings = selectYAxisSettings(state, axisId);
533
+ if (yAxisSettings == null || typeof yAxisSettings.padding !== "string") return 0;
534
+ return selectCalculatedPadding(state, "yAxis", axisId, yAxisSettings.padding);
535
+ };
536
+ var selectXAxisPadding = createSelector(selectXAxisSettings, selectCalculatedXAxisPadding, (xAxisSettings, calculated) => {
537
+ if (xAxisSettings == null) return {
409
538
  left: 0,
410
539
  right: 0
411
540
  };
412
- let { padding: n } = e;
413
- return typeof n == "string" ? {
414
- left: t,
415
- right: t
416
- } : {
417
- left: (n.left ?? 0) + t,
418
- right: (n.right ?? 0) + t
541
+ const { padding } = xAxisSettings;
542
+ if (typeof padding === "string") return {
543
+ left: calculated,
544
+ right: calculated
545
+ };
546
+ return {
547
+ left: (padding.left ?? 0) + calculated,
548
+ right: (padding.right ?? 0) + calculated
419
549
  };
420
- }), lt = x(T, st, (e, t) => {
421
- if (e == null) return {
550
+ });
551
+ var selectYAxisPadding = createSelector(selectYAxisSettings, selectCalculatedYAxisPadding, (yAxisSettings, calculated) => {
552
+ if (yAxisSettings == null) return {
422
553
  top: 0,
423
554
  bottom: 0
424
555
  };
425
- let { padding: n } = e;
426
- return typeof n == "string" ? {
427
- top: t,
428
- bottom: t
429
- } : {
430
- top: (n.top ?? 0) + t,
431
- bottom: (n.bottom ?? 0) + t
556
+ const { padding } = yAxisSettings;
557
+ if (typeof padding === "string") return {
558
+ top: calculated,
559
+ bottom: calculated
560
+ };
561
+ return {
562
+ top: (padding.top ?? 0) + calculated,
563
+ bottom: (padding.bottom ?? 0) + calculated
432
564
  };
433
- }), ut = x([
434
- d,
435
- ct,
436
- f,
437
- p,
438
- (e, t, n) => n
439
- ], (e, t, n, { padding: r }, i) => i ? [r.left, n.width - r.right] : [e.left + t.left, e.left + e.width - t.right]), dt = x([
440
- d,
441
- _,
442
- lt,
443
- f,
444
- p,
445
- (e, t, n) => n
446
- ], (e, t, n, r, { padding: i }, a) => a ? [r.height - i.bottom, i.top] : t === "horizontal" ? [e.top + e.height - n.bottom, e.top + n.top] : [e.top + n.top, e.top + e.height - n.bottom]);
447
- function q(e, t, n, r) {
448
- switch (t) {
449
- case "xAxis": return ut(e, n, r);
450
- case "yAxis": return dt(e, n, r);
451
- case "zAxis": return E(e, n)?.range;
452
- case "angleAxis": return ae(e);
453
- case "radiusAxis": return se(e, n);
565
+ });
566
+ var combineXAxisRange = createSelector([
567
+ selectChartOffset,
568
+ selectXAxisPadding,
569
+ selectBrushDimensions,
570
+ selectBrushSettings,
571
+ (_state, _axisId, isPanorama) => isPanorama
572
+ ], (offset, padding, brushDimensions, { padding: brushPadding }, isPanorama) => {
573
+ if (isPanorama) return [brushPadding.left, brushDimensions.width - brushPadding.right];
574
+ return [offset.left + padding.left, offset.left + offset.width - padding.right];
575
+ });
576
+ var combineYAxisRange = createSelector([
577
+ selectChartOffset,
578
+ selectChartLayout,
579
+ selectYAxisPadding,
580
+ selectBrushDimensions,
581
+ selectBrushSettings,
582
+ (_state, _axisId, isPanorama) => isPanorama
583
+ ], (offset, layout, padding, brushDimensions, { padding: brushPadding }, isPanorama) => {
584
+ if (isPanorama) return [brushDimensions.height - brushPadding.bottom, brushPadding.top];
585
+ if (layout === "horizontal") return [offset.top + offset.height - padding.bottom, offset.top + padding.top];
586
+ return [offset.top + padding.top, offset.top + offset.height - padding.bottom];
587
+ });
588
+ function selectAxisRange(state, axisType, axisId, isPanorama) {
589
+ switch (axisType) {
590
+ case "xAxis": return combineXAxisRange(state, axisId, isPanorama);
591
+ case "yAxis": return combineYAxisRange(state, axisId, isPanorama);
592
+ case "zAxis": return selectZAxisSettings(state, axisId)?.range;
593
+ case "angleAxis": return selectAngleAxisRange(state);
594
+ case "radiusAxis": return selectRadiusAxisRange(state, axisId);
454
595
  default: return;
455
596
  }
456
597
  }
457
- var ft = x([D, q], g), J = x([
458
- D,
459
- W,
460
- it,
461
- ft
462
- ], G);
463
- x(N, v, (e, t) => e.flatMap((e) => e.errorBars ?? []).filter((e) => De(t, e)));
464
- function pt(e, t) {
465
- return e.id < t.id ? -1 : e.id > t.id ? 1 : 0;
466
- }
467
- var Y = (e, t) => t, X = (e, t, n) => n, mt = x(l, Y, X, (e, t, n) => e.filter((e) => e.orientation === t).filter((e) => e.mirror === n).sort(pt)), ht = x(u, Y, X, (e, t, n) => e.filter((e) => e.orientation === t).filter((e) => e.mirror === n).sort(pt));
468
- function gt(e, t) {
598
+ var selectAxisRangeWithReverse = createSelector([selectBaseAxis, selectAxisRange], combineAxisRangeWithReverse);
599
+ var selectAxisScale = createSelector([
600
+ selectBaseAxis,
601
+ selectRealScaleType,
602
+ selectAxisDomainIncludingNiceTicks,
603
+ selectAxisRangeWithReverse
604
+ ], combineScaleFunction);
605
+ function sortBy$1(a, b) {
606
+ const aNum = Number(a);
607
+ const bNum = Number(b);
608
+ if (Number.isNaN(aNum) && Number.isNaN(bNum)) return 0;
609
+ if (Number.isNaN(aNum)) return -1;
610
+ if (Number.isNaN(bNum)) return 1;
611
+ return aNum - bNum;
612
+ }
613
+ var selectSortedDataPoints = createSelector([selectAllAppliedValues], (appliedData) => {
614
+ return appliedData?.map((item) => item.value).sort(sortBy$1);
615
+ });
616
+ var selectAxisInverseScale = createSelector([selectAxisScale], combineInverseScaleFunction);
617
+ var selectAxisInverseDataSnapScale = createSelector([selectAxisScale, selectSortedDataPoints], createCategoricalInverse);
618
+ createSelector(selectCartesianItemsSettings, pickAxisType, (items, axisType) => {
619
+ return items.flatMap((item) => {
620
+ return item.errorBars ?? [];
621
+ }).filter((e) => {
622
+ return isErrorBarRelevantForAxisType(axisType, e);
623
+ });
624
+ });
625
+ function compareIds(a, b) {
626
+ if (a.id < b.id) return -1;
627
+ if (a.id > b.id) return 1;
628
+ return 0;
629
+ }
630
+ var pickAxisOrientation = (_state, orientation) => orientation;
631
+ var pickMirror = (_state, _orientation, mirror) => mirror;
632
+ var selectAllXAxesWithOffsetType = createSelector(selectAllXAxes, pickAxisOrientation, pickMirror, (allAxes, orientation, mirror) => allAxes.filter((axis) => axis.orientation === orientation).filter((axis) => axis.mirror === mirror).sort(compareIds));
633
+ var selectAllYAxesWithOffsetType = createSelector(selectAllYAxes, pickAxisOrientation, pickMirror, (allAxes, orientation, mirror) => allAxes.filter((axis) => axis.orientation === orientation).filter((axis) => axis.mirror === mirror).sort(compareIds));
634
+ function getXAxisSize(offset, axisSettings) {
469
635
  return {
470
- width: e.width,
471
- height: t.height
636
+ width: offset.width,
637
+ height: axisSettings.height
472
638
  };
473
639
  }
474
- function _t(e, t) {
640
+ function getYAxisSize(offset, axisSettings) {
475
641
  return {
476
- width: t.width,
477
- height: e.height
642
+ width: axisSettings.width,
643
+ height: offset.height
478
644
  };
479
645
  }
480
- var vt = x(d, w, gt);
481
- function yt(e, t, n) {
482
- switch (t) {
483
- case "top": return e.top;
484
- case "bottom": return n - e.bottom;
646
+ var selectXAxisSize = createSelector(selectChartOffset, selectXAxisSettings, getXAxisSize);
647
+ function combineXAxisPositionStartingPoint(offset, orientation, chartHeight) {
648
+ switch (orientation) {
649
+ case "top": return offset.top;
650
+ case "bottom": return chartHeight - offset.bottom;
485
651
  default: return 0;
486
652
  }
487
653
  }
488
- function bt(e, t, n) {
489
- switch (t) {
490
- case "left": return e.left;
491
- case "right": return n - e.right;
654
+ function combineYAxisPositionStartingPoint(offset, orientation, chartWidth) {
655
+ switch (orientation) {
656
+ case "left": return offset.left;
657
+ case "right": return chartWidth - offset.right;
492
658
  default: return 0;
493
659
  }
494
660
  }
495
- var xt = x(s, d, mt, Y, X, (e, t, n, r, i) => {
496
- let a = {}, o;
497
- return n.forEach((n) => {
498
- let s = gt(t, n);
499
- o ??= yt(t, r, e);
500
- let c = r === "top" && !i || r === "bottom" && i;
501
- a[n.id] = o - Number(c) * s.height, o += (c ? -1 : 1) * s.height;
502
- }), a;
503
- }), St = x(c, d, ht, Y, X, (e, t, n, r, i) => {
504
- let a = {}, o;
505
- return n.forEach((n) => {
506
- let s = _t(t, n);
507
- o ??= bt(t, r, e);
508
- let c = r === "left" && !i || r === "right" && i;
509
- a[n.id] = o - Number(c) * s.width, o += (c ? -1 : 1) * s.width;
510
- }), a;
661
+ var selectAllXAxesOffsetSteps = createSelector(selectChartHeight, selectChartOffset, selectAllXAxesWithOffsetType, pickAxisOrientation, pickMirror, (chartHeight, offset, allAxesWithSameOffsetType, orientation, mirror) => {
662
+ const steps = {};
663
+ let position;
664
+ allAxesWithSameOffsetType.forEach((axis) => {
665
+ const axisSize = getXAxisSize(offset, axis);
666
+ if (position == null) position = combineXAxisPositionStartingPoint(offset, orientation, chartHeight);
667
+ const needSpace = orientation === "top" && !mirror || orientation === "bottom" && mirror;
668
+ steps[axis.id] = position - Number(needSpace) * axisSize.height;
669
+ position += (needSpace ? -1 : 1) * axisSize.height;
670
+ });
671
+ return steps;
511
672
  });
512
- function Ct(e, t) {
513
- let n = d(e), r = w(e, t);
514
- if (r == null) return;
515
- let i = xt(e, r.orientation, r.mirror)[t];
516
- return i == null ? {
517
- x: n.left,
673
+ var selectAllYAxesOffsetSteps = createSelector(selectChartWidth, selectChartOffset, selectAllYAxesWithOffsetType, pickAxisOrientation, pickMirror, (chartWidth, offset, allAxesWithSameOffsetType, orientation, mirror) => {
674
+ const steps = {};
675
+ let position;
676
+ allAxesWithSameOffsetType.forEach((axis) => {
677
+ const axisSize = getYAxisSize(offset, axis);
678
+ if (position == null) position = combineYAxisPositionStartingPoint(offset, orientation, chartWidth);
679
+ const needSpace = orientation === "left" && !mirror || orientation === "right" && mirror;
680
+ steps[axis.id] = position - Number(needSpace) * axisSize.width;
681
+ position += (needSpace ? -1 : 1) * axisSize.width;
682
+ });
683
+ return steps;
684
+ });
685
+ function selectXAxisPosition(state, axisId) {
686
+ const offset = selectChartOffset(state);
687
+ const axisSettings = selectXAxisSettings(state, axisId);
688
+ if (axisSettings == null) return;
689
+ const stepOfThisAxis = selectAllXAxesOffsetSteps(state, axisSettings.orientation, axisSettings.mirror)[axisId];
690
+ if (stepOfThisAxis == null) return {
691
+ x: offset.left,
518
692
  y: 0
519
- } : {
520
- x: n.left,
521
- y: i
693
+ };
694
+ return {
695
+ x: offset.left,
696
+ y: stepOfThisAxis
522
697
  };
523
698
  }
524
- function wt(e, t) {
525
- let n = d(e), r = T(e, t);
526
- if (r == null) return;
527
- let i = St(e, r.orientation, r.mirror)[t];
528
- return i == null ? {
699
+ function selectYAxisPosition(state, axisId) {
700
+ const offset = selectChartOffset(state);
701
+ const axisSettings = selectYAxisSettings(state, axisId);
702
+ if (axisSettings == null) return;
703
+ const stepOfThisAxis = selectAllYAxesOffsetSteps(state, axisSettings.orientation, axisSettings.mirror)[axisId];
704
+ if (stepOfThisAxis == null) return {
529
705
  x: 0,
530
- y: n.top
531
- } : {
532
- x: i,
533
- y: n.top
706
+ y: offset.top
707
+ };
708
+ return {
709
+ x: stepOfThisAxis,
710
+ y: offset.top
534
711
  };
535
712
  }
536
- var Tt = x(d, T, (e, t) => ({
537
- width: t.width,
538
- height: e.height
539
- }));
540
- function Et(e, t, n) {
541
- switch (t) {
542
- case "xAxis": return vt(e, n).width;
543
- case "yAxis": return Tt(e, n).height;
713
+ var selectYAxisSize = createSelector(selectChartOffset, selectYAxisSettings, (offset, axisSettings) => {
714
+ return {
715
+ width: axisSettings.width,
716
+ height: offset.height
717
+ };
718
+ });
719
+ function selectCartesianAxisSize(state, axisType, axisId) {
720
+ switch (axisType) {
721
+ case "xAxis": return selectXAxisSize(state, axisId).width;
722
+ case "yAxis": return selectYAxisSize(state, axisId).height;
544
723
  default: return;
545
724
  }
546
725
  }
547
- function Dt(t, n, r, i) {
548
- if (r == null) return;
549
- let { allowDuplicatedCategory: a, type: o, dataKey: s } = r, c = e(t, i), l = n.map((e) => e.value);
550
- if (s && c && o === "category" && a && ne(l)) return l;
551
- }
552
- var Z = x([
553
- _,
554
- L,
555
- D,
556
- v
557
- ], Dt);
558
- function Ot(t, n, r, i) {
559
- if (r == null || r.dataKey == null) return;
560
- let { type: a, scale: o } = r;
561
- if (e(t, i) && (a === "number" || o !== "auto")) return n.map((e) => e.value);
562
- }
563
- var Q = x([
564
- _,
565
- L,
566
- O,
567
- v
568
- ], Ot), kt = x([
569
- _,
570
- xe,
571
- W,
572
- J,
573
- Z,
574
- Q,
575
- q,
576
- K,
577
- v
578
- ], (t, n, r, i, a, o, s, c, l) => {
579
- if (n == null) return null;
580
- let u = e(t, l);
726
+ function combineDuplicateDomain(chartLayout, appliedValues, axis, axisType) {
727
+ if (axis == null) return;
728
+ const { allowDuplicatedCategory, type, dataKey } = axis;
729
+ const isCategorical = isCategoricalAxis(chartLayout, axisType);
730
+ const allData = appliedValues.map((av) => av.value);
731
+ if (dataKey && isCategorical && type === "category" && allowDuplicatedCategory && hasDuplicate(allData)) return allData;
732
+ }
733
+ var selectDuplicateDomain = createSelector([
734
+ selectChartLayout,
735
+ selectAllAppliedValues,
736
+ selectBaseAxis,
737
+ pickAxisType
738
+ ], combineDuplicateDomain);
739
+ function combineCategoricalDomain(layout, appliedValues, axis, axisType) {
740
+ if (axis == null || axis.dataKey == null) return;
741
+ const { type, scale } = axis;
742
+ if (isCategoricalAxis(layout, axisType) && (type === "number" || scale !== "auto")) return appliedValues.map((d) => d.value);
743
+ }
744
+ var selectCategoricalDomain = createSelector([
745
+ selectChartLayout,
746
+ selectAllAppliedValues,
747
+ selectAxisSettings,
748
+ pickAxisType
749
+ ], combineCategoricalDomain);
750
+ var selectAxisPropsNeededForCartesianGridTicksGenerator = createSelector([
751
+ selectChartLayout,
752
+ selectCartesianAxisSettings,
753
+ selectRealScaleType,
754
+ selectAxisScale,
755
+ selectDuplicateDomain,
756
+ selectCategoricalDomain,
757
+ selectAxisRange,
758
+ selectNiceTicks,
759
+ pickAxisType
760
+ ], (layout, axis, realScaleType, scale, duplicateDomain, categoricalDomain, axisRange, niceTicks, axisType) => {
761
+ if (axis == null) return null;
762
+ const isCategorical = isCategoricalAxis(layout, axisType);
581
763
  return {
582
- angle: n.angle,
583
- interval: n.interval,
584
- minTickGap: n.minTickGap,
585
- orientation: n.orientation,
586
- tick: n.tick,
587
- tickCount: n.tickCount,
588
- tickFormatter: n.tickFormatter,
589
- ticks: n.ticks,
590
- type: n.type,
591
- unit: n.unit,
592
- axisType: l,
593
- categoricalDomain: o,
594
- duplicateDomain: a,
595
- isCategorical: u,
596
- niceTicks: c,
597
- range: s,
598
- realScaleType: r,
599
- scale: i
764
+ angle: axis.angle,
765
+ interval: axis.interval,
766
+ minTickGap: axis.minTickGap,
767
+ orientation: axis.orientation,
768
+ tick: axis.tick,
769
+ tickCount: axis.tickCount,
770
+ tickFormatter: axis.tickFormatter,
771
+ ticks: axis.ticks,
772
+ type: axis.type,
773
+ unit: axis.unit,
774
+ axisType,
775
+ categoricalDomain,
776
+ duplicateDomain,
777
+ isCategorical,
778
+ niceTicks,
779
+ range: axisRange,
780
+ realScaleType,
781
+ scale
600
782
  };
601
783
  });
602
- function At(n, r, i, a, o, s, c, l, u) {
603
- if (r == null || a == null) return;
604
- let d = e(n, u), { type: f, ticks: p, tickCount: ee } = r, m = i === "scaleBand" ? a.bandwidth() / 2 : 2, h = f === "category" && a.bandwidth ? a.bandwidth() / m : 0;
605
- h = u === "angleAxis" && s?.length >= 2 ? re(s[0] - s[1]) * 2 * h : h;
606
- let g = p || o;
607
- return g ? g.map((e, t) => ({
608
- index: t,
609
- coordinate: a(c ? c.indexOf(e) : e) + h,
610
- value: e,
611
- offset: h
612
- })).filter((e) => !t(e.coordinate)) : d && l ? l.map((e, t) => ({
613
- coordinate: a(e) + h,
614
- value: e,
615
- index: t,
616
- offset: h
617
- })) : a.ticks ? a.ticks(ee).map((e) => ({
618
- coordinate: a(e) + h,
619
- value: e,
620
- offset: h
621
- })) : a.domain().map((e, t) => ({
622
- coordinate: a(e) + h,
623
- value: c ? c[e] : e,
624
- index: t,
625
- offset: h
784
+ function combineAxisTicks(layout, axis, realScaleType, scale, niceTicks, axisRange, duplicateDomain, categoricalDomain, axisType) {
785
+ if (axis == null || scale == null) return;
786
+ const isCategorical = isCategoricalAxis(layout, axisType);
787
+ const { type, ticks, tickCount } = axis;
788
+ const offsetForBand = realScaleType === "scaleBand" ? scale.bandwidth() / 2 : 2;
789
+ let offset = type === "category" && scale.bandwidth ? scale.bandwidth() / offsetForBand : 0;
790
+ offset = axisType === "angleAxis" && axisRange?.length >= 2 ? mathSign(axisRange[0] - axisRange[1]) * 2 * offset : offset;
791
+ const ticksOrNiceTicks = ticks || niceTicks;
792
+ if (ticksOrNiceTicks) return ticksOrNiceTicks.map((entry, index) => {
793
+ return {
794
+ index,
795
+ coordinate: scale(duplicateDomain ? duplicateDomain.indexOf(entry) : entry) + offset,
796
+ value: entry,
797
+ offset
798
+ };
799
+ }).filter((row) => !isNan(row.coordinate));
800
+ if (isCategorical && categoricalDomain) return categoricalDomain.map((entry, index) => ({
801
+ coordinate: scale(entry) + offset,
802
+ value: entry,
803
+ index,
804
+ offset
805
+ }));
806
+ if (scale.ticks) return scale.ticks(tickCount).map((entry) => ({
807
+ coordinate: scale(entry) + offset,
808
+ value: entry,
809
+ offset
810
+ }));
811
+ return scale.domain().map((entry, index) => ({
812
+ coordinate: scale(entry) + offset,
813
+ value: duplicateDomain ? duplicateDomain[entry] : entry,
814
+ index,
815
+ offset
626
816
  }));
627
817
  }
628
- var jt = x([
629
- _,
630
- O,
631
- W,
632
- J,
633
- K,
634
- q,
635
- Z,
636
- Q,
637
- v
638
- ], At);
639
- function $(t, n, r, i, a, o, s) {
640
- if (n == null || r == null || i == null || i[0] === i[1]) return null;
641
- let c = e(t, s), { tickCount: l } = n, u = 0;
642
- return u = s === "angleAxis" && i?.length >= 2 ? re(i[0] - i[1]) * 2 * u : u, c && o ? o.map((e, t) => ({
643
- coordinate: r(e) + u,
644
- value: e,
645
- index: t,
646
- offset: u
647
- })) : r.ticks ? r.ticks(l).map((e) => ({
648
- coordinate: r(e) + u,
649
- value: e,
650
- offset: u
651
- })) : r.domain().map((e, t) => ({
652
- coordinate: r(e) + u,
653
- value: a ? a[e] : e,
654
- index: t,
655
- offset: u
818
+ var selectTicksOfAxis = createSelector([
819
+ selectChartLayout,
820
+ selectAxisSettings,
821
+ selectRealScaleType,
822
+ selectAxisScale,
823
+ selectNiceTicks,
824
+ selectAxisRange,
825
+ selectDuplicateDomain,
826
+ selectCategoricalDomain,
827
+ pickAxisType
828
+ ], combineAxisTicks);
829
+ var selectAxisInverseTickSnapScale = createSelector([selectTicksOfAxis], (ticks) => {
830
+ if (!ticks || ticks.length === 0) return;
831
+ return (pixelValue) => {
832
+ let minDistance = Infinity;
833
+ let closestTick = ticks[0];
834
+ for (const tick of ticks) {
835
+ const distance = Math.abs(tick.coordinate - pixelValue);
836
+ if (distance < minDistance) {
837
+ minDistance = distance;
838
+ closestTick = tick;
839
+ }
840
+ }
841
+ return closestTick?.value;
842
+ };
843
+ });
844
+ function combineGraphicalItemTicks(layout, axis, scale, axisRange, duplicateDomain, categoricalDomain, axisType) {
845
+ if (axis == null || scale == null || axisRange == null || axisRange[0] === axisRange[1]) return null;
846
+ const isCategorical = isCategoricalAxis(layout, axisType);
847
+ const { tickCount } = axis;
848
+ let offset = 0;
849
+ offset = axisType === "angleAxis" && axisRange?.length >= 2 ? mathSign(axisRange[0] - axisRange[1]) * 2 * offset : offset;
850
+ if (isCategorical && categoricalDomain) return categoricalDomain.map((entry, index) => ({
851
+ coordinate: scale(entry) + offset,
852
+ value: entry,
853
+ index,
854
+ offset
855
+ }));
856
+ if (scale.ticks) return scale.ticks(tickCount).map((entry) => ({
857
+ coordinate: scale(entry) + offset,
858
+ value: entry,
859
+ offset
860
+ }));
861
+ return scale.domain().map((entry, index) => ({
862
+ coordinate: scale(entry) + offset,
863
+ value: duplicateDomain ? duplicateDomain[entry] : entry,
864
+ index,
865
+ offset
656
866
  }));
657
867
  }
658
- var Mt = x([
659
- _,
660
- O,
661
- J,
662
- q,
663
- Z,
664
- Q,
665
- v
666
- ], $), Nt = x(D, J, (e, t) => {
667
- if (!(e == null || t == null)) return {
668
- ...e,
669
- scale: t
868
+ var selectTicksOfGraphicalItem = createSelector([
869
+ selectChartLayout,
870
+ selectAxisSettings,
871
+ selectAxisScale,
872
+ selectAxisRange,
873
+ selectDuplicateDomain,
874
+ selectCategoricalDomain,
875
+ pickAxisType
876
+ ], combineGraphicalItemTicks);
877
+ var selectAxisWithScale = createSelector(selectBaseAxis, selectAxisScale, (axis, scale) => {
878
+ if (axis == null || scale == null) return;
879
+ return {
880
+ ...axis,
881
+ scale
670
882
  };
671
- }), Pt = x((e, t, n) => E(e, n), x([
672
- D,
673
- W,
674
- U,
675
- ft
676
- ], G), (e, t) => {
677
- if (!(e == null || t == null)) return {
678
- ...e,
679
- scale: t
883
+ });
884
+ var selectZAxisWithScale = createSelector((state, _axisType, axisId) => selectZAxisSettings(state, axisId), createSelector([
885
+ selectBaseAxis,
886
+ selectRealScaleType,
887
+ selectAxisDomain,
888
+ selectAxisRangeWithReverse
889
+ ], combineScaleFunction), (axis, scale) => {
890
+ if (axis == null || scale == null) return;
891
+ return {
892
+ ...axis,
893
+ scale
680
894
  };
681
- }), Ft = x([
682
- _,
683
- l,
684
- u
685
- ], (e, t, n) => {
686
- switch (e) {
687
- case "horizontal": return t.some((e) => e.reversed) ? "right-to-left" : "left-to-right";
688
- case "vertical": return n.some((e) => e.reversed) ? "bottom-to-top" : "top-to-bottom";
895
+ });
896
+ var selectChartDirection = createSelector([
897
+ selectChartLayout,
898
+ selectAllXAxes,
899
+ selectAllYAxes
900
+ ], (layout, allXAxes, allYAxes) => {
901
+ switch (layout) {
902
+ case "horizontal": return allXAxes.some((axis) => axis.reversed) ? "right-to-left" : "left-to-right";
903
+ case "vertical": return allYAxes.some((axis) => axis.reversed) ? "bottom-to-top" : "top-to-bottom";
689
904
  default: return;
690
905
  }
691
906
  });
692
907
  //#endregion
693
- export { Ne as combineAppliedNumericalValuesIncludingErrorValues, Ee as combineAppliedValues, Ge as combineAreasDomain, $e as combineAxisDomain, rt as combineAxisDomainWithNiceTicks, At as combineAxisTicks, Ot as combineCategoricalDomain, Te as combineDisplayedData, je as combineDomainOfStackGroups, H as combineDotsDomain, Dt as combineDuplicateDomain, $ as combineGraphicalItemTicks, F as combineGraphicalItemsData, M as combineGraphicalItemsSettings, qe as combineLinesDomain, nt as combineNiceTicks, Xe as combineNumericalDomain, et as combineRealScaleType, G as combineScaleFunction, ke as combineStackGroups, P as filterGraphicalNotStackedItems, V as filterReferenceElements, z as getDomainDefinition, ve as implicitXAxis, ye as implicitYAxis, be as implicitZAxis, A as itemAxisPredicate, B as mergeDomains, kt as selectAxisPropsNeededForCartesianGridTicksGenerator, q as selectAxisRange, J as selectAxisScale, O as selectAxisSettings, Nt as selectAxisWithScale, D as selectBaseAxis, Et as selectCartesianAxisSize, Ft as selectChartDirection, Ye as selectDomainDefinition, Z as selectDuplicateDomain, k as selectHasBar, W as selectRealScaleType, Be as selectReferenceAreas, Re as selectReferenceDots, He as selectReferenceLines, Ae as selectStackGroups, jt as selectTicksOfAxis, Mt as selectTicksOfGraphicalItem, j as selectUnfilteredCartesianItems, Ct as selectXAxisPosition, w as selectXAxisSettings, vt as selectXAxisSize, wt as selectYAxisPosition, T as selectYAxisSettings, Tt as selectYAxisSize, Pt as selectZAxisWithScale };
908
+ export { combineAppliedNumericalValuesIncludingErrorValues, combineAppliedValues, combineAreasDomain, combineAxisDomain, combineAxisDomainWithNiceTicks, combineAxisTicks, combineCategoricalDomain, combineDisplayedData, combineDomainOfStackGroups, combineDotsDomain, combineDuplicateDomain, combineGraphicalItemTicks, combineGraphicalItemsData, combineGraphicalItemsSettings, combineLinesDomain, combineNiceTicks, combineNumericalDomain, combineRealScaleType, combineScaleFunction, combineStackGroups, filterGraphicalNotStackedItems, filterReferenceElements, getDomainDefinition, implicitXAxis, implicitYAxis, implicitZAxis, itemAxisPredicate, mergeDomains, selectAxisDomain, selectAxisInverseDataSnapScale, selectAxisInverseScale, selectAxisInverseTickSnapScale, selectAxisPropsNeededForCartesianGridTicksGenerator, selectAxisRange, selectAxisScale, selectAxisSettings, selectAxisWithScale, selectBaseAxis, selectCartesianAxisSize, selectChartDirection, selectDomainDefinition, selectDuplicateDomain, selectHasBar, selectRealScaleType, selectReferenceAreas, selectReferenceDots, selectReferenceLines, selectStackGroups, selectTicksOfAxis, selectTicksOfGraphicalItem, selectUnfilteredCartesianItems, selectXAxisPosition, selectXAxisSettings, selectXAxisSize, selectYAxisPosition, selectYAxisSettings, selectYAxisSize, selectZAxisWithScale };