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,178 +1,241 @@
1
- import { isNullish as e } from "../../utils/validate.mjs";
2
- import { selectChartDataWithIndexesIfNotInPanorama as t } from "./dataSelectors.mjs";
3
- import { selectChartOffset as n } from "./selectChartOffset.mjs";
4
- import { selectBarCategoryGap as r, selectBarGap as i, selectRootBarSize as a, selectRootMaxBarSize as o } from "./rootPropsSelectors.mjs";
5
- import { getPercentValue as s } from "../../utils/data.mjs";
6
- import { selectChartLayout as c } from "./common.mjs";
7
- import { getBandSizeOfAxis as l } from "../../utils/chart.mjs";
8
- import { selectAxisWithScale as u, selectCartesianAxisSize as d, selectStackGroups as f, selectTicksOfGraphicalItem as p, selectUnfilteredCartesianItems as m } from "./axisSelectors.mjs";
9
- import { computeBarRectangles as h } from "../../cartesian/bar/utils.mjs";
10
- import { createSelector as g } from "@reduxjs/toolkit";
1
+ import { isNullish } from "../../utils/validate.mjs";
2
+ import { selectChartDataWithIndexesIfNotInPanorama } from "./dataSelectors.mjs";
3
+ import { selectChartOffset } from "./selectChartOffset.mjs";
4
+ import { selectBarCategoryGap, selectBarGap, selectRootBarSize, selectRootMaxBarSize } from "./rootPropsSelectors.mjs";
5
+ import { getPercentValue } from "../../utils/data.mjs";
6
+ import { selectChartLayout } from "./common.mjs";
7
+ import { getBandSizeOfAxis } from "../../utils/chart.mjs";
8
+ import { selectAxisWithScale, selectCartesianAxisSize, selectStackGroups, selectTicksOfGraphicalItem, selectUnfilteredCartesianItems } from "./axisSelectors.mjs";
9
+ import { computeBarRectangles } from "../../cartesian/bar/utils.mjs";
10
+ import { createSelector } from "@reduxjs/toolkit";
11
11
  //#region src/state/selectors/barSelectors.ts
