vccs 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/README.md +151 -0
  2. package/dist/animation/Animate.d.ts +1 -1
  3. package/dist/cartesian/area/type.d.ts +3 -3
  4. package/dist/cartesian/bar/type.d.ts +1 -13
  5. package/dist/cartesian/brush/components/Slide.d.ts +1 -1
  6. package/dist/cartesian/brush/components/TravellerLayer.d.ts +1 -1
  7. package/dist/cartesian/brush/type.d.ts +2 -1
  8. package/dist/cartesian/cartesian-axis/CartesianAxis.d.ts +2 -1
  9. package/dist/cartesian/funnel/Funnel.d.ts +2 -0
  10. package/dist/cartesian/funnel/index.d.ts +2 -0
  11. package/dist/cartesian/funnel/type.d.ts +74 -6
  12. package/dist/cartesian/index.d.ts +2 -0
  13. package/dist/cartesian/line/Line.d.ts +7 -13
  14. package/dist/cartesian/line/type.d.ts +4 -17
  15. package/dist/cartesian/reference-area/ReferenceArea.d.ts +16 -16
  16. package/dist/cartesian/reference-dot/ReferenceDot.d.ts +143 -0
  17. package/dist/cartesian/reference-dot/index.d.ts +2 -0
  18. package/dist/cartesian/reference-line/ReferenceLine.d.ts +8 -8
  19. package/dist/cartesian/scatter/Scatter.d.ts +1 -1
  20. package/dist/chart/FunnelChart.d.ts +1 -0
  21. package/dist/chart/RechartsWrapper.d.ts +7 -3
  22. package/dist/chart/Surface.d.ts +2 -1
  23. package/dist/chart/Treemap.d.ts +237 -0
  24. package/dist/chart/generateCategoricalChart.d.ts +2 -1
  25. package/dist/chart/index.d.ts +2 -0
  26. package/dist/chart/treemapUtils.d.ts +22 -0
  27. package/dist/components/Customized.d.ts +23 -0
  28. package/dist/components/Text.d.ts +4 -4
  29. package/dist/components/Tooltip.d.ts +1 -1
  30. package/dist/components/index.d.ts +2 -0
  31. package/dist/components/label/Label.d.ts +3 -3
  32. package/dist/components/label/types.d.ts +1 -1
  33. package/dist/container/Surface.d.ts +3 -2
  34. package/dist/es/animation/Animate.mjs +48 -22
  35. package/dist/es/cartesian/GraphicalItemClipPath.mjs +16 -15
  36. package/dist/es/cartesian/area/ActivePoints.mjs +44 -40
  37. package/dist/es/cartesian/area/Area.mjs +42 -31
  38. package/dist/es/cartesian/area/ClipRect.mjs +79 -58
  39. package/dist/es/cartesian/area/RenderArea.mjs +142 -108
  40. package/dist/es/cartesian/area/hooks/useArea.mjs +71 -47
  41. package/dist/es/cartesian/area/type.mjs +13 -15
  42. package/dist/es/cartesian/area/utils.mjs +69 -49
  43. package/dist/es/cartesian/axis/XAxis.mjs +87 -73
  44. package/dist/es/cartesian/axis/YAxis.mjs +67 -56
  45. package/dist/es/cartesian/bar/Bar.mjs +78 -71
  46. package/dist/es/cartesian/bar/components/BarBackground.mjs +22 -19
  47. package/dist/es/cartesian/bar/components/BarRectangles.mjs +117 -80
  48. package/dist/es/cartesian/bar/hooks/useBar.mjs +49 -37
  49. package/dist/es/cartesian/bar/type.mjs +11 -25
  50. package/dist/es/cartesian/bar/utils.mjs +97 -70
  51. package/dist/es/cartesian/cartesian-axis/CartesianAxis.mjs +165 -115
  52. package/dist/es/cartesian/cartesian-grid/Background.mjs +19 -16
  53. package/dist/es/cartesian/cartesian-grid/CartesianGrid.mjs +116 -97
  54. package/dist/es/cartesian/cartesian-grid/HorizontalGridLines.mjs +24 -23
  55. package/dist/es/cartesian/cartesian-grid/HorizontalStripes.mjs +24 -24
  56. package/dist/es/cartesian/cartesian-grid/VerticalGridLines.mjs +23 -22
  57. package/dist/es/cartesian/cartesian-grid/VerticalStripes.mjs +24 -24
  58. package/dist/es/cartesian/cartesian-grid/const.mjs +317 -10
  59. package/dist/es/cartesian/cartesian-grid/utils.mjs +18 -13
  60. package/dist/es/cartesian/error-bar/ErrorBar.mjs +111 -83
  61. package/dist/es/cartesian/error-bar/ErrorBarContext.mjs +13 -12
  62. package/dist/es/cartesian/funnel/Funnel.mjs +162 -0
  63. package/dist/es/cartesian/funnel/type.mjs +78 -0
  64. package/dist/es/cartesian/funnel/utils.mjs +102 -0
  65. package/dist/es/cartesian/line/ActivePoints.mjs +45 -41
  66. package/dist/es/cartesian/line/Line.mjs +41 -37
  67. package/dist/es/cartesian/line/StaticLine.mjs +191 -122
  68. package/dist/es/cartesian/line/hooks/useLine.mjs +60 -44
  69. package/dist/es/cartesian/line/type.mjs +13 -18
  70. package/dist/es/cartesian/line/utils.mjs +27 -26
  71. package/dist/es/cartesian/reference-area/ReferenceArea.mjs +79 -78
  72. package/dist/es/cartesian/reference-dot/ReferenceDot.mjs +134 -0
  73. package/dist/es/cartesian/reference-line/ReferenceLine.mjs +93 -84
  74. package/dist/es/cartesian/scatter/Scatter.mjs +168 -140
  75. package/dist/es/cartesian/scatter/hooks/useScatter.mjs +18 -14
  76. package/dist/es/cartesian/useNeedsClip.mjs +18 -9
  77. package/dist/es/cartesian/utils/get-ticks.mjs +103 -68
  78. package/dist/es/cartesian/z-axis/ZAxis.mjs +30 -28
  79. package/dist/es/chart/AreaChart.mjs +5 -5
  80. package/dist/es/chart/BarChart.mjs +5 -5
  81. package/dist/es/chart/ComposedChart.mjs +5 -5
  82. package/dist/es/chart/FunnelChart.mjs +11 -0
  83. package/dist/es/chart/LegendPortalContext.mjs +3 -3
  84. package/dist/es/chart/LineChart.mjs +5 -5
  85. package/dist/es/chart/PieChart.mjs +5 -5
  86. package/dist/es/chart/RadarChart.mjs +5 -5
  87. package/dist/es/chart/RadialBarChart.mjs +5 -5
  88. package/dist/es/chart/RechartsWrapper.mjs +113 -89
  89. package/dist/es/chart/ScatterChart.mjs +5 -5
  90. package/dist/es/chart/Surface.mjs +3 -3
  91. package/dist/es/chart/Surface.vue_vue_type_script_setup_true_lang.mjs +51 -45
  92. package/dist/es/chart/TooltipPortalContext.mjs +3 -3
  93. package/dist/es/chart/Treemap.mjs +379 -0
  94. package/dist/es/chart/const.mjs +2 -2
  95. package/dist/es/chart/generateCategoricalChart.mjs +99 -89
  96. package/dist/es/chart/provideClipPathId.mjs +12 -7
  97. package/dist/es/chart/treemapUtils.mjs +32 -0
  98. package/dist/es/components/Cell.mjs +16 -4
  99. package/dist/es/components/Customized.mjs +43 -0
  100. package/dist/es/components/Text.mjs +3 -3
  101. package/dist/es/components/Text.vue_vue_type_script_setup_true_lang.mjs +106 -69
  102. package/dist/es/components/Tooltip.mjs +274 -199
  103. package/dist/es/components/label/Label.mjs +30 -26
  104. package/dist/es/components/label/LabelList.mjs +45 -39
  105. package/dist/es/components/label/types.mjs +10 -6
  106. package/dist/es/components/label/utils.mjs +194 -162
  107. package/dist/es/components/legend/Legend.mjs +82 -71
  108. package/dist/es/components/legend/LegendSymbol.mjs +40 -38
  109. package/dist/es/components/legend/hooks/useLegend.mjs +71 -46
  110. package/dist/es/components/legend/hooks/useLegendContent.mjs +52 -31
  111. package/dist/es/components/legend/type.mjs +2 -2
  112. package/dist/es/components/legend/utils.mjs +19 -11
  113. package/dist/es/components/utils.mjs +35 -22
  114. package/dist/es/container/ClipPath.mjs +14 -14
  115. package/dist/es/container/Layer.mjs +9 -7
  116. package/dist/es/container/ResponsiveContainer.mjs +3 -3
  117. package/dist/es/container/ResponsiveContainer.vue_vue_type_script_setup_true_lang.mjs +109 -77
  118. package/dist/es/container/Surface.mjs +25 -23
  119. package/dist/es/container/useSizeContext.mjs +3 -3
  120. package/dist/es/context/ChartDataContextProvider.mjs +19 -13
  121. package/dist/es/context/PanoramaContextProvider.mjs +15 -10
  122. package/dist/es/context/accessibilityContext.mjs +3 -3
  123. package/dist/es/context/cartesianLabelListContext.mjs +3 -3
  124. package/dist/es/context/chartLayoutContext.mjs +33 -30
  125. package/dist/es/context/cursorLayerContext.mjs +3 -3
  126. package/dist/es/context/graphicalLayerContext.mjs +3 -3
  127. package/dist/es/context/labelLayerContext.mjs +3 -3
  128. package/dist/es/context/polarLabelViewBoxContext.mjs +5 -5
  129. package/dist/es/context/useTooltipAxis.mjs +14 -12
  130. package/dist/es/events/useChartSynchronisation.mjs +91 -66
  131. package/dist/es/hooks/publicHooks.mjs +207 -0
  132. package/dist/es/hooks/useIsAnimating.mjs +28 -0
  133. package/dist/es/hooks/useSetupGraphicalItem.mjs +52 -43
  134. package/dist/es/index.mjs +54 -42
  135. package/dist/es/polar/pie/Pie.mjs +131 -115
  136. package/dist/es/polar/pie/type.mjs +8 -10
  137. package/dist/es/polar/radar/PolarAngleAxis.mjs +103 -84
  138. package/dist/es/polar/radar/PolarGrid.mjs +72 -59
  139. package/dist/es/polar/radar/PolarRadiusAxis.mjs +90 -65
  140. package/dist/es/polar/radar/Radar.mjs +181 -145
  141. package/dist/es/polar/radial-bar/RadialBar.mjs +161 -140
  142. package/dist/es/polar/radial-bar/type.mjs +9 -9
  143. package/dist/es/shape/Cross.mjs +11 -10
  144. package/dist/es/shape/Curve.mjs +71 -44
  145. package/dist/es/shape/Dot.mjs +12 -11
  146. package/dist/es/shape/Polygon.mjs +19 -0
  147. package/dist/es/shape/Rectangle.mjs +41 -30
  148. package/dist/es/shape/Sector.mjs +105 -79
  149. package/dist/es/shape/Symbols.mjs +45 -34
  150. package/dist/es/shape/Trapezoid.mjs +50 -0
  151. package/dist/es/state/ReportChartProps.mjs +23 -24
  152. package/dist/es/state/ReportMainChartProps.mjs +26 -21
  153. package/dist/es/state/ReportPolarOptions.mjs +23 -22
  154. package/dist/es/state/SetGraphicalItem.mjs +42 -27
  155. package/dist/es/state/SetLegendPayload.mjs +17 -13
  156. package/dist/es/state/SetTooltipEntrySettings.mjs +14 -12
  157. package/dist/es/state/brushSlice.mjs +12 -8
  158. package/dist/es/state/cartesianAxisSlice.mjs +23 -17
  159. package/dist/es/state/chartDataSlice.mjs +18 -13
  160. package/dist/es/state/externalEventsMiddleware.mjs +25 -15
  161. package/dist/es/state/graphicalItemsSlice.mjs +29 -25
  162. package/dist/es/state/hooks.mjs +24 -3
  163. package/dist/es/state/keyboardEventsMiddleware.mjs +50 -42
  164. package/dist/es/state/layoutSlice.mjs +18 -12
  165. package/dist/es/state/legendSlice.mjs +19 -14
  166. package/dist/es/state/mouseEventsMiddleware.mjs +31 -24
  167. package/dist/es/state/optionsSlice.mjs +14 -11
  168. package/dist/es/state/polarAxisSlice.mjs +15 -13
  169. package/dist/es/state/polarOptionsSlice.mjs +8 -6
  170. package/dist/es/state/reduxDevtoolsJsonStringifyReplacer.mjs +5 -3
  171. package/dist/es/state/referenceElementsSlice.mjs +21 -19
  172. package/dist/es/state/rootPropsSlice.mjs +20 -9
  173. package/dist/es/state/selectors/areaSelectors.mjs +65 -55
  174. package/dist/es/state/selectors/axisSelectors.mjs +784 -569
  175. package/dist/es/state/selectors/barSelectors.mjs +225 -162
  176. package/dist/es/state/selectors/brushSelectors.mjs +15 -14
  177. package/dist/es/state/selectors/combiners/combineActiveLabel.mjs +6 -5
  178. package/dist/es/state/selectors/combiners/combineActiveTooltipIndex.mjs +36 -27
  179. package/dist/es/state/selectors/combiners/combineAxisRangeWithReverse.mjs +5 -3
  180. package/dist/es/state/selectors/combiners/combineCoordinateForDefaultIndex.mjs +13 -11
  181. package/dist/es/state/selectors/combiners/combineTooltipInteractionState.mjs +26 -21
  182. package/dist/es/state/selectors/combiners/combineTooltipPayloadConfigurations.mjs +10 -6
  183. package/dist/es/state/selectors/common.mjs +2 -2
  184. package/dist/es/state/selectors/containerSelectors.mjs +5 -2
  185. package/dist/es/state/selectors/dataSelectors.mjs +28 -9
  186. package/dist/es/state/selectors/funnelSelectors.mjs +38 -0
  187. package/dist/es/state/selectors/legendSelectors.mjs +7 -6
  188. package/dist/es/state/selectors/lineSelectors.mjs +54 -47
  189. package/dist/es/state/selectors/pickAxisId.mjs +2 -2
  190. package/dist/es/state/selectors/pickAxisType.mjs +2 -2
  191. package/dist/es/state/selectors/pieSelectors.mjs +116 -81
  192. package/dist/es/state/selectors/polarAxisSelectors.mjs +113 -94
  193. package/dist/es/state/selectors/polarGridSelectors.mjs +13 -11
  194. package/dist/es/state/selectors/polarScaleSelectors.mjs +49 -46
  195. package/dist/es/state/selectors/polarSelectors.mjs +79 -62
  196. package/dist/es/state/selectors/radarSelectors.mjs +111 -91
  197. package/dist/es/state/selectors/radialBarSelectors.mjs +230 -183
  198. package/dist/es/state/selectors/rootPropsSelectors.mjs +11 -5
  199. package/dist/es/state/selectors/scatterSelectors.mjs +111 -95
  200. package/dist/es/state/selectors/selectActivePropsFromChartPointer.mjs +19 -17
  201. package/dist/es/state/selectors/selectAllAxes.mjs +8 -3
  202. package/dist/es/state/selectors/selectChartOffset.mjs +59 -50
  203. package/dist/es/state/selectors/selectChartOffsetInternal.mjs +55 -44
  204. package/dist/es/state/selectors/selectTooltipEventType.mjs +15 -14
  205. package/dist/es/state/selectors/selectTooltipPayloadSearcher.mjs +3 -3
  206. package/dist/es/state/selectors/selectTooltipSettings.mjs +2 -2
  207. package/dist/es/state/selectors/selectTooltipState.mjs +2 -2
  208. package/dist/es/state/selectors/selectors.mjs +94 -75
  209. package/dist/es/state/selectors/tooltipSelectors.mjs +253 -204
  210. package/dist/es/state/selectors/touchSelectors.mjs +17 -14
  211. package/dist/es/state/store.mjs +46 -46
  212. package/dist/es/state/tooltipSlice.mjs +64 -37
  213. package/dist/es/state/touchEventsMiddleware.mjs +35 -29
  214. package/dist/es/state/utils/useReportScale.mjs +16 -13
  215. package/dist/es/synchronisation/syncSelectors.mjs +3 -3
  216. package/dist/es/synchronisation/useChartSynchronisation.mjs +33 -19
  217. package/dist/es/types/common.mjs +12 -0
  218. package/dist/es/types/event.mjs +164 -2
  219. package/dist/es/utils/ReduceCSSCalc.mjs +81 -49
  220. package/dist/es/utils/VueUtils.mjs +35 -14
  221. package/dist/es/utils/attrs.mjs +43 -26
  222. package/dist/es/utils/cartesian.mjs +47 -15
  223. package/dist/es/utils/cell.mjs +28 -0
  224. package/dist/es/utils/chart.mjs +298 -197
  225. package/dist/es/utils/const.mjs +30 -2
  226. package/dist/es/utils/createCategoricalInverse.mjs +46 -0
  227. package/dist/es/utils/createContext.mjs +28 -9
  228. package/dist/es/utils/data-utils.mjs +9 -8
  229. package/dist/es/utils/data.mjs +35 -21
  230. package/dist/es/utils/events.mjs +5 -3
  231. package/dist/es/utils/getLinearRegression.mjs +28 -11
  232. package/dist/es/utils/grid.mjs +20 -5
  233. package/dist/es/utils/isDomainSpecifiedByUser.mjs +105 -54
  234. package/dist/es/utils/legend.mjs +13 -12
  235. package/dist/es/utils/log.mjs +10 -7
  236. package/dist/es/utils/payload/getUniqPayload.mjs +6 -4
  237. package/dist/es/utils/polar.mjs +37 -30
  238. package/dist/es/utils/props.mjs +16 -10
  239. package/dist/es/utils/resolveDefaultProps.mjs +23 -4
  240. package/dist/es/utils/scale/getNiceTickValues.mjs +127 -49
  241. package/dist/es/utils/scale/utils/arithmetic.mjs +49 -19
  242. package/dist/es/utils/scale/utils/utils.mjs +43 -24
  243. package/dist/es/utils/scale.mjs +46 -0
  244. package/dist/es/utils/style.mjs +24 -13
  245. package/dist/es/utils/tick.mjs +34 -23
  246. package/dist/es/utils/tooltip/translate.mjs +63 -49
  247. package/dist/es/utils/validate.mjs +40 -29
  248. package/dist/hooks/publicHooks.d.ts +143 -0
  249. package/dist/hooks/useIsAnimating.d.ts +14 -0
  250. package/dist/index.d.ts +1 -0
  251. package/dist/polar/pie/type.d.ts +2 -2
  252. package/dist/polar/radar/Radar.d.ts +4 -4
  253. package/dist/shape/Curve.d.ts +2 -1
  254. package/dist/shape/Polygon.d.ts +9 -0
  255. package/dist/shape/Rectangle.d.ts +0 -4
  256. package/dist/shape/Sector.d.ts +2 -2
  257. package/dist/shape/Symbols.d.ts +2 -1
  258. package/dist/shape/Trapezoid.d.ts +30 -0
  259. package/dist/shape/index.d.ts +2 -0
  260. package/dist/shape/types.d.ts +4 -5
  261. package/dist/state/ReportChartProps.d.ts +3 -3
  262. package/dist/state/graphicalItemsSlice.d.ts +1 -1
  263. package/dist/state/rootPropsSlice.d.ts +2 -2
  264. package/dist/state/selectors/axisSelectors.d.ts +5 -0
  265. package/dist/types/axis.d.ts +2 -2
  266. package/dist/types/bar.d.ts +2 -6
  267. package/dist/types/categorical.d.ts +2 -2
  268. package/dist/types/common.d.ts +7 -1
  269. package/dist/types/tooltip.d.ts +2 -2
  270. package/dist/utils/cell.d.ts +11 -0
  271. package/dist/utils/createCategoricalInverse.d.ts +16 -0
  272. package/dist/utils/scale.d.ts +23 -0
  273. package/package.json +2 -1
