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,89 +1,111 @@
1
- import { getValueByDataKey as e } from "../../utils/chart.mjs";
2
- import { useChartLayout as t } from "../../context/chartLayoutContext.mjs";
3
- import { Layer as n } from "../../container/Layer.mjs";
4
- import { provideCartesianLabelListData as r } from "../../context/cartesianLabelListContext.mjs";
5
- import { LabelList as i } from "../../components/label/LabelList.mjs";
6
- import { useSetupGraphicalItem as a } from "../../hooks/useSetupGraphicalItem.mjs";
7
- import { useGraphicalLayerRef as o } from "../../context/graphicalLayerContext.mjs";
8
- import { BarVueProps as s } from "./type.mjs";
9
- import { useNeedsClip as c } from "../useNeedsClip.mjs";
10
- import { useBar as l } from "./hooks/useBar.mjs";
11
- import { GraphicalItemClipPath as u } from "../GraphicalItemClipPath.mjs";
12
- import { BarBackground as d } from "./components/BarBackground.mjs";
13
- import { BarRectangles as f } from "./components/BarRectangles.mjs";
14
- import { createErrorBarRegistry as p, provideErrorBarContext as m, provideErrorBarRegistry as h } from "../error-bar/ErrorBarContext.mjs";
15
- import { Cell as g } from "../../components/Cell.mjs";
16
- import { Fragment as _, Teleport as v, computed as y, createVNode as b, defineComponent as x, isVNode as S, mergeProps as C } from "vue";
1
+ import { getValueByDataKey } from "../../utils/chart.mjs";
2
+ import { useChartLayout } from "../../context/chartLayoutContext.mjs";
3
+ import { Layer } from "../../container/Layer.mjs";
4
+ import { provideCartesianLabelListData } from "../../context/cartesianLabelListContext.mjs";
5
+ import { LabelList } from "../../components/label/LabelList.mjs";
6
+ import { useSetupGraphicalItem } from "../../hooks/useSetupGraphicalItem.mjs";
7
+ import { useGraphicalLayerRef } from "../../context/graphicalLayerContext.mjs";
8
+ import { BarVueProps } from "./type.mjs";
9
+ import { useNeedsClip } from "../useNeedsClip.mjs";
10
+ import { useBar } from "./hooks/useBar.mjs";
11
+ import { GraphicalItemClipPath } from "../GraphicalItemClipPath.mjs";
12
+ import { BarBackground } from "./components/BarBackground.mjs";
13
+ import { BarRectangles } from "./components/BarRectangles.mjs";
14
+ import { createErrorBarRegistry, provideErrorBarContext, provideErrorBarRegistry } from "../error-bar/ErrorBarContext.mjs";
15
+ import { Cell } from "../../components/Cell.mjs";
16
+ import { Fragment, Teleport, computed, createVNode, defineComponent, isVNode, mergeProps } from "vue";
17
17
  //#region src/cartesian/bar/Bar.tsx