12
- var _ = (e, t) => t, v = (e, t, n) => n;
13
- function y(e, t, n, r) {
14
- return r;
15
- }
16
- function b(e, t, n, r, i) {
17
- return i;
18
- }
19
- function x(e, t, n, r, i) {
20
- return i.maxBarSize;
21
- }
22
- function S(t, n, r) {
23
- let i = r ?? t;
24
- return e(i) ? void 0 : s(i, n, 0);
25
- }
26
- var C = g([
27
- c,
28
- m,
29
- _,
30
- v,
31
- y
32
- ], (e, t, n, r, i) => t.filter((t) => e === "horizontal" ? t.xAxisId === n : t.yAxisId === r).filter((e) => e.isPanorama === i).filter((e) => e.hide === !1).filter((e) => e.type === "bar"));
33
- function w(e, t, n, r) {
34
- return c(e) === "horizontal" ? f(e, "yAxis", n, r) : f(e, "xAxis", t, r);
35
- }
36
- function T(e, t, n) {
37
- return c(e) === "horizontal" ? d(e, "xAxis", t) : d(e, "yAxis", n);
38
- }
39
- function E(e, t, n) {
40
- let r = {}, i = e.filter((e) => e.stackId != null), a = e.filter((e) => e.stackId == null), o = i.reduce((e, t) => (e[t.stackId] || (e[t.stackId] = []), e[t.stackId].push(t), e), r), s = Object.entries(o).map(([e, r]) => ({
41
- stackId: e,
42
- dataKeys: r.map((e) => e.dataKey),
43
- barSize: S(t, n, r[0].barSize)
44
- })), c = a.map((e) => ({
45
- stackId: void 0,
46
- dataKeys: [e.dataKey],
47
- barSize: S(t, n, e.barSize)
48
- }));
49
- return [...s, ...c];
50
- }
51
- var D = g([
52
- C,
53
- a,
54
- T
55
- ], E);
56
- function O(t, n, r, i, a) {
57
- let s = c(t), d = o(t), { maxBarSize: f } = a, m = e(f) ? d : f, h, g;
58
- return s === "horizontal" ? (h = u(t, "xAxis", n, i), g = p(t, "xAxis", n, i)) : (h = u(t, "yAxis", r, i), g = p(t, "yAxis", r, i)), l(h, g, !0) ?? m ?? 0;
59
- }
60
- function k(e, t, n, r) {
61
- let i = c(e), a, o;
62
- return i === "horizontal" ? (a = u(e, "xAxis", t, r), o = p(e, "xAxis", t, r)) : (a = u(e, "yAxis", n, r), o = p(e, "yAxis", n, r)), l(a, o);
63
- }
64
- function A(e, t, n, r, i) {
65
- let a = r.length;
66
- if (a < 1) return null;
67
- let o = s(e, n, 0, !0), c, l = [];
68
- if (r[0].barSize === +r[0].barSize) {
69
- let e = !1, t = n / a, i = r.reduce((e, t) => e + t.barSize || 0, 0);
70
- i += (a - 1) * o, i >= n && (i -= (a - 1) * o, o = 0), i >= n && t > 0 && (e = !0, t *= .9, i = a * t);
71
- let s = {
72
- offset: ((n - i) / 2 >> 0) - o,
12
+ var pickXAxisId = (_state, xAxisId) => xAxisId;
13
+ var pickYAxisId = (_state, _xAxisId, yAxisId) => yAxisId;
14
+ function pickIsPanorama(_state, _xAxisId, _yAxisId, isPanorama) {
15
+ return isPanorama;
16
+ }
17
+ function pickBarSettings(_state, _xAxisId, _yAxisId, _isPanorama, barSettings) {
18
+ return barSettings;
19
+ }
20
+ function pickMaxBarSize(_state, _xAxisId, _yAxisId, _isPanorama, barSettings) {
21
+ return barSettings.maxBarSize;
22
+ }
23
+ function getBarSize(globalSize, totalSize, selfSize) {
24
+ const barSize = selfSize ?? globalSize;
25
+ return isNullish(barSize) ? void 0 : getPercentValue(barSize, totalSize, 0);
26
+ }
27
+ var selectAllVisibleBars = createSelector([
28
+ selectChartLayout,
29
+ selectUnfilteredCartesianItems,
30
+ pickXAxisId,
31
+ pickYAxisId,
32
+ pickIsPanorama
33
+ ], (layout, allItems, xAxisId, yAxisId, isPanorama) => allItems.filter((i) => {
34
+ if (layout === "horizontal") return i.xAxisId === xAxisId;
35
+ return i.yAxisId === yAxisId;
36
+ }).filter((i) => i.isPanorama === isPanorama).filter((i) => i.hide === false).filter((i) => i.type === "bar"));
37
+ function selectBarStackGroups(state, xAxisId, yAxisId, isPanorama) {
38
+ if (selectChartLayout(state) === "horizontal") return selectStackGroups(state, "yAxis", yAxisId, isPanorama);
39
+ return selectStackGroups(state, "xAxis", xAxisId, isPanorama);
40
+ }
41
+ function selectBarCartesianAxisSize(state, xAxisId, yAxisId) {
42
+ if (selectChartLayout(state) === "horizontal") return selectCartesianAxisSize(state, "xAxis", xAxisId);
43
+ return selectCartesianAxisSize(state, "yAxis", yAxisId);
44
+ }
45
+ function combineBarSizeList(allBars, globalSize, totalSize) {
46
+ const initialValue = {};
47
+ const stackedBars = allBars.filter((b) => b.stackId != null);
48
+ const unstackedBars = allBars.filter((b) => b.stackId == null);
49
+ const groupByStack = stackedBars.reduce((acc, bar) => {
50
+ if (!acc[bar.stackId]) acc[bar.stackId] = [];
51
+ acc[bar.stackId].push(bar);
52
+ return acc;
53
+ }, initialValue);
54
+ const stackedSizeList = Object.entries(groupByStack).map(([stackId, bars]) => {
55
+ return {
56
+ stackId,
57
+ dataKeys: bars.map((b) => b.dataKey),
58
+ barSize: getBarSize(globalSize, totalSize, bars[0].barSize)
59
+ };
60
+ });
61
+ const unstackedSizeList = unstackedBars.map((b) => {
62
+ return {
63
+ stackId: void 0,
64
+ dataKeys: [b.dataKey],
65
+ barSize: getBarSize(globalSize, totalSize, b.barSize)
66
+ };
67
+ });
68
+ return [...stackedSizeList, ...unstackedSizeList];
69
+ }
70
+ var selectBarSizeList = createSelector([
71
+ selectAllVisibleBars,
72
+ selectRootBarSize,
73
+ selectBarCartesianAxisSize
74
+ ], combineBarSizeList);
75
+ function selectBarBandSize(state, xAxisId, yAxisId, isPanorama, barSettings) {
76
+ const layout = selectChartLayout(state);
77
+ const globalMaxBarSize = selectRootMaxBarSize(state);
78
+ const { maxBarSize: childMaxBarSize } = barSettings;
79
+ const maxBarSize = isNullish(childMaxBarSize) ? globalMaxBarSize : childMaxBarSize;
80
+ let axis, ticks;
81
+ if (layout === "horizontal") {
82
+ axis = selectAxisWithScale(state, "xAxis", xAxisId, isPanorama);
83
+ ticks = selectTicksOfGraphicalItem(state, "xAxis", xAxisId, isPanorama);
84
+ } else {
85
+ axis = selectAxisWithScale(state, "yAxis", yAxisId, isPanorama);
86
+ ticks = selectTicksOfGraphicalItem(state, "yAxis", yAxisId, isPanorama);
87
+ }
88
+ return getBandSizeOfAxis(axis, ticks, true) ?? maxBarSize ?? 0;
89
+ }
90
+ function selectAxisBandSize(state, xAxisId, yAxisId, isPanorama) {
91
+ const layout = selectChartLayout(state);
92
+ let axis, ticks;
93
+ if (layout === "horizontal") {
94
+ axis = selectAxisWithScale(state, "xAxis", xAxisId, isPanorama);
95
+ ticks = selectTicksOfGraphicalItem(state, "xAxis", xAxisId, isPanorama);
96
+ } else {
97
+ axis = selectAxisWithScale(state, "yAxis", yAxisId, isPanorama);
98
+ ticks = selectTicksOfGraphicalItem(state, "yAxis", yAxisId, isPanorama);
99
+ }
100
+ return getBandSizeOfAxis(axis, ticks);
101
+ }
102
+ function getBarPositions(barGap, barCategoryGap, bandSize, sizeList, maxBarSize) {
103
+ const len = sizeList.length;
104
+ if (len < 1) return null;
105
+ let realBarGap = getPercentValue(barGap, bandSize, 0, true);
106
+ let result;
107
+ const initialValue = [];
108
+ if (sizeList[0].barSize === +sizeList[0].barSize) {
109
+ let useFull = false;
110
+ let fullBarSize = bandSize / len;
111
+ let sum = sizeList.reduce((res, entry) => res + entry.barSize || 0, 0);
112
+ sum += (len - 1) * realBarGap;
113
+ if (sum >= bandSize) {
114
+ sum -= (len - 1) * realBarGap;
115
+ realBarGap = 0;
116
+ }
117
+ if (sum >= bandSize && fullBarSize > 0) {
118
+ useFull = true;
119
+ fullBarSize *= .9;
120
+ sum = len * fullBarSize;
121
+ }
122
+ let prev = {
123
+ offset: ((bandSize - sum) / 2 >> 0) - realBarGap,
73
124
  size: 0
74
125
  };
75
- c = r.reduce((n, r) => {
76
- let i = {
77
- stackId: r.stackId,
78
- dataKeys: r.dataKeys,
126
+ result = sizeList.reduce((res, entry) => {
127
+ const newPosition = {
128
+ stackId: entry.stackId,
129
+ dataKeys: entry.dataKeys,
79
130
  position: {
80
- offset: s.offset + s.size + o,
81
- size: e ? t : r.barSize
131
+ offset: prev.offset + prev.size + realBarGap,
132
+ size: useFull ? fullBarSize : entry.barSize
82
133
  }
83
- }, a = [...n, i];
84
- return s = a[a.length - 1].position, a;
85
- }, l);
134
+ };
135
+ const newRes = [...res, newPosition];
136
+ prev = newRes[newRes.length - 1].position;
137
+ return newRes;
138
+ }, initialValue);
86
139
  } else {
87
- let e = s(t, n, 0, !0);
88
- n - 2 * e - (a - 1) * o <= 0 && (o = 0);
89
- let u = (n - 2 * e - (a - 1) * o) / a;
90
- u > 1 && (u >>= 0);
91
- let d = i === +i ? Math.min(u, i) : u;
92
- c = r.reduce((t, n, r) => [...t, {
93
- stackId: n.stackId,
94
- dataKeys: n.dataKeys,
140
+ const offset = getPercentValue(barCategoryGap, bandSize, 0, true);
141
+ if (bandSize - 2 * offset - (len - 1) * realBarGap <= 0) realBarGap = 0;
142
+ let originalSize = (bandSize - 2 * offset - (len - 1) * realBarGap) / len;
143
+ if (originalSize > 1) originalSize >>= 0;
144
+ const size = maxBarSize === +maxBarSize ? Math.min(originalSize, maxBarSize) : originalSize;
145
+ result = sizeList.reduce((res, entry, i) => [...res, {
146
+ stackId: entry.stackId,
147
+ dataKeys: entry.dataKeys,
95
148
  position: {
96
- offset: e + (u + o) * r + (u - d) / 2,
97
- size: d
149
+ offset: offset + (originalSize + realBarGap) * i + (originalSize - size) / 2,
150
+ size
98
151
  }
99
- }], l);
152
+ }], initialValue);
100
153
  }
101
- return c;
154
+ return result;
102
155
  }
103
- function j(t, n, r, i, a, o, s) {
104
- let c = e(s) ? n : s, l = A(r, i, a === o ? o : a, t, c);
105
- return a !== o && l != null && (l = l.map((e) => ({
106
- ...e,
156
+ function combineAllBarPositions(sizeList, globalMaxBarSize, barGap, barCategoryGap, barBandSize, bandSize, childMaxBarSize) {
157
+ const maxBarSize = isNullish(childMaxBarSize) ? globalMaxBarSize : childMaxBarSize;
158
+ let allBarPositions = getBarPositions(barGap, barCategoryGap, barBandSize !== bandSize ? barBandSize : bandSize, sizeList, maxBarSize);
159
+ if (barBandSize !== bandSize && allBarPositions != null) allBarPositions = allBarPositions.map((pos) => ({
160
+ ...pos,
107
161
  position: {
108
- ...e.position,
109
- offset: e.position.offset - a / 2
162
+ ...pos.position,
163
+ offset: pos.position.offset - barBandSize / 2
110
164
  }
111
- }))), l;
112
- }
113
- var M = g([
114
- D,
115
- o,
116
- i,
117
- r,
118
- O,
119
- k,
120
- x
121
- ], j);
122
- function N(e, t, n, r) {
123
- return u(e, "xAxis", t, r);
124
- }
125
- function P(e, t, n, r) {
126
- return u(e, "yAxis", n, r);
127
- }
128
- function F(e, t, n, r) {
129
- return p(e, "xAxis", t, r);
130
- }
131
- function I(e, t, n, r) {
132
- return p(e, "yAxis", n, r);
133
- }
134
- var L = g([M, b], (e, t) => {
135
- if (e == null) return;
136
- let n = e.find((e) => e.stackId === t.stackId && e.dataKeys.includes(t.dataKey));
137
- if (n != null) return n.position;
165
+ }));
166
+ return allBarPositions;
167
+ }
168
+ var selectAllBarPositions = createSelector([
169
+ selectBarSizeList,
170
+ selectRootMaxBarSize,
171
+ selectBarGap,
172
+ selectBarCategoryGap,
173
+ selectBarBandSize,
174
+ selectAxisBandSize,
175
+ pickMaxBarSize
176
+ ], combineAllBarPositions);
177
+ function selectXAxisWithScale(state, xAxisId, _yAxisId, isPanorama) {
178
+ return selectAxisWithScale(state, "xAxis", xAxisId, isPanorama);
179
+ }
180
+ function selectYAxisWithScale(state, _xAxisId, yAxisId, isPanorama) {
181
+ return selectAxisWithScale(state, "yAxis", yAxisId, isPanorama);
182
+ }
183
+ function selectXAxisTicks(state, xAxisId, _yAxisId, isPanorama) {
184
+ return selectTicksOfGraphicalItem(state, "xAxis", xAxisId, isPanorama);
185
+ }
186
+ function selectYAxisTicks(state, _xAxisId, yAxisId, isPanorama) {
187
+ return selectTicksOfGraphicalItem(state, "yAxis", yAxisId, isPanorama);
188
+ }
189
+ var selectBarPosition = createSelector([selectAllBarPositions, pickBarSettings], (allBarPositions, barSettings) => {
190
+ if (allBarPositions == null) return;
191
+ const position = allBarPositions.find((p) => p.stackId === barSettings.stackId && p.dataKeys.includes(barSettings.dataKey));
192
+ if (position == null) return;
193
+ return position.position;
194
+ });
195
+ function combineStackedData(stackGroups, barSettings) {
196
+ if (!stackGroups || barSettings?.dataKey == null) return;
197
+ const { stackId } = barSettings;
198
+ const stackGroup = stackGroups[stackId];
199
+ if (!stackGroup) return;
200
+ const { stackedData } = stackGroup;
201
+ if (!stackedData) return;
202
+ return stackedData.find((sd) => sd.key === barSettings.dataKey);
203
+ }
204
+ var selectSynchronisedBarSettings = createSelector([selectUnfilteredCartesianItems, pickBarSettings], (graphicalItems, barSettingsFromProps) => {
205
+ if (graphicalItems.some((cgis) => cgis.type === "bar" && barSettingsFromProps.dataKey === cgis.dataKey && barSettingsFromProps.stackId === cgis.stackId && barSettingsFromProps.stackId === cgis.stackId)) return barSettingsFromProps;
138
206
  });
139
- function R(e, t) {
140
- if (!e || t?.dataKey == null) return;
141
- let { stackId: n } = t, r = e[n];
142
- if (!r) return;
143
- let { stackedData: i } = r;
144
- if (i) return i.find((e) => e.key === t.dataKey);
145
- }
146
- var z = g([m, b], (e, t) => {
147
- if (e.some((e) => e.type === "bar" && t.dataKey === e.dataKey && t.stackId === e.stackId && t.stackId === e.stackId)) return t;
148
- }), B = g([
149
- n,
150
- N,
151
- P,
152
- F,
153
- I,
154
- L,
155
- c,
156
- t,
157
- k,
158
- g([w, b], R),
159
- z
160
- ], (e, t, n, r, i, a, o, { chartData: s, dataStartIndex: c, dataEndIndex: l }, u, d, f) => {
161
- if (f == null || a == null || o !== "horizontal" && o !== "vertical" || t == null || n == null || r == null || i == null) return;
162
- let { data: p } = f, m;
163
- if (m = (p?.length ?? 0) > 0 ? p : s?.slice(c, l + 1), m != null) return h({
164
- layout: o,
165
- barSettings: f,
166
- pos: a,
167
- bandSize: u,
168
- xAxis: t,
169
- yAxis: n,
170
- xAxisTicks: r,
171
- yAxisTicks: i,
172
- stackedData: d,
173
- displayedData: m,
174
- offset: e
207
+ var selectBarRectangles = createSelector([
208
+ selectChartOffset,
209
+ selectXAxisWithScale,
210
+ selectYAxisWithScale,
211
+ selectXAxisTicks,
212
+ selectYAxisTicks,
213
+ selectBarPosition,
214
+ selectChartLayout,
215
+ selectChartDataWithIndexesIfNotInPanorama,
216
+ selectAxisBandSize,
217
+ createSelector([selectBarStackGroups, pickBarSettings], combineStackedData),
218
+ selectSynchronisedBarSettings
219
+ ], (offset, xAxis, yAxis, xAxisTicks, yAxisTicks, pos, layout, { chartData, dataStartIndex, dataEndIndex }, bandSize, stackedData, barSettings) => {
220
+ if (barSettings == null || pos == null || layout !== "horizontal" && layout !== "vertical" || xAxis == null || yAxis == null || xAxisTicks == null || yAxisTicks == null) return;
221
+ const { data } = barSettings;
222
+ let displayedData;
223
+ if ((data?.length ?? 0) > 0) displayedData = data;
224
+ else displayedData = chartData?.slice(dataStartIndex, dataEndIndex + 1);
225
+ if (displayedData == null) return;
226
+ return computeBarRectangles({
227
+ layout,
228
+ barSettings,
229
+ pos,
230
+ bandSize,
231
+ xAxis,
232
+ yAxis,
233
+ xAxisTicks,
234
+ yAxisTicks,
235
+ stackedData,
236
+ displayedData,
237
+ offset
175
238
  });
176
239
  });
177
240
  //#endregion
178
- export { j as combineAllBarPositions, E as combineBarSizeList, R as combineStackedData, B as selectBarRectangles };
241
+ export { combineAllBarPositions, combineBarSizeList, combineStackedData, selectBarRectangles };
@@ -1,17 +1,18 @@
1
- import { isNumber as e } from "../../utils/validate.mjs";
2
- import { selectMargin as t } from "./containerSelectors.mjs";
3
- import { selectChartOffset as n } from "./selectChartOffset.mjs";
4
- import { createSelector as r } from "@reduxjs/toolkit";
1
+ import { isNumber } from "../../utils/validate.mjs";
2
+ import { selectMargin } from "./containerSelectors.mjs";
3
+ import { selectChartOffset } from "./selectChartOffset.mjs";
4
+ import { createSelector } from "@reduxjs/toolkit";
5
5
  //#region src/state/selectors/brushSelectors.ts
6
- var i = (e) => e.brush, a = r([
7
- i,
8
- n,
9
- t
10
- ], (t, n, r) => ({
11
- height: t.height,
12
- x: e(t.x) ? t.x : n.left,
13
- y: e(t.y) ? t.y : n.top + n.height + n.brushBottom - (r?.bottom || 0),
14
- width: e(t.width) ? t.width : n.width
6
+ var selectBrushSettings = (state) => state.brush;
7
+ var selectBrushDimensions = createSelector([
8
+ selectBrushSettings,
9
+ selectChartOffset,
10
+ selectMargin
11
+ ], (brushSettings, offset, margin) => ({
12
+ height: brushSettings.height,
13
+ x: isNumber(brushSettings.x) ? brushSettings.x : offset.left,
14
+ y: isNumber(brushSettings.y) ? brushSettings.y : offset.top + offset.height + offset.brushBottom - (margin?.bottom || 0),
15
+ width: isNumber(brushSettings.width) ? brushSettings.width : offset.width
15
16
  }));
16
17
  //#endregion
17
- export { a as selectBrushDimensions, i as selectBrushSettings };
18
+ export { selectBrushDimensions, selectBrushSettings };
@@ -1,8 +1,9 @@
1
- import { isNan as e } from "../../../utils/validate.mjs";
1
+ import { isNan } from "../../../utils/validate.mjs";
2
2
  //#region src/state/selectors/combiners/combineActiveLabel.ts
3
- function t(t, n) {
4
- let r = Number(n);
5
- if (!(e(r) || n == null)) return r >= 0 ? t?.[r]?.value : void 0;
3
+ function combineActiveLabel(tooltipTicks, activeIndex) {
4
+ const n = Number(activeIndex);
5
+ if (isNan(n) || activeIndex == null) return;
6
+ return n >= 0 ? tooltipTicks?.[n]?.value : void 0;
6
7
  }
7
8
  //#endregion
8
- export { t as combineActiveLabel };
9
+ export { combineActiveLabel };
@@ -1,34 +1,43 @@
1
- import { isWellBehavedNumber as e } from "../../../utils/validate.mjs";
2
- import { getValueByDataKey as t } from "../../../utils/chart.mjs";
3
- import { isWellFormedNumberDomain as n } from "../../../utils/isDomainSpecifiedByUser.mjs";
1
+ import { isWellBehavedNumber } from "../../../utils/validate.mjs";
2
+ import { getValueByDataKey } from "../../../utils/chart.mjs";
3
+ import { isWellFormedNumberDomain } from "../../../utils/isDomainSpecifiedByUser.mjs";
4
4
  //#region src/state/selectors/combiners/combineActiveTooltipIndex.ts
5
- function r(e) {
6
- if (typeof e == "number") return Number.isFinite(e) ? e : void 0;
7
- if (e instanceof Date) {
8
- let t = e.valueOf();
9
- return Number.isFinite(t) ? t : void 0;
5
+ function toFiniteNumber(value) {
6
+ if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
7
+ if (value instanceof Date) {
8
+ const numericValue = value.valueOf();
9
+ return Number.isFinite(numericValue) ? numericValue : void 0;
10
10
  }
11
- let t = Number(e);
12
- return Number.isFinite(t) ? t : void 0;
11
+ const parsed = Number(value);
12
+ return Number.isFinite(parsed) ? parsed : void 0;
13
13
  }
14
- function i(e, t) {
15
- let n = r(e), i = t[0], a = t[1];
16
- return n === void 0 ? !1 : n >= Math.min(i, a) && n <= Math.max(i, a);
14
+ function isValueWithinNumberDomain(value, domain) {
15
+ const numericValue = toFiniteNumber(value);
16
+ const lowerBound = domain[0];
17
+ const upperBound = domain[1];
18
+ if (numericValue === void 0) return false;
19
+ return numericValue >= Math.min(lowerBound, upperBound) && numericValue <= Math.max(lowerBound, upperBound);
17
20
  }
18
- function a(e, r, a) {
19
- if (a == null || r == null) return !0;
20
- let o = t(e, r);
21
- return o == null || !n(a) ? !0 : i(o, a);
21
+ function isValueWithinDomain(entry, axisDataKey, domain) {
22
+ if (domain == null || axisDataKey == null) return true;
23
+ const value = getValueByDataKey(entry, axisDataKey);
24
+ if (value == null) return true;
25
+ if (!isWellFormedNumberDomain(domain)) return true;
26
+ return isValueWithinNumberDomain(value, domain);
22
27
  }
23
- function o(t, n, r, i) {
24
- let o = t?.index;
25
- if (o == null) return null;
26
- let s = Number(o);
27
- if (!e(s)) return o;
28
- let c = Infinity;
29
- n.length > 0 && (c = n.length - 1);
30
- let l = Math.max(0, Math.min(s, c)), u = n[l];
31
- return u == null || a(u, r, i) ? String(l) : null;
28
+ function combineActiveTooltipIndex(tooltipInteraction, chartData, axisDataKey, domain) {
29
+ const desiredIndex = tooltipInteraction?.index;
30
+ if (desiredIndex == null) return null;
31
+ const indexAsNumber = Number(desiredIndex);
32
+ if (!isWellBehavedNumber(indexAsNumber)) return desiredIndex;
33
+ const lowerLimit = 0;
34
+ let upperLimit = Infinity;
35
+ if (chartData.length > 0) upperLimit = chartData.length - 1;
36
+ const clampedIndex = Math.max(lowerLimit, Math.min(indexAsNumber, upperLimit));
37
+ const entry = chartData[clampedIndex];
38
+ if (entry == null) return String(clampedIndex);
39
+ if (!isValueWithinDomain(entry, axisDataKey, domain)) return null;
40
+ return String(clampedIndex);
32
41
  }
33
42
  //#endregion
34
- export { o as combineActiveTooltipIndex };
43
+ export { combineActiveTooltipIndex };
@@ -1,6 +1,8 @@
1
1
  //#region src/state/selectors/combiners/combineAxisRangeWithReverse.ts
2
- function e(e, t) {
3
- if (!(!e || !t)) return e?.reversed ? [t[1], t[0]] : t;
2
+ function combineAxisRangeWithReverse(axisSettings, axisRange) {
3
+ if (!axisSettings || !axisRange) return;
4
+ if (axisSettings?.reversed) return [axisRange[1], axisRange[0]];
5
+ return axisRange;
4
6
  }
5
7
  //#endregion
6
- export { e as combineAxisRangeWithReverse };
8
+ export { combineAxisRangeWithReverse };
@@ -1,19 +1,21 @@
1
1
  //#region src/state/selectors/combiners/combineCoordinateForDefaultIndex.ts
2
- function e(e, t, n, r, i, a, o, s) {
3
- if (a == null || r == null) return;
4
- let c = o[0], l = c == null ? void 0 : s?.(c.positions, a);
5
- if (l != null) return l;
6
- let u = i?.[Number(a)];
7
- if (u) switch (n) {
2
+ function combineCoordinateForDefaultIndex(width, height, layout, offset, tooltipTicks, defaultIndex, tooltipConfigurations, tooltipPayloadSearcher) {
3
+ if (defaultIndex == null || offset == null) return;
4
+ const firstConfiguration = tooltipConfigurations[0];
5
+ const maybePosition = firstConfiguration == null ? void 0 : tooltipPayloadSearcher?.(firstConfiguration.positions, defaultIndex);
6
+ if (maybePosition != null) return maybePosition;
7
+ const tick = tooltipTicks?.[Number(defaultIndex)];
8
+ if (!tick) return;
9
+ switch (layout) {
8
10
  case "horizontal": return {
9
- x: u.coordinate,
10
- y: (r.top + t) / 2
11
+ x: tick.coordinate,
12
+ y: (offset.top + height) / 2
11
13
  };
12
14
  default: return {
13
- x: (r.left + e) / 2,
14
- y: u.coordinate
15
+ x: (offset.left + width) / 2,
16
+ y: tick.coordinate
15
17
  };
16
18
  }
17
19
  }
18
20
  //#endregion
19
- export { e as combineCoordinateForDefaultIndex };
21
+ export { combineCoordinateForDefaultIndex };
@@ -1,32 +1,37 @@
1
- import { noInteraction as e } from "../../tooltipSlice.mjs";
1
+ import { noInteraction } from "../../tooltipSlice.mjs";
2
2
  //#region src/state/selectors/combiners/combineTooltipInteractionState.ts
3
- function t(e, t, n) {
4
- return t === "axis" ? n === "click" ? e.axisInteraction.click : e.axisInteraction.hover : n === "click" ? e.itemInteraction.click : e.itemInteraction.hover;
3
+ function chooseAppropriateMouseInteraction(tooltipState, tooltipEventType, trigger) {
4
+ if (tooltipEventType === "axis") {
5
+ if (trigger === "click") return tooltipState.axisInteraction.click;
6
+ return tooltipState.axisInteraction.hover;
7
+ }
8
+ if (trigger === "click") return tooltipState.itemInteraction.click;
9
+ return tooltipState.itemInteraction.hover;
5
10
  }
6
- function n(e) {
7
- return e.index != null;
11
+ function hasBeenActivePreviously(tooltipInteractionState) {
12
+ return tooltipInteractionState.index != null;
8
13
  }
9
- function r(r, i, a, o) {
10
- let s = t(r, i, a);
11
- if (s?.active) return s;
12
- if (r.keyboardInteraction.active) return r.keyboardInteraction;
13
- if (r.syncInteraction.active && r.syncInteraction.index != null) return r.syncInteraction;
14
- let c = r.settings.active === !0;
15
- if (n(s)) {
16
- if (c) return {
17
- ...s,
18
- active: !0
14
+ function combineTooltipInteractionState(tooltipState, tooltipEventType, trigger, defaultIndex) {
15
+ const appropriateMouseInteraction = chooseAppropriateMouseInteraction(tooltipState, tooltipEventType, trigger);
16
+ if (appropriateMouseInteraction?.active) return appropriateMouseInteraction;
17
+ if (tooltipState.keyboardInteraction.active) return tooltipState.keyboardInteraction;
18
+ if (tooltipState.syncInteraction.active && tooltipState.syncInteraction.index != null) return tooltipState.syncInteraction;
19
+ const activeFromProps = tooltipState.settings.active === true;
20
+ if (hasBeenActivePreviously(appropriateMouseInteraction)) {
21
+ if (activeFromProps) return {
22
+ ...appropriateMouseInteraction,
23
+ active: true
19
24
  };
20
- } else if (o != null) return {
21
- active: !0,
25
+ } else if (defaultIndex != null) return {
26
+ active: true,
22
27
  coordinate: void 0,
23
28
  dataKey: void 0,
24
- index: o
29
+ index: defaultIndex
25
30
  };
26
31
  return {
27
- ...e,
28
- coordinate: s?.coordinate
32
+ ...noInteraction,
33
+ coordinate: appropriateMouseInteraction?.coordinate
29
34
  };
30
35
  }
31
36
  //#endregion
32
- export { r as combineTooltipInteractionState };
37
+ export { combineTooltipInteractionState };