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,29 +1,32 @@
1
- import { Layer as e } from "../../../container/Layer.mjs";
2
- import { useBarContext as t } from "../hooks/useBar.mjs";
3
- import { Rectangle as n } from "../../../shape/Rectangle.mjs";
4
- import { Fragment as r, createVNode as i, defineComponent as a } from "vue";
1
+ import { Layer } from "../../../container/Layer.mjs";
2
+ import { useBarContext } from "../hooks/useBar.mjs";
3
+ import { Rectangle } from "../../../shape/Rectangle.mjs";
4
+ import { Fragment, createVNode, defineComponent } from "vue";
5
5
  //#region src/cartesian/bar/components/BarBackground.tsx
6
- var o = /* @__PURE__ */ a({
6
+ var BarBackground = /* @__PURE__ */ defineComponent({
7
7
  name: "BarBackground",
8
- inheritAttrs: !1,
9
- setup(a, { attrs: o }) {
10
- let { props: s, data: c } = t();
8
+ inheritAttrs: false,
9
+ setup(_, { attrs }) {
10
+ const { props, data: barData } = useBarContext();
11
11
  return () => {
12
- let t = c.value, a = s.background;
13
- return !a || !t ? null : i(r, null, [t.map((t, r) => {
14
- let { value: o, background: s, tooltipPosition: c, ...l } = t;
15
- if (!s) return null;
16
- let u = typeof a == "object" ? a : {}, d = {
17
- option: a,
18
- ...l,
12
+ const data = barData.value;
13
+ const backgroundFromProps = props.background;
14
+ if (!backgroundFromProps || !data) return null;
15
+ return createVNode(Fragment, null, [data.map((entry, i) => {
16
+ const { value, background: backgroundFromDataEntry, tooltipPosition, ...rest } = entry;
17
+ if (!backgroundFromDataEntry) return null;
18
+ const backgroundObjectProps = typeof backgroundFromProps === "object" ? backgroundFromProps : {};
19
+ const barRectangleProps = {
20
+ option: backgroundFromProps,
21
+ ...rest,
19
22
  fill: "#eee",
20
- ...s,
21
- ...u
23
+ ...backgroundFromDataEntry,
24
+ ...backgroundObjectProps
22
25
  };
23
- return i(e, { key: `background-bar-${r}` }, { default: () => [i(n, d, null)] });
26
+ return createVNode(Layer, { "key": `background-bar-${i}` }, { default: () => [createVNode(Rectangle, barRectangleProps, null)] });
24
27
  })]);
25
28
  };
26
29
  }
27
30
  });
28
31
  //#endregion
29
- export { o as BarBackground };
32
+ export { BarBackground };
@@ -1,106 +1,143 @@
1
- import { mouseLeaveItem as e, setActiveClickItemIndex as t, setActiveMouseOverItemIndex as n } from "../../../state/tooltipSlice.mjs";
2
- import { selectActiveTooltipDataKey as r, selectActiveTooltipIndex as i } from "../../../state/selectors/tooltipSelectors.mjs";
3
- import { useAppDispatch as a, useAppSelector as o } from "../../../state/hooks.mjs";
4
- import { filterProps as s } from "../../../utils/VueUtils.mjs";
5
- import { Layer as c } from "../../../container/Layer.mjs";
6
- import { Animate as l } from "../../../animation/Animate.mjs";
7
- import { useBarContext as u } from "../hooks/useBar.mjs";
8
- import { Rectangle as d } from "../../../shape/Rectangle.mjs";
9
- import { Fragment as f, createVNode as p, defineComponent as m, isVNode as h } from "vue";
1
+ import { mouseLeaveItem, setActiveClickItemIndex, setActiveMouseOverItemIndex } from "../../../state/tooltipSlice.mjs";
2
+ import { selectActiveTooltipDataKey, selectActiveTooltipIndex } from "../../../state/selectors/tooltipSelectors.mjs";
3
+ import { useAppDispatch, useAppSelector } from "../../../state/hooks.mjs";
4
+ import { filterProps } from "../../../utils/VueUtils.mjs";
5
+ import { Layer } from "../../../container/Layer.mjs";
6
+ import { Animate } from "../../../animation/Animate.mjs";
7
+ import { useBarContext } from "../hooks/useBar.mjs";
8
+ import { Rectangle } from "../../../shape/Rectangle.mjs";
9
+ import { Fragment, createVNode, defineComponent, isVNode } from "vue";
10
10
  //#region src/cartesian/bar/components/BarRectangles.tsx
11
- function g(e) {
12
- return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !h(e);
11
+ function _isSlot(s) {
12
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
13
13
  }
14
- var _ = /* @__PURE__ */ m({
14
+ var BarRectangles = /* @__PURE__ */ defineComponent({
15
15
  name: "BarRectangles",
16
- inheritAttrs: !1,
17
- setup(m) {
18
- let h = a(), _ = o(i), v = o(r), y = null, b = 0, { props: x, data: S, layout: C, isAnimating: w, shapeSlot: T, activeBarSlot: E, cellProps: D } = u(), { dataKey: O, isAnimationActive: k, onAnimationStart: A, onAnimationEnd: j, activeBar: M, activeIndex: N } = x, P = (e, t) => (r) => {
19
- h(n({
20
- activeDataKey: O,
21
- activeIndex: String(t),
16
+ inheritAttrs: false,
17
+ setup(_) {
18
+ const dispatch = useAppDispatch();
19
+ const activeIndex = useAppSelector(selectActiveTooltipIndex);
20
+ const activeDataKey = useAppSelector(selectActiveTooltipDataKey);
21
+ let previousRectangles = null;
22
+ let animationId = 0;
23
+ const { props, data: barData, layout, isAnimating, shapeSlot, activeBarSlot, cellProps } = useBarContext();
24
+ const { dataKey, isAnimationActive, onAnimationStart, onAnimationEnd, activeBar, activeIndex: activeIndexProp } = props;
25
+ const onMouseEnterFromContext = (entry, index) => (e) => {
26
+ dispatch(setActiveMouseOverItemIndex({
27
+ activeDataKey: dataKey,
28
+ activeIndex: String(index),
22
29
  activeCoordinate: {
23
- x: e.tooltipPosition.x,
24
- y: e.tooltipPosition.y
30
+ x: entry.tooltipPosition.x,
31
+ y: entry.tooltipPosition.y
25
32
  }
26
33
  }));
27
- }, F = (t, n) => (t) => {
28
- h(e());
29
- }, I = (e, n) => (r) => {
30
- h(t({
31
- activeDataKey: O,
32
- activeIndex: String(n),
34
+ };
35
+ const onMouseLeaveFromContext = (entry, index) => (e) => {
36
+ dispatch(mouseLeaveItem());
37
+ };
38
+ const onClickFromContext = (entry, index) => (e) => {
39
+ dispatch(setActiveClickItemIndex({
40
+ activeDataKey: dataKey,
41
+ activeIndex: String(index),
33
42
  activeCoordinate: {
34
- x: e.tooltipPosition.x,
35
- y: e.tooltipPosition.y
43
+ x: entry.tooltipPosition.x,
44
+ y: entry.tooltipPosition.y
36
45
  }
37
46
  }));
38
- }, L = s(x, !1), R = (e, t) => (n) => e + (t - e) * n, z = (e) => e ? p(f, null, [e.map((e, t) => {
39
- let n, r = M !== !1 || N != null || !!E, i = N == null ? r && String(t) === _.value && (v.value == null || O === v.value) : r && t === N, a = i && typeof M == "object" ? M : {}, o = e.payload?.fill, s = D.value?.[t], l = {
40
- ...L,
41
- ...o ? { fill: o } : {},
42
- ...e,
43
- ...s ?? {},
44
- ...i ? a : {},
45
- isActive: i,
46
- index: t,
47
- dataKey: O
48
- };
49
- return p(c, {
50
- key: `rectangle-${e?.x}-${e?.y}-${e?.value}-${t}`,
51
- class: "v-charts-bar-rectangle",
52
- onMouseenter: P(e, t),
53
- onMouseleave: F(e, t),
54
- onClick: I(e, t)
55
- }, g(n = i && E ? E(l) : T ? T(l) : p(d, l, null)) ? n : { default: () => [n] });
56
- })]) : null;
47
+ };
48
+ const baseProps = filterProps(props, false);
49
+ const interpolateNumber = (from, to) => (t) => from + (to - from) * t;
50
+ const renderRectangles = (data) => {
51
+ if (!data) return null;
52
+ return createVNode(Fragment, null, [data.map((entry, i) => {
53
+ let _slot;
54
+ const activeEnabled = activeBar !== false || activeIndexProp != null || !!activeBarSlot;
55
+ const isActive = activeIndexProp != null ? activeEnabled && i === activeIndexProp : activeEnabled && String(i) === activeIndex.value && (activeDataKey.value == null || dataKey === activeDataKey.value);
56
+ const activeBarProps = isActive && typeof activeBar === "object" ? activeBar : {};
57
+ const entryFill = entry.payload?.fill;
58
+ const cellPropsForIndex = cellProps.value?.[i];
59
+ const barRectangleProps = {
60
+ ...baseProps,
61
+ ...entryFill ? { fill: entryFill } : {},
62
+ ...entry,
63
+ ...cellPropsForIndex ?? {},
64
+ ...isActive ? activeBarProps : {},
65
+ isActive,
66
+ index: i,
67
+ dataKey
68
+ };
69
+ const renderShape = () => {
70
+ if (isActive && activeBarSlot) return activeBarSlot(barRectangleProps);
71
+ if (shapeSlot) return shapeSlot(barRectangleProps);
72
+ return createVNode(Rectangle, barRectangleProps, null);
73
+ };
74
+ return createVNode(Layer, {
75
+ "key": `rectangle-${entry?.x}-${entry?.y}-${entry?.value}-${i}`,
76
+ "class": "v-charts-bar-rectangle",
77
+ "onMouseenter": onMouseEnterFromContext(entry, i),
78
+ "onMouseleave": onMouseLeaveFromContext(entry, i),
79
+ "onClick": onClickFromContext(entry, i)
80
+ }, _isSlot(_slot = renderShape()) ? _slot : { default: () => [_slot] });
81
+ })]);
82
+ };
57
83
  return () => {
58
- let e = S.value;
59
- if (!e) return null;
60
- if (k && y !== e) {
61
- let t = y;
62
- return b++, w.value = !0, p(l, {
63
- key: b,
64
- transition: x.transition,
65
- isActive: k,
66
- onAnimationStart: A,
67
- onAnimationEnd: () => {
68
- w.value = !1, j?.();
84
+ const data = barData.value;
85
+ if (!data) return null;
86
+ if (isAnimationActive && previousRectangles !== data) {
87
+ const prevData = previousRectangles;
88
+ animationId++;
89
+ isAnimating.value = true;
90
+ return createVNode(Animate, {
91
+ "key": animationId,
92
+ "transition": props.transition,
93
+ "isActive": isAnimationActive,
94
+ "onAnimationStart": onAnimationStart,
95
+ "onAnimationEnd": () => {
96
+ isAnimating.value = false;
97
+ onAnimationEnd?.();
69
98
  }
70
- }, { default: (n) => {
71
- let r = n === 1 ? e : e.map((e, r) => {
72
- let i = t?.[r];
73
- if (i && i.stackedBarStart === e.stackedBarStart) {
74
- let t = R(i.x || 0, e.x || 0), r = R(i.y || 0, e.y || 0), a = R(i.width, e.width), o = R(i.height, e.height);
99
+ }, { default: (t) => {
100
+ const stepData = t === 1 ? data : data.map((entry, index) => {
101
+ const prev = prevData?.[index];
102
+ if (prev && prev.stackedBarStart === entry.stackedBarStart) {
103
+ const interpolatorX = interpolateNumber(prev.x || 0, entry.x || 0);
104
+ const interpolatorY = interpolateNumber(prev.y || 0, entry.y || 0);
105
+ const interpolatorWidth = interpolateNumber(prev.width, entry.width);
106
+ const interpolatorHeight = interpolateNumber(prev.height, entry.height);
75
107
  return {
76
- ...e,
77
- x: t(n),
78
- y: r(n),
79
- width: a(n),
80
- height: o(n)
108
+ ...entry,
109
+ x: interpolatorX(t),
110
+ y: interpolatorY(t),
111
+ width: interpolatorWidth(t),
112
+ height: interpolatorHeight(t)
81
113
  };
82
114
  }
83
- if (C.value === "horizontal") {
84
- let t = R(0, e.height)(n), r = R(e.stackedBarStart, e.y)(n);
115
+ if (layout.value === "horizontal") {
116
+ const h = interpolateNumber(0, entry.height)(t);
117
+ const y = interpolateNumber(entry.stackedBarStart, entry.y)(t);
85
118
  return {
86
- ...e,
87
- y: r,
88
- height: t
119
+ ...entry,
120
+ y,
121
+ height: h
89
122
  };
90
123
  }
91
- let a = R(0, e.width)(n), o = R(e.stackedBarStart, e.x)(n);
124
+ const w = interpolateNumber(0, entry.width)(t);
125
+ const x = interpolateNumber(entry.stackedBarStart, entry.x)(t);
92
126
  return {
93
- ...e,
94
- width: a,
95
- x: o
127
+ ...entry,
128
+ width: w,
129
+ x
96
130
  };
97
131
  });
98
- return n > 0 && (y = r), p("g", null, [z(r)]);
132
+ if (t > 0) previousRectangles = stepData;
133
+ return createVNode("g", null, [renderRectangles(stepData)]);
99
134
  } });
100
135
  }
101
- return w.value = !1, y = e, p("g", null, [z(e)]);
136
+ isAnimating.value = false;
137
+ previousRectangles = data;
138
+ return createVNode("g", null, [renderRectangles(data)]);
102
139
  };
103
140
  }
104
141
  });
105
142
  //#endregion
106
- export { _ as BarRectangles };
143
+ export { BarRectangles };
@@ -1,41 +1,53 @@
1
- import { uniqueId as e } from "../../../utils/data-utils.mjs";
2
- import { useIsPanorama as t } from "../../../context/PanoramaContextProvider.mjs";
3
- import { getNormalizedStackId as n } from "../../../utils/chart.mjs";
4
- import { useAppSelector as r } from "../../../state/hooks.mjs";
5
- import { useChartLayout as i } from "../../../context/chartLayoutContext.mjs";
6
- import { useNeedsClip as a } from "../../useNeedsClip.mjs";
7
- import { selectBarRectangles as o } from "../../../state/selectors/barSelectors.mjs";
8
- import { computed as s, ref as c, shallowRef as l, useAttrs as u } from "vue";
9
- import { createContext as d } from "motion-v";
1
+ import { uniqueId } from "../../../utils/data-utils.mjs";
2
+ import { useIsPanorama } from "../../../context/PanoramaContextProvider.mjs";
3
+ import { getNormalizedStackId } from "../../../utils/chart.mjs";
4
+ import { useAppSelector } from "../../../state/hooks.mjs";
5
+ import { useChartLayout } from "../../../context/chartLayoutContext.mjs";
6
+ import { useNeedsClip } from "../../useNeedsClip.mjs";
7
+ import { selectBarRectangles } from "../../../state/selectors/barSelectors.mjs";
8
+ import { computed, ref, shallowRef, useAttrs } from "vue";
9
+ import { createContext } from "motion-v";
10
10
  //#region src/cartesian/bar/hooks/useBar.ts
11
- var [f, p] = d("BarContext");
12
- function m(d, f, m) {
13
- let h = t(), g = u(), _ = i(), { needClip: v } = a(d.xAxisId, d.yAxisId), y = s(() => ({
14
- barSize: d.barSize,
15
- data: d.data,
16
- dataKey: d.dataKey,
17
- maxBarSize: d.maxBarSize,
18
- minPointSize: d.minPointSize,
19
- stackId: n(d.stackId)
20
- })), b = r((e) => o(e, d.xAxisId, d.yAxisId, h, y.value)), x = s(() => (_.value === "vertical" || _.value === "horizontal") && !d.hide), S = e("v-charts-bar-"), C = c(!1), w = l([]);
21
- return p({
22
- clipPathId: S,
23
- layout: _,
24
- props: d,
25
- attrs: g,
26
- data: b,
27
- isAnimating: C,
28
- shapeSlot: f,
29
- activeBarSlot: m,
30
- cellProps: w
31
- }), {
32
- shouldRender: x,
33
- needClip: v,
34
- clipPathId: S,
35
- barData: b,
36
- isAnimating: C,
37
- cellProps: w
11
+ var [useBarContext, provideBarContext] = createContext("BarContext");
12
+ function useBar(props, shapeSlot, activeBarSlot) {
13
+ const isPanorama = useIsPanorama();
14
+ const attrs = useAttrs();
15
+ const layout = useChartLayout();
16
+ const { needClip } = useNeedsClip(props.xAxisId, props.yAxisId);
17
+ const barSettings = computed(() => ({
18
+ barSize: props.barSize,
19
+ data: props.data,
20
+ dataKey: props.dataKey,
21
+ maxBarSize: props.maxBarSize,
22
+ minPointSize: props.minPointSize,
23
+ stackId: getNormalizedStackId(props.stackId)
24
+ }));
25
+ const rects = useAppSelector((state) => selectBarRectangles(state, props.xAxisId, props.yAxisId, isPanorama, barSettings.value));
26
+ const shouldRender = computed(() => {
27
+ return (layout.value === "vertical" || layout.value === "horizontal") && !props.hide;
28
+ });
29
+ const clipPathId = uniqueId("v-charts-bar-");
30
+ const isAnimating = ref(false);
31
+ const cellPropsRef = shallowRef([]);
32
+ provideBarContext({
33
+ clipPathId,
34
+ layout,
35
+ props,
36
+ attrs,
37
+ data: rects,
38
+ isAnimating,
39
+ shapeSlot,
40
+ activeBarSlot,
41
+ cellProps: cellPropsRef
42
+ });
43
+ return {
44
+ shouldRender,
45
+ needClip,
46
+ clipPathId,
47
+ barData: rects,
48
+ isAnimating,
49
+ cellProps: cellPropsRef
38
50
  };
39
51
  }
40
52
  //#endregion
41
- export { m as useBar, f as useBarContext };
53
+ export { useBar, useBarContext };
@@ -1,9 +1,7 @@
1
+ import { classProp } from "../../types/common.mjs";
1
2
  //#region src/cartesian/bar/type.ts
2
- var e = {
3
- class: {
4
- type: String,
5
- default: void 0
6
- },
3
+ var BarVueProps = {
4
+ class: classProp,
7
5
  barSize: { type: [String, Number] },
8
6
  data: {
9
7
  type: Array,
@@ -15,7 +13,7 @@ var e = {
15
13
  Number,
16
14
  Function
17
15
  ],
18
- required: !0
16
+ required: true
19
17
  },
20
18
  fill: {
21
19
  type: String,
@@ -49,11 +47,11 @@ var e = {
49
47
  maxBarSize: { type: Number },
50
48
  hide: {
51
49
  type: Boolean,
52
- default: !1
50
+ default: false
53
51
  },
54
52
  background: {
55
53
  type: [Boolean, Object],
56
- default: !1
54
+ default: false
57
55
  },
58
56
  radius: {
59
57
  type: [Number, Array],
@@ -69,7 +67,7 @@ var e = {
69
67
  },
70
68
  isAnimationActive: {
71
69
  type: Boolean,
72
- default: !0
70
+ default: true
73
71
  },
74
72
  activeBar: {
75
73
  type: [
@@ -77,7 +75,7 @@ var e = {
77
75
  Boolean,
78
76
  Function
79
77
  ],
80
- default: !1
78
+ default: false
81
79
  },
82
80
  activeIndex: {
83
81
  type: Number,
@@ -99,18 +97,6 @@ var e = {
99
97
  type: [String, Number],
100
98
  default: 0
101
99
  },
102
- animationBegin: {
103
- type: Number,
104
- default: 0
105
- },
106
- animationDuration: {
107
- type: Number,
108
- default: 1500
109
- },
110
- animationEasing: {
111
- type: String,
112
- default: "ease"
113
- },
114
100
  transition: {
115
101
  type: Object,
116
102
  default: {
@@ -120,12 +106,12 @@ var e = {
120
106
  },
121
107
  needClip: {
122
108
  type: Boolean,
123
- default: !1
109
+ default: false
124
110
  },
125
111
  label: {
126
112
  type: [Boolean, Object],
127
- default: !1
113
+ default: false
128
114
  }
129
115
  };
130
116
  //#endregion
131
- export { e as BarVueProps };
117
+ export { BarVueProps };
@@ -1,84 +1,111 @@
1
- import { isNullish as e, isNumber as t } from "../../utils/validate.mjs";
2
- import { mathSign as n } from "../../utils/data.mjs";
3
- import { getBaseValueOfBar as r, getCateCoordinateOfBar as i, getValueByDataKey as a, truncateByDomain as o } from "../../utils/chart.mjs";
4
- import { toRaw as s } from "vue";
5
- import { isNaN as c } from "es-toolkit/compat";
6
- import { invariant as l } from "es-toolkit";
1
+ import { isNullish, isNumber } from "../../utils/validate.mjs";
2
+ import { mathSign } from "../../utils/data.mjs";
3
+ import { getBaseValueOfBar, getCateCoordinateOfBar, getValueByDataKey, truncateByDomain } from "../../utils/chart.mjs";
4
+ import { toRaw } from "vue";
5
+ import { isNaN } from "es-toolkit/compat";
6
+ import { invariant } from "es-toolkit";
7
7
  //#region src/cartesian/bar/utils.ts
8
- function u(n, r = 0) {
9
- return (i, a) => {
10
- if (t(n)) return n;
11
- let o = t(i) || e(i);
12
- return o ? n(i, a) : (l(o, `minPointSize callback function received a value with type of ${typeof i}. Currently only numbers or null/undefined are supported.`), r);
8
+ /**
9
+ * Safely gets minPointSize from the minPointSize prop if it is a function
10
+ * @param minPointSize minPointSize as passed to the Bar component
11
+ * @param defaultValue default minPointSize
12
+ * @returns minPointSize
13
+ */
14
+ function minPointSizeCallback(minPointSize, defaultValue = 0) {
15
+ return (value, index) => {
16
+ if (isNumber(minPointSize)) return minPointSize;
17
+ const isValueNumberOrNil = isNumber(value) || isNullish(value);
18
+ if (isValueNumberOrNil) return minPointSize(value, index);
19
+ invariant(isValueNumberOrNil, `minPointSize callback function received a value with type of ${typeof value}. Currently only numbers or null/undefined are supported.`);
20
+ return defaultValue;
13
21
  };
14
22
  }
15
- var d = 0;
16
- function f({ layout: e, barSettings: { dataKey: t, minPointSize: l }, pos: f, bandSize: p, xAxis: m, yAxis: h, xAxisTicks: g, yAxisTicks: _, stackedData: v, displayedData: y, offset: b }) {
17
- let x = {
18
- x: b.left,
19
- y: b.top,
20
- width: b.width,
21
- height: b.height
22
- }, S = e === "horizontal" ? h : m, C = v ? S.scale.domain() : null, w = r({ numericAxis: S }), T = S.scale(w);
23
- return y.map((r, y) => {
24
- let S = s(r), E, D, O, k, A, j;
25
- v ? E = o(v[y], C) : (E = a(S, t), Array.isArray(E) || (E = [w, E]));
26
- let M = u(l, d)(E[1], y);
27
- if (e === "horizontal") {
28
- let [e, t] = [h.scale(E[0]), h.scale(E[1])];
29
- D = i({
30
- axis: m,
31
- ticks: g,
32
- bandSize: p,
33
- offset: f.offset,
34
- entry: S,
35
- index: y
36
- }), O = t ?? e ?? void 0, k = f.size;
37
- let r = e - t;
38
- if (A = c(r) ? 0 : r, j = {
39
- x: D,
40
- y: b.top,
41
- width: k,
42
- height: b.height
43
- }, Math.abs(M) > 0 && Math.abs(A) < Math.abs(M)) {
44
- let e = n(A || M) * (Math.abs(M) - Math.abs(A));
45
- O -= e, A += e;
23
+ var defaultMinPointSize = 0;
24
+ function computeBarRectangles({ layout, barSettings: { dataKey, minPointSize: minPointSizeProp }, pos, bandSize, xAxis, yAxis, xAxisTicks, yAxisTicks, stackedData, displayedData, offset }) {
25
+ const parentViewBox = {
26
+ x: offset.left,
27
+ y: offset.top,
28
+ width: offset.width,
29
+ height: offset.height
30
+ };
31
+ const numericAxis = layout === "horizontal" ? yAxis : xAxis;
32
+ const stackedDomain = stackedData ? numericAxis.scale.domain() : null;
33
+ const baseValue = getBaseValueOfBar({ numericAxis });
34
+ const stackedBarStart = numericAxis.scale(baseValue);
35
+ return displayedData.map((rawEntry, index) => {
36
+ const entry = toRaw(rawEntry);
37
+ let value, x, y, width, height, background;
38
+ if (stackedData) value = truncateByDomain(stackedData[index], stackedDomain);
39
+ else {
40
+ value = getValueByDataKey(entry, dataKey);
41
+ if (!Array.isArray(value)) value = [baseValue, value];
42
+ }
43
+ const minPointSize = minPointSizeCallback(minPointSizeProp, defaultMinPointSize)(value[1], index);
44
+ if (layout === "horizontal") {
45
+ const [baseValueScale, currentValueScale] = [yAxis.scale(value[0]), yAxis.scale(value[1])];
46
+ x = getCateCoordinateOfBar({
47
+ axis: xAxis,
48
+ ticks: xAxisTicks,
49
+ bandSize,
50
+ offset: pos.offset,
51
+ entry,
52
+ index
53
+ });
54
+ y = currentValueScale ?? baseValueScale ?? void 0;
55
+ width = pos.size;
56
+ const computedHeight = baseValueScale - currentValueScale;
57
+ height = isNaN(computedHeight) ? 0 : computedHeight;
58
+ background = {
59
+ x,
60
+ y: offset.top,
61
+ width,
62
+ height: offset.height
63
+ };
64
+ if (Math.abs(minPointSize) > 0 && Math.abs(height) < Math.abs(minPointSize)) {
65
+ const delta = mathSign(height || minPointSize) * (Math.abs(minPointSize) - Math.abs(height));
66
+ y -= delta;
67
+ height += delta;
46
68
  }
47
69
  } else {
48
- let [e, t] = [m.scale(E[0]), m.scale(E[1])];
49
- if (D = e, O = i({
50
- axis: h,
51
- ticks: _,
52
- bandSize: p,
53
- offset: f.offset,
54
- entry: S,
55
- index: y
56
- }), k = t - e, A = f.size, j = {
57
- x: b.left,
58
- y: O,
59
- width: b.width,
60
- height: A
61
- }, Math.abs(M) > 0 && Math.abs(k) < Math.abs(M)) {
62
- let e = n(k || M) * (Math.abs(M) - Math.abs(k));
63
- k += e;
70
+ const [baseValueScale, currentValueScale] = [xAxis.scale(value[0]), xAxis.scale(value[1])];
71
+ x = baseValueScale;
72
+ y = getCateCoordinateOfBar({
73
+ axis: yAxis,
74
+ ticks: yAxisTicks,
75
+ bandSize,
76
+ offset: pos.offset,
77
+ entry,
78
+ index
79
+ });
80
+ width = currentValueScale - baseValueScale;
81
+ height = pos.size;
82
+ background = {
83
+ x: offset.left,
84
+ y,
85
+ width: offset.width,
86
+ height
87
+ };
88
+ if (Math.abs(minPointSize) > 0 && Math.abs(width) < Math.abs(minPointSize)) {
89
+ const delta = mathSign(width || minPointSize) * (Math.abs(minPointSize) - Math.abs(width));
90
+ width += delta;
64
91
  }
65
92
  }
66
93
  return {
67
- x: D,
68
- y: O,
69
- width: k,
70
- height: A,
71
- stackedBarStart: T ?? 0,
72
- value: v ? E : E[1],
73
- payload: S,
74
- background: j,
94
+ x,
95
+ y,
96
+ width,
97
+ height,
98
+ stackedBarStart: stackedBarStart ?? 0,
99
+ value: stackedData ? value : value[1],
100
+ payload: entry,
101
+ background,
75
102
  tooltipPosition: {
76
- x: D + k / 2,
77
- y: O + A / 2
103
+ x: x + width / 2,
104
+ y: y + height / 2
78
105
  },
79
- parentViewBox: x
106
+ parentViewBox
80
107
  };
81
108
  });
82
109
  }
83
110
  //#endregion
84
- export { f as computeBarRectangles };
111
+ export { computeBarRectangles };