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