18
- function w(e) {
19
- return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !S(e);
18
+ function _isSlot(s) {
19
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
20
20
  }
21
- var T = (t, n) => {
22
- let r = Array.isArray(t.value) ? t.value[1] : t.value;
21
+ var errorBarDataPointFormatter = (dataPoint, dataKey) => {
22
+ const value = Array.isArray(dataPoint.value) ? dataPoint.value[1] : dataPoint.value;
23
23
  return {
24
- x: t.x,
25
- y: t.y,
26
- value: r,
27
- errorVal: e(t.payload ?? t, n)
24
+ x: dataPoint.x,
25
+ y: dataPoint.y,
26
+ value,
27
+ errorVal: getValueByDataKey(dataPoint.payload ?? dataPoint, dataKey)
28
28
  };
29
- }, E = /* @__PURE__ */ x({
29
+ };
30
+ var Bar = /* @__PURE__ */ defineComponent({
30
31
  name: "Bar",
31
- props: s,
32
- inheritAttrs: !1,
32
+ props: BarVueProps,
33
+ inheritAttrs: false,
33
34
  slots: Object,
34
- setup(e, { attrs: s, slots: x }) {
35
- let S = p();
36
- h(S), a(e, "bar", { errorBars: S.errorBars });
37
- let { shouldRender: E, clipPathId: D, barData: O, isAnimating: k, cellProps: A } = l(e, x.shape, x.activeBar), { needClip: j } = c(e.xAxisId, e.yAxisId), M = t(), N = y(() => {
38
- let e = O.value?.[0];
39
- return e == null || e.height == null || e.width == null ? 0 : M.value === "vertical" ? e.height / 2 : e.width / 2;
35
+ setup(props, { attrs, slots }) {
36
+ const errorBarRegistry = createErrorBarRegistry();
37
+ provideErrorBarRegistry(errorBarRegistry);
38
+ useSetupGraphicalItem(props, "bar", { errorBars: errorBarRegistry.errorBars });
39
+ const { shouldRender, clipPathId, barData, isAnimating, cellProps: cellPropsRef } = useBar(props, slots.shape, slots.activeBar);
40
+ const { needClip } = useNeedsClip(props.xAxisId, props.yAxisId);
41
+ const layout = useChartLayout();
42
+ const errorBarOffset = computed(() => {
43
+ const first = barData.value?.[0];
44
+ if (first == null || first.height == null || first.width == null) return 0;
45
+ return layout.value === "vertical" ? first.height / 2 : first.width / 2;
40
46
  });
41
- m({
42
- data: O,
43
- xAxisId: e.xAxisId ?? "xAxis-0",
44
- yAxisId: e.yAxisId ?? "yAxis-0",
45
- dataPointFormatter: T,
46
- errorBarOffset: N
47
- }), r(y(() => {
48
- if (!(k.value || !O.value)) return O.value.map((t, n) => {
49
- let r = A.value?.[n]?.fill ?? t.payload?.fill ?? e.fill;
47
+ provideErrorBarContext({
48
+ data: barData,
49
+ xAxisId: props.xAxisId ?? "xAxis-0",
50
+ yAxisId: props.yAxisId ?? "yAxis-0",
51
+ dataPointFormatter: errorBarDataPointFormatter,
52
+ errorBarOffset
53
+ });
54
+ provideCartesianLabelListData(computed(() => {
55
+ if (isAnimating.value || !barData.value) return void 0;
56
+ return barData.value.map((entry, i) => {
57
+ const fill = cellPropsRef.value?.[i]?.fill ?? entry.payload?.fill ?? props.fill;
50
58
  return {
51
- x: t.x,
52
- y: t.y,
53
- width: t.width,
54
- height: t.height,
55
- value: t.value,
56
- payload: t.payload,
57
- parentViewBox: t.parentViewBox,
58
- ...r == null ? {} : { fill: r }
59
+ x: entry.x,
60
+ y: entry.y,
61
+ width: entry.width,
62
+ height: entry.height,
63
+ value: entry.value,
64
+ payload: entry.payload,
65
+ parentViewBox: entry.parentViewBox,
66
+ ...fill != null ? { fill } : {}
59
67
  };
60
68
  });
61
69
  }));
62
- let P = o(null), F = (e) => {
63
- let t = [];
64
- for (let n of e) n.type === g ? t.push(n.props ?? {}) : n.type === _ && Array.isArray(n.children) && t.push(...F(n.children));
65
- return t;
66
- }, I = (e) => e.filter((e) => !(e.type === g || e.type === _ && Array.isArray(e.children) && e.children.some((e) => e.type === g)));
70
+ const graphicalLayerRef = useGraphicalLayerRef(null);
71
+ const extractCellProps = (vnodes) => {
72
+ const result = [];
73
+ for (const vnode of vnodes) if (vnode.type === Cell) result.push(vnode.props ?? {});
74
+ else if (vnode.type === Fragment && Array.isArray(vnode.children)) result.push(...extractCellProps(vnode.children));
75
+ return result;
76
+ };
77
+ const filterOutCells = (vnodes) => {
78
+ const result = [];
79
+ for (const vnode of vnodes) {
80
+ if (vnode.type === Cell) continue;
81
+ if (vnode.type === Fragment && Array.isArray(vnode.children)) result.push(...filterOutCells(vnode.children));
82
+ else result.push(vnode);
83
+ }
84
+ return result;
85
+ };
67
86
  return () => {
68
- if (!E.value) return null;
69
- let t = x.default?.() ?? [], r = F(t);
70
- A.value = r;
71
- let a = r.length > 0 ? I(t) : t, o = b(n, { class: ["v-charts-bar", s.class] }, { default: () => [
72
- j.value && b("defs", null, [b(u, {
73
- clipPathId: D,
74
- xAxisId: e.xAxisId,
75
- yAxisId: e.yAxisId
87
+ if (!shouldRender.value) return null;
88
+ const defaultContent = slots.default?.() ?? [];
89
+ const cells = extractCellProps(defaultContent);
90
+ cellPropsRef.value = cells;
91
+ const nonCellContent = cells.length > 0 ? filterOutCells(defaultContent) : defaultContent;
92
+ const barContent = createVNode(Layer, { "class": ["v-charts-bar", attrs.class] }, { default: () => [
93
+ needClip.value && createVNode("defs", null, [createVNode(GraphicalItemClipPath, {
94
+ "clipPathId": clipPathId,
95
+ "xAxisId": props.xAxisId,
96
+ "yAxisId": props.yAxisId
76
97
  }, null)]),
77
- b(n, {
78
- class: "v-charts-bar-rectangles",
79
- "clip-path": j.value ? `url(#clipPath-${D})` : null
80
- }, { default: () => [e.background && b(d, null, null), b(f, null, null)] }),
81
- !k.value && e.label && b(i, C(typeof e.label == "object" ? e.label : {}, { data: O.value }), null),
82
- a
98
+ createVNode(Layer, {
99
+ "class": "v-charts-bar-rectangles",
100
+ "clip-path": needClip.value ? `url(#clipPath-${clipPathId})` : null
101
+ }, { default: () => [props.background && createVNode(BarBackground, null, null), createVNode(BarRectangles, null, null)] }),
102
+ !isAnimating.value && props.label && createVNode(LabelList, mergeProps(typeof props.label === "object" ? props.label : {}, { "data": barData.value }), null),
103
+ nonCellContent
83
104
  ] });
84
- return P?.value ? b(v, { to: P.value }, w(o) ? o : { default: () => [o] }) : o;
105
+ if (graphicalLayerRef?.value) return createVNode(Teleport, { "to": graphicalLayerRef.value }, _isSlot(barContent) ? barContent : { default: () => [barContent] });
106
+ return barContent;
85
107
  };
86
108
  }
87
109
  });
88
110
  //#endregion
89
- export { E as Bar };
111
+ export { Bar };
@@ -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,5 +1,5 @@
1
1
  //#region src/cartesian/bar/type.ts
2
- var e = {
2
+ var BarVueProps = {
3
3
  class: {
4
4
  type: String,
5
5
  default: void 0
@@ -15,7 +15,7 @@ var e = {
15
15
  Number,
16
16
  Function
17
17
  ],
18
- required: !0
18
+ required: true
19
19
  },
20
20
  fill: {
21
21
  type: String,
@@ -49,11 +49,11 @@ var e = {
49
49
  maxBarSize: { type: Number },
50
50
  hide: {
51
51
  type: Boolean,
52
- default: !1
52
+ default: false
53
53
  },
54
54
  background: {
55
55
  type: [Boolean, Object],
56
- default: !1
56
+ default: false
57
57
  },
58
58
  radius: {
59
59
  type: [Number, Array],
@@ -69,7 +69,7 @@ var e = {
69
69
  },
70
70
  isAnimationActive: {
71
71
  type: Boolean,
72
- default: !0
72
+ default: true
73
73
  },
74
74
  activeBar: {
75
75
  type: [
@@ -77,7 +77,7 @@ var e = {
77
77
  Boolean,
78
78
  Function
79
79
  ],
80
- default: !1
80
+ default: false
81
81
  },
82
82
  activeIndex: {
83
83
  type: Number,
@@ -120,12 +120,12 @@ var e = {
120
120
  },
121
121
  needClip: {
122
122
  type: Boolean,
123
- default: !1
123
+ default: false
124
124
  },
125
125
  label: {
126
126
  type: [Boolean, Object],
127
- default: !1
127
+ default: false
128
128
  }
129
129
  };
130
130
  //#endregion
131
- export { e as BarVueProps };
131
+ export { BarVueProps };