@@ -1,186 +1,248 @@
1
- import { isNan as e, isNullish as t, isNumOrStr as n, isNumber as r } from "./validate.mjs";
2
- import { formatAngleOfSector as i, getAngleOfPoint as a, polarToCartesian as o, reverseFormatAngleOfSector as s } from "./polar.mjs";
3
- import { findEntryInArray as c, mathSign as l } from "./data.mjs";
4
- import { toRaw as u } from "vue";
5
- import { stack as d, stackOffsetExpand as f, stackOffsetNone as p, stackOffsetSilhouette as m, stackOffsetWiggle as h, stackOrderNone as g } from "victory-vendor/d3-shape";
6
- import { get as _, isNaN as v, sortBy as y } from "lodash-es";
1
+ import { isNan, isNullish, isNumOrStr, isNumber } from "./validate.mjs";
2
+ import { formatAngleOfSector, getAngleOfPoint, polarToCartesian, reverseFormatAngleOfSector } from "./polar.mjs";
3
+ import { findEntryInArray, mathSign } from "./data.mjs";
4
+ import { toRaw } from "vue";
5
+ import { stack, stackOffsetExpand, stackOffsetNone, stackOffsetSilhouette, stackOffsetWiggle, stackOrderNone } from "victory-vendor/d3-shape";
6
+ import { get, isNaN, sortBy } from "lodash-es";
7
7
  //#region src/utils/chart.ts
8
- function b(e, t, n) {
9
- if (!e) return null;
10
- let { duplicateDomain: r, type: i, range: a, scale: o, realScaleType: s, isCategorical: c, categoricalDomain: u, tickCount: d, ticks: f, niceTicks: p, axisType: m } = e;
11
- if (!o) return null;
12
- let h = s === "scaleBand" ? o.bandwidth() / 2 : 2, g = (t || n) && i === "category" && o.bandwidth ? o.bandwidth() / h : 0;
13
- return g = m === "angleAxis" && a.length >= 2 ? l(a[0] - a[1]) * 2 * g : g, t && (f || p) ? (f || p).map((e, t) => ({
14
- coordinate: o(r ? r.indexOf(e) : e) + g,
15
- value: e,
16
- offset: g,
17
- index: t
18
- })).filter((e) => !v(e.coordinate)) : c && u ? u.map((e, t) => ({
19
- coordinate: o(e) + g,
20
- value: e,
21
- index: t,
22
- offset: g
23
- })) : o.ticks && !n ? o.ticks(d).map((e, t) => ({
24
- coordinate: o(e) + g,
25
- value: e,
26
- offset: g,
27
- index: t
28
- })) : o.domain().map((e, t) => ({
29
- coordinate: o(e) + g,
30
- value: r ? r[e] : e,
31
- index: t,
32
- offset: g
8
+ /**
9
+ * Get the ticks of an axis
10
+ * @param {object} axis The configuration of an axis
11
+ * @param {boolean} isGrid Whether or not are the ticks in grid
12
+ * @param {boolean} isAll Return the ticks of all the points or not
13
+ * @return {Array} Ticks
14
+ */
15
+ function getTicksOfAxis(axis, isGrid, isAll) {
16
+ if (!axis) return null;
17
+ const { duplicateDomain, type, range, scale, realScaleType, isCategorical, categoricalDomain, tickCount, ticks, niceTicks, axisType } = axis;
18
+ if (!scale) return null;
19
+ const offsetForBand = realScaleType === "scaleBand" ? scale.bandwidth() / 2 : 2;
20
+ let offset = (isGrid || isAll) && type === "category" && scale.bandwidth ? scale.bandwidth() / offsetForBand : 0;
21
+ offset = axisType === "angleAxis" && range.length >= 2 ? mathSign(range[0] - range[1]) * 2 * offset : offset;
22
+ if (isGrid && (ticks || niceTicks)) return (ticks || niceTicks).map((entry, index) => {
23
+ return {
24
+ coordinate: scale(duplicateDomain ? duplicateDomain.indexOf(entry) : entry) + offset,
25
+ value: entry,
26
+ offset,
27
+ index
28
+ };
29
+ }).filter((row) => !isNaN(row.coordinate));
30
+ if (isCategorical && categoricalDomain) return categoricalDomain.map((entry, index) => ({
31
+ coordinate: scale(entry) + offset,
32
+ value: entry,
33
+ index,
34
+ offset
35
+ }));
36
+ if (scale.ticks && !isAll) return scale.ticks(tickCount).map((entry, index) => ({
37
+ coordinate: scale(entry) + offset,
38
+ value: entry,
39
+ offset,
40
+ index
41
+ }));
42
+ return scale.domain().map((entry, index) => ({
43
+ coordinate: scale(entry) + offset,
44
+ value: duplicateDomain ? duplicateDomain[entry] : entry,
45
+ index,
46
+ offset
33
47
  }));
34
48
  }
35
- function x(e, r, i) {
36
- return t(e) || t(r) ? i : n(r) ? _(u(e), r, i) : typeof r == "function" ? r(e) : i;
49
+ function getValueByDataKey(obj, dataKey, defaultValue) {
50
+ if (isNullish(obj) || isNullish(dataKey)) return defaultValue;
51
+ if (isNumOrStr(dataKey)) return get(toRaw(obj), dataKey, defaultValue);
52
+ if (typeof dataKey === "function") return dataKey(obj);
53
+ return defaultValue;
37
54
  }
38
- var S = /^dataMin\s*-\s*(\d+(\.\d+)?)$/, C = /^dataMax\s*\+\s*(\d+(\.\d+)?)$/;
39
- function w(e, t, n) {
40
- if (e && e.scale && e.scale.bandwidth) {
41
- let t = e.scale.bandwidth();
42
- if (!n || t > 0) return t;
55
+ var MIN_VALUE_REG = /^dataMin\s*-\s*(\d+(\.\d+)?)$/;
56
+ var MAX_VALUE_REG = /^dataMax\s*\+\s*(\d+(\.\d+)?)$/;
57
+ /**
58
+ * Calculate the size between two category
59
+ * @param {object} axis The options of axis
60
+ * @param {Array} ticks The ticks of axis
61
+ * @param {boolean} isBar if items in axis are bars
62
+ * @return {number} Size
63
+ */
64
+ function getBandSizeOfAxis(axis, ticks, isBar) {
65
+ if (axis && axis.scale && axis.scale.bandwidth) {
66
+ const bandWidth = axis.scale.bandwidth();
67
+ if (!isBar || bandWidth > 0) return bandWidth;
43
68
  }
44
- if (e && t && t.length >= 2) {
45
- let e = y(t, (e) => e.coordinate), n = Infinity;
46
- for (let t = 1, r = e.length; t < r; t++) {
47
- let r = e[t], i = e[t - 1];
48
- n = Math.min((r.coordinate || 0) - (i.coordinate || 0), n);
69
+ if (axis && ticks && ticks.length >= 2) {
70
+ const orderedTicks = sortBy(ticks, (o) => o.coordinate);
71
+ let bandSize = Infinity;
72
+ for (let i = 1, len = orderedTicks.length; i < len; i++) {
73
+ const cur = orderedTicks[i];
74
+ const prev = orderedTicks[i - 1];
75
+ bandSize = Math.min((cur.coordinate || 0) - (prev.coordinate || 0), bandSize);
49
76
  }
50
- return n === Infinity ? 0 : n;
77
+ return bandSize === Infinity ? 0 : bandSize;
51
78
  }
52
- return n ? void 0 : 0;
79
+ return isBar ? void 0 : 0;
53
80
  }
54
- function T(e, t) {
55
- if (!t || t.length !== 2 || !r(t[0]) || !r(t[1])) return e;
56
- let n = Math.min(t[0], t[1]), i = Math.max(t[0], t[1]), a = [e[0], e[1]];
57
- return (!r(e[0]) || e[0] < n) && (a[0] = n), (!r(e[1]) || e[1] > i) && (a[1] = i), a[0] > i && (a[0] = i), a[1] < n && (a[1] = n), a;
81
+ /**
82
+ * Both value and domain are tuples of two numbers
83
+ * - but the type stays as array of numbers until we have better support in rest of the app
84
+ * @param value input that will be truncated
85
+ * @param domain boundaries
86
+ * @returns tuple of two numbers
87
+ */
88
+ function truncateByDomain(value, domain) {
89
+ if (!domain || domain.length !== 2 || !isNumber(domain[0]) || !isNumber(domain[1])) return value;
90
+ const minValue = Math.min(domain[0], domain[1]);
91
+ const maxValue = Math.max(domain[0], domain[1]);
92
+ const result = [value[0], value[1]];
93
+ if (!isNumber(value[0]) || value[0] < minValue) result[0] = minValue;
94
+ if (!isNumber(value[1]) || value[1] > maxValue) result[1] = maxValue;
95
+ if (result[0] > maxValue) result[0] = maxValue;
96
+ if (result[1] < minValue) result[1] = minValue;
97
+ return result;
58
98
  }
59
- function E(e) {
60
- return e == null ? void 0 : String(e);
99
+ function getNormalizedStackId(publicStackId) {
100
+ return publicStackId == null ? void 0 : String(publicStackId);
61
101
  }
62
- function D({ axis: e, ticks: n, bandSize: r, entry: i, index: a, dataKey: o }) {
63
- if (e.type === "category") {
64
- if (!e.allowDuplicatedCategory && e.dataKey && !t(i[e.dataKey])) {
65
- let t = c(n, "value", i[e.dataKey]);
66
- if (t) return t.coordinate + r / 2;
102
+ function getCateCoordinateOfLine({ axis, ticks, bandSize, entry, index, dataKey }) {
103
+ if (axis.type === "category") {
104
+ if (!axis.allowDuplicatedCategory && axis.dataKey && !isNullish(entry[axis.dataKey])) {
105
+ const matchedTick = findEntryInArray(ticks, "value", entry[axis.dataKey]);
106
+ if (matchedTick) return matchedTick.coordinate + bandSize / 2;
67
107
  }
68
- return n[a] ? n[a].coordinate + r / 2 : null;
108
+ return ticks[index] ? ticks[index].coordinate + bandSize / 2 : null;
69
109
  }
70
- let s = x(i, t(o) ? e.dataKey : o);
71
- return t(s) ? null : e.scale(s);
110
+ const value = getValueByDataKey(entry, !isNullish(dataKey) ? dataKey : axis.dataKey);
111
+ return !isNullish(value) ? axis.scale(value) : null;
72
112
  }
73
- function O(e) {
74
- let t = e.currentTarget, n = t.getBoundingClientRect(), r = n.width / t.offsetWidth, i = n.height / t.offsetHeight;
113
+ function getChartPointer(event) {
114
+ const target = event.currentTarget;
115
+ const rect = target.getBoundingClientRect();
116
+ const scaleX = rect.width / target.offsetWidth;
117
+ const scaleY = rect.height / target.offsetHeight;
75
118
  return {
76
- chartX: Math.round((e.clientX - n.left) / r),
77
- chartY: Math.round((e.clientY - n.top) / i)
119
+ chartX: Math.round((event.clientX - rect.left) / scaleX),
120
+ chartY: Math.round((event.clientY - rect.top) / scaleY)
78
121
  };
79
122
  }
80
- function k({ tooltipEntrySettings: e, dataKey: t, payload: n, value: r, name: i }) {
123
+ function getTooltipEntry({ tooltipEntrySettings, dataKey, payload, value, name }) {
81
124
  return {
82
- ...e,
83
- dataKey: t,
84
- payload: n,
85
- value: r,
86
- name: i
125
+ ...tooltipEntrySettings,
126
+ dataKey,
127
+ payload,
128
+ value,
129
+ name
87
130
  };
88
131
  }
89
- function A(e, t) {
90
- return t === "horizontal" ? e.x : t === "vertical" ? e.y : t === "centric" ? e.angle : e.radius;
132
+ function calculateTooltipPos(rangeObj, layout) {
133
+ if (layout === "horizontal") return rangeObj.x;
134
+ if (layout === "vertical") return rangeObj.y;
135
+ if (layout === "centric") return rangeObj.angle;
136
+ return rangeObj.radius;
91
137
  }
92
- function j({ x: e, y: t }, n) {
93
- let { radius: r, angle: o } = a({
94
- x: e,
95
- y: t
96
- }, n), { innerRadius: c, outerRadius: l } = n;
97
- if (r < c || r > l || r === 0) return null;
98
- let { startAngle: u, endAngle: d } = i(n), f = o, p;
99
- if (u <= d) {
100
- for (; f > d;) f -= 360;
101
- for (; f < u;) f += 360;
102
- p = f >= u && f <= d;
138
+ function inRangeOfSector({ x, y }, viewBox) {
139
+ const { radius, angle } = getAngleOfPoint({
140
+ x,
141
+ y
142
+ }, viewBox);
143
+ const { innerRadius, outerRadius } = viewBox;
144
+ if (radius < innerRadius || radius > outerRadius) return null;
145
+ if (radius === 0) return null;
146
+ const { startAngle, endAngle } = formatAngleOfSector(viewBox);
147
+ let formatAngle = angle;
148
+ let inRange;
149
+ if (startAngle <= endAngle) {
150
+ while (formatAngle > endAngle) formatAngle -= 360;
151
+ while (formatAngle < startAngle) formatAngle += 360;
152
+ inRange = formatAngle >= startAngle && formatAngle <= endAngle;
103
153
  } else {
104
- for (; f > u;) f -= 360;
105
- for (; f < d;) f += 360;
106
- p = f >= d && f <= u;
154
+ while (formatAngle > startAngle) formatAngle -= 360;
155
+ while (formatAngle < endAngle) formatAngle += 360;
156
+ inRange = formatAngle >= endAngle && formatAngle <= startAngle;
107
157
  }
108
- return p ? {
109
- ...n,
110
- radius: r,
111
- angle: s(f, n)
112
- } : null;
158
+ if (inRange) return {
159
+ ...viewBox,
160
+ radius,
161
+ angle: reverseFormatAngleOfSector(formatAngle, viewBox)
162
+ };
163
+ return null;
113
164
  }
114
- function M(e, t, n, r, i) {
115
- return n === "horizontal" || n === "vertical" ? e >= i.left && e <= i.left + i.width && t >= i.top && t <= i.top + i.height ? {
116
- x: e,
117
- y: t
118
- } : null : r ? j({
119
- x: e,
120
- y: t
121
- }, r) : null;
165
+ function inRange(x, y, layout, polarViewBox, offset) {
166
+ if (layout === "horizontal" || layout === "vertical") return x >= offset.left && x <= offset.left + offset.width && y >= offset.top && y <= offset.top + offset.height ? {
167
+ x,
168
+ y
169
+ } : null;
170
+ if (polarViewBox) return inRangeOfSector({
171
+ x,
172
+ y
173
+ }, polarViewBox);
174
+ return null;
122
175
  }
123
- function N(e, t, n, r, i) {
124
- let a = -1, o = t?.length ?? 0;
125
- if (o <= 1) return 0;
126
- if (r === "angleAxis" && i != null && Math.abs(Math.abs(i[1] - i[0]) - 360) <= 1e-6) for (let t = 0; t < o; t++) {
127
- let r = t > 0 ? n[t - 1].coordinate : n[o - 1].coordinate, s = n[t].coordinate, c = t >= o - 1 ? n[0].coordinate : n[t + 1].coordinate, u;
128
- if (l(s - r) !== l(c - s)) {
129
- let o = [];
130
- if (l(c - s) === l(i[1] - i[0])) {
131
- u = c;
132
- let e = s + i[1] - i[0];
133
- o[0] = Math.min(e, (e + r) / 2), o[1] = Math.max(e, (e + r) / 2);
176
+ function calculateActiveTickIndex(coordinate, ticks, unsortedTicks, axisType, range) {
177
+ let index = -1;
178
+ const len = ticks?.length ?? 0;
179
+ if (len <= 1) return 0;
180
+ if (axisType === "angleAxis" && range != null && Math.abs(Math.abs(range[1] - range[0]) - 360) <= 1e-6) for (let i = 0; i < len; i++) {
181
+ const before = i > 0 ? unsortedTicks[i - 1].coordinate : unsortedTicks[len - 1].coordinate;
182
+ const cur = unsortedTicks[i].coordinate;
183
+ const after = i >= len - 1 ? unsortedTicks[0].coordinate : unsortedTicks[i + 1].coordinate;
184
+ let sameDirectionCoord;
185
+ if (mathSign(cur - before) !== mathSign(after - cur)) {
186
+ const diffInterval = [];
187
+ if (mathSign(after - cur) === mathSign(range[1] - range[0])) {
188
+ sameDirectionCoord = after;
189
+ const curInRange = cur + range[1] - range[0];
190
+ diffInterval[0] = Math.min(curInRange, (curInRange + before) / 2);
191
+ diffInterval[1] = Math.max(curInRange, (curInRange + before) / 2);
134
192
  } else {
135
- u = r;
136
- let e = c + i[1] - i[0];
137
- o[0] = Math.min(s, (e + s) / 2), o[1] = Math.max(s, (e + s) / 2);
193
+ sameDirectionCoord = before;
194
+ const afterInRange = after + range[1] - range[0];
195
+ diffInterval[0] = Math.min(cur, (afterInRange + cur) / 2);
196
+ diffInterval[1] = Math.max(cur, (afterInRange + cur) / 2);
138
197
  }
139
- let d = [Math.min(s, (u + s) / 2), Math.max(s, (u + s) / 2)];
140
- if (e > d[0] && e <= d[1] || e >= o[0] && e <= o[1]) {
141
- a = n[t].index;
198
+ const sameInterval = [Math.min(cur, (sameDirectionCoord + cur) / 2), Math.max(cur, (sameDirectionCoord + cur) / 2)];
199
+ if (coordinate > sameInterval[0] && coordinate <= sameInterval[1] || coordinate >= diffInterval[0] && coordinate <= diffInterval[1]) {
200
+ index = unsortedTicks[i].index;
142
201
  break;
143
202
  }
144
203
  } else {
145
- let i = Math.min(r, c), o = Math.max(r, c);
146
- if (e > (i + s) / 2 && e <= (o + s) / 2) {
147
- a = n[t].index;
204
+ const minValue = Math.min(before, after);
205
+ const maxValue = Math.max(before, after);
206
+ if (coordinate > (minValue + cur) / 2 && coordinate <= (maxValue + cur) / 2) {
207
+ index = unsortedTicks[i].index;
148
208
  break;
149
209
  }
150
210
  }
151
211
  }
152
- else for (let n = 0; n < o; n++) if (n === 0 && e <= (t[n].coordinate + t[n + 1].coordinate) / 2 || n > 0 && n < o - 1 && e > (t[n].coordinate + t[n - 1].coordinate) / 2 && e <= (t[n].coordinate + t[n + 1].coordinate) / 2 || n === o - 1 && e > (t[n].coordinate + t[n - 1].coordinate) / 2) {
153
- a = t[n].index;
212
+ else for (let i = 0; i < len; i++) if (i === 0 && coordinate <= (ticks[i].coordinate + ticks[i + 1].coordinate) / 2 || i > 0 && i < len - 1 && coordinate > (ticks[i].coordinate + ticks[i - 1].coordinate) / 2 && coordinate <= (ticks[i].coordinate + ticks[i + 1].coordinate) / 2 || i === len - 1 && coordinate > (ticks[i].coordinate + ticks[i - 1].coordinate) / 2) {
213
+ index = ticks[i].index;
154
214
  break;
155
215
  }
156
- return a;
216
+ return index;
157
217
  }
158
- function P(e, t, n, r) {
159
- let i = t.find((e) => e && e.index === n);
160
- if (i) {
161
- if (e === "horizontal") return {
162
- x: i.coordinate,
163
- y: r.y
218
+ function getActiveCoordinate(layout, tooltipTicks, activeIndex, rangeObj) {
219
+ const entry = tooltipTicks.find((tick) => tick && tick.index === activeIndex);
220
+ if (entry) {
221
+ if (layout === "horizontal") return {
222
+ x: entry.coordinate,
223
+ y: rangeObj.y
164
224
  };
165
- if (e === "vertical") return {
166
- x: r.x,
167
- y: i.coordinate
225
+ if (layout === "vertical") return {
226
+ x: rangeObj.x,
227
+ y: entry.coordinate
168
228
  };
169
- if (e === "centric") {
170
- let e = i.coordinate, { radius: t } = r;
229
+ if (layout === "centric") {
230
+ const angle = entry.coordinate;
231
+ const { radius } = rangeObj;
171
232
  return {
172
- ...r,
173
- ...o(r.cx, r.cy, t, e),
174
- angle: e,
175
- radius: t
233
+ ...rangeObj,
234
+ ...polarToCartesian(rangeObj.cx, rangeObj.cy, radius, angle),
235
+ angle,
236
+ radius
176
237
  };
177
238
  }
178
- let t = i.coordinate, { angle: n } = r;
239
+ const radius = entry.coordinate;
240
+ const { angle } = rangeObj;
179
241
  return {
180
- ...r,
181
- ...o(r.cx, r.cy, t, n),
182
- angle: n,
183
- radius: t
242
+ ...rangeObj,
243
+ ...polarToCartesian(rangeObj.cx, rangeObj.cy, radius, angle),
244
+ angle,
245
+ radius
184
246
  };
185
247
  }
186
248
  return {
@@ -188,78 +250,117 @@ function P(e, t, n, r) {
188
250
  y: 0
189
251
  };
190
252
  }
191
- function F(e) {
192
- return [e[0] === Infinity ? 0 : e[0], e[1] === -Infinity ? 0 : e[1]];
253
+ function makeDomainFinite(domain) {
254
+ return [domain[0] === Infinity ? 0 : domain[0], domain[1] === -Infinity ? 0 : domain[1]];
193
255
  }
194
- function I(e) {
195
- let t = e.flat(2).filter(r);
196
- return [Math.min(...t), Math.max(...t)];
256
+ function getDomainOfSingle(data) {
257
+ const flat = data.flat(2).filter(isNumber);
258
+ return [Math.min(...flat), Math.max(...flat)];
197
259
  }
198
- function L(e, t, n) {
199
- if (e != null) return F(Object.keys(e).reduce((r, i) => {
200
- let { stackedData: a } = e[i], o = a.reduce((e, r) => {
201
- let i = I(r.slice(t, n + 1));
202
- return [Math.min(e[0], i[0]), Math.max(e[1], i[1])];
260
+ function getDomainOfStackGroups(stackGroups, startIndex, endIndex) {
261
+ if (stackGroups == null) return;
262
+ return makeDomainFinite(Object.keys(stackGroups).reduce((result, stackId) => {
263
+ const { stackedData } = stackGroups[stackId];
264
+ const domain = stackedData.reduce((res, entry) => {
265
+ const s = getDomainOfSingle(entry.slice(startIndex, endIndex + 1));
266
+ return [Math.min(res[0], s[0]), Math.max(res[1], s[1])];
203
267
  }, [Infinity, -Infinity]);
204
- return [Math.min(o[0], r[0]), Math.max(o[1], r[1])];
268
+ return [Math.min(domain[0], result[0]), Math.max(domain[1], result[1])];
205
269
  }, [Infinity, -Infinity]));
206
270
  }
207
- var R = 1e-4;
208
- function z(e) {
209
- let t = e.domain();
210
- if (!t || t.length <= 2) return;
211
- let n = t.length, r = e.range(), i = Math.min(r[0], r[1]) - R, a = Math.max(r[0], r[1]) + R, o = e(t[0]), s = e(t[n - 1]);
212
- (o < i || o > a || s < i || s > a) && e.domain([t[0], t[n - 1]]);
271
+ var EPS = 1e-4;
272
+ function checkDomainOfScale(scale) {
273
+ const domain = scale.domain();
274
+ if (!domain || domain.length <= 2) return;
275
+ const len = domain.length;
276
+ const range = scale.range();
277
+ const minValue = Math.min(range[0], range[1]) - EPS;
278
+ const maxValue = Math.max(range[0], range[1]) + EPS;
279
+ const first = scale(domain[0]);
280
+ const last = scale(domain[len - 1]);
281
+ if (first < minValue || first > maxValue || last < minValue || last > maxValue) scale.domain([domain[0], domain[len - 1]]);
213
282
  }
214
- function B(e, t) {
215
- if (e) return String(e);
216
- if (typeof t == "string") return t;
283
+ function getTooltipNameProp(nameFromItem, dataKey) {
284
+ if (nameFromItem) return String(nameFromItem);
285
+ if (typeof dataKey === "string") return dataKey;
217
286
  }
218
- function V(e) {
219
- return e && typeof e == "object" && "clipDot" in e ? !!e.clipDot : !0;
287
+ function isClipDot(dot) {
288
+ if (dot && typeof dot === "object" && "clipDot" in dot) return Boolean(dot.clipDot);
289
+ return true;
220
290
  }
221
- var H = {
222
- sign: (t) => {
223
- let n = t.length;
224
- if (!(n <= 0)) for (let r = 0, i = t[0].length; r < i; ++r) {
225
- let i = 0, a = 0;
226
- for (let o = 0; o < n; ++o) {
227
- let n = e(t[o][r][1]) ? t[o][r][0] : t[o][r][1];
228
- n >= 0 ? (t[o][r][0] = i, t[o][r][1] = i + n, i = t[o][r][1]) : (t[o][r][0] = a, t[o][r][1] = a + n, a = t[o][r][1]);
291
+ var offsetSign = (series) => {
292
+ const n = series.length;
293
+ if (n <= 0) return;
294
+ for (let j = 0, m = series[0].length; j < m; ++j) {
295
+ let positive = 0;
296
+ let negative = 0;
297
+ for (let i = 0; i < n; ++i) {
298
+ const value = isNan(series[i][j][1]) ? series[i][j][0] : series[i][j][1];
299
+ if (value >= 0) {
300
+ series[i][j][0] = positive;
301
+ series[i][j][1] = positive + value;
302
+ positive = series[i][j][1];
303
+ } else {
304
+ series[i][j][0] = negative;
305
+ series[i][j][1] = negative + value;
306
+ negative = series[i][j][1];
229
307
  }
230
308
  }
231
- },
232
- expand: f,
233
- none: p,
234
- silhouette: m,
235
- wiggle: h,
236
- positive: (t) => {
237
- let n = t.length;
238
- if (!(n <= 0)) for (let r = 0, i = t[0].length; r < i; ++r) {
239
- let i = 0;
240
- for (let a = 0; a < n; ++a) {
241
- let n = e(t[a][r][1]) ? t[a][r][0] : t[a][r][1];
242
- n >= 0 ? (t[a][r][0] = i, t[a][r][1] = i + n, i = t[a][r][1]) : (t[a][r][0] = 0, t[a][r][1] = 0);
309
+ }
310
+ };
311
+ /**
312
+ * Replaces all negative values with zero when stacking data.
313
+ *
314
+ * If all values in the series are positive then this behaves the same as 'none' stacker.
315
+ *
316
+ * @param {Array} series from d3-shape Stack
317
+ * @return {Array} series with applied offset
318
+ */
319
+ var offsetPositive = (series) => {
320
+ const n = series.length;
321
+ if (n <= 0) return;
322
+ for (let j = 0, m = series[0].length; j < m; ++j) {
323
+ let positive = 0;
324
+ for (let i = 0; i < n; ++i) {
325
+ const value = isNan(series[i][j][1]) ? series[i][j][0] : series[i][j][1];
326
+ if (value >= 0) {
327
+ series[i][j][0] = positive;
328
+ series[i][j][1] = positive + value;
329
+ positive = series[i][j][1];
330
+ } else {
331
+ series[i][j][0] = 0;
332
+ series[i][j][1] = 0;
243
333
  }
244
334
  }
245
335
  }
246
336
  };
247
- function U(e, t, n) {
248
- let r = H[n];
249
- return d().keys(t).value((e, t) => +x(e, t, 0)).order(g).offset(r)(e);
337
+ var STACK_OFFSET_MAP = {
338
+ sign: offsetSign,
339
+ expand: stackOffsetExpand,
340
+ none: stackOffsetNone,
341
+ silhouette: stackOffsetSilhouette,
342
+ wiggle: stackOffsetWiggle,
343
+ positive: offsetPositive
344
+ };
345
+ function getStackedData(data, dataKeys, offsetType) {
346
+ const offsetAccessor = STACK_OFFSET_MAP[offsetType];
347
+ return stack().keys(dataKeys).value((d, key) => +getValueByDataKey(d, key, 0)).order(stackOrderNone).offset(offsetAccessor)(data);
250
348
  }
251
- function W({ numericAxis: e }) {
252
- let t = e.scale.domain();
253
- if (e.type === "number") {
254
- let e = Math.min(t[0], t[1]), n = Math.max(t[0], t[1]);
255
- return e <= 0 && n >= 0 ? 0 : n < 0 ? n : e;
349
+ function getBaseValueOfBar({ numericAxis }) {
350
+ const domain = numericAxis.scale.domain();
351
+ if (numericAxis.type === "number") {
352
+ const minValue = Math.min(domain[0], domain[1]);
353
+ const maxValue = Math.max(domain[0], domain[1]);
354
+ if (minValue <= 0 && maxValue >= 0) return 0;
355
+ if (maxValue < 0) return maxValue;
356
+ return minValue;
256
357
  }
257
- return t[0];
358
+ return domain[0];
258
359
  }
259
- function G({ axis: e, ticks: n, offset: r, bandSize: i, entry: a, index: o }) {
260
- if (e.type === "category") return n[o] ? n[o].coordinate + r : null;
261
- let s = x(a, e.dataKey, e.scale.domain()[o]);
262
- return t(s) ? null : e.scale(s) - i / 2 + r;
360
+ function getCateCoordinateOfBar({ axis, ticks, offset, bandSize, entry, index }) {
361
+ if (axis.type === "category") return ticks[index] ? ticks[index].coordinate + offset : null;
362
+ const value = getValueByDataKey(entry, axis.dataKey, axis.scale.domain()[index]);
363
+ return !isNullish(value) ? axis.scale(value) - bandSize / 2 + offset : null;
263
364
  }
264
365
  //#endregion
265
- export { C as MAX_VALUE_REG, S as MIN_VALUE_REG, N as calculateActiveTickIndex, A as calculateTooltipPos, z as checkDomainOfScale, P as getActiveCoordinate, w as getBandSizeOfAxis, W as getBaseValueOfBar, G as getCateCoordinateOfBar, D as getCateCoordinateOfLine, O as getChartPointer, L as getDomainOfStackGroups, E as getNormalizedStackId, U as getStackedData, b as getTicksOfAxis, k as getTooltipEntry, B as getTooltipNameProp, x as getValueByDataKey, M as inRange, V as isClipDot, T as truncateByDomain };
366
+ export { MAX_VALUE_REG, MIN_VALUE_REG, calculateActiveTickIndex, calculateTooltipPos, checkDomainOfScale, getActiveCoordinate, getBandSizeOfAxis, getBaseValueOfBar, getCateCoordinateOfBar, getCateCoordinateOfLine, getChartPointer, getDomainOfStackGroups, getNormalizedStackId, getStackedData, getTicksOfAxis, getTooltipEntry, getTooltipNameProp, getValueByDataKey, inRange, isClipDot, truncateByDomain };
@@ -1,4 +1,32 @@
1
1
  //#region src/utils/const.ts
2
- var e = "data-recharts-item-index", t = "data-recharts-item-data-key";
2
+ /**
3
+ * We use this attribute to identify which element is the one that the user is touching.
4
+ * The index is the position of the element in the data array.
5
+ * This can be either a number (for array-based charts) or a string (for the charts that have a matrix-shaped data).
6
+ */
7
+ var DATA_ITEM_INDEX_ATTRIBUTE_NAME = "data-recharts-item-index";
8
+ /**
9
+ * We use this attribute to identify which element is the one that the user is touching.
10
+ * DataKey works here as a kind of identifier for the element. It's not a perfect identifier for ~two~ three reasons:
11
+ *
12
+ * 1. There can be two different elements with the same dataKey; we won't know which is it
13
+ * 2. DataKey can be a function, and that serialized will be a `[Function: anonymous]` string
14
+ * which means we will be able to identify that it was a function but can't tell which one.
15
+ * This will lead to some weird bugs. A proper fix would be to either:
16
+ * a) use a unique identifier for each element (passed from props, or generated)
17
+ * b) figure out how to compare the dataKey or graphical item by object reference
18
+ *
19
+ * a) is a fuss because we don't have the unique identifier in props,
20
+ * and b) is possible most of the time except for touchMove events which work differently from mouseEnter/mouseLeave:
21
+ * - while mouseEnter is fired for the element that the mouse is over,
22
+ * touchMove is fired for the element where user has started touching. As the finger moves,
23
+ * we can identify the element that the user is touching by using the elementFromPoint method,
24
+ * but it keeps calling the handler on the element where touchStart was fired.
25
+ *
26
+ * Okay and now I discovered a third reason: the dataKey can be undefined and that's still fine
27
+ * because if dataKey is undefined then graphical elements assume the dataKey of the axes.
28
+ * Which makes it a convenient way of using recharts to render a chart but horrible identifier.
29
+ */
30
+ var DATA_ITEM_DATAKEY_ATTRIBUTE_NAME = "data-recharts-item-data-key";
3
31
  //#endregion
4
- export { t as DATA_ITEM_DATAKEY_ATTRIBUTE_NAME, e as DATA_ITEM_INDEX_ATTRIBUTE_NAME };
32
+ export { DATA_ITEM_DATAKEY_ATTRIBUTE_NAME, DATA_ITEM_INDEX_ATTRIBUTE_NAME };