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
@@ -0,0 +1,379 @@
1
+ import { addTooltipEntrySettings, mouseLeaveItem, removeTooltipEntrySettings, setActiveClickItemIndex, setActiveMouseOverItemIndex } from "../state/tooltipSlice.mjs";
2
+ import { useAppDispatch } from "../state/hooks.mjs";
3
+ import { Layer } from "../container/Layer.mjs";
4
+ import { getStringSize } from "../utils/attrs.mjs";
5
+ import { Animate } from "../animation/Animate.mjs";
6
+ import { createRechartsStore } from "../state/store.mjs";
7
+ import { RechartsWrapper } from "./RechartsWrapper.mjs";
8
+ import Surface from "../container/Surface.mjs";
9
+ import { computeTreemapLayout } from "./treemapUtils.mjs";
10
+ import { Fragment, computed, createTextVNode, createVNode, defineComponent, ref, watchEffect } from "vue";
11
+ import { provideStore } from "@reduxjs/vue-redux";
12
+ import { get } from "lodash-es";
13
+ //#region src/chart/Treemap.tsx
14
+ var DEFAULT_COLORS = [
15
+ "#8889DD",
16
+ "#9597E4",
17
+ "#8DC77B",
18
+ "#A5D297",
19
+ "#E2CF45",
20
+ "#F8C12D",
21
+ "#F89C24",
22
+ "#F56E1A"
23
+ ];
24
+ /**
25
+ * Recursively sum all descendant values for a given dataKey.
26
+ */
27
+ function sumValues(item, dataKey) {
28
+ if (item.children && item.children.length > 0) return item.children.reduce((sum, child) => sum + sumValues(child, dataKey), 0);
29
+ const val = item[dataKey];
30
+ return typeof val === "number" && val > 0 ? val : 0;
31
+ }
32
+ /**
33
+ * Tooltip payload searcher for Treemap — navigates nested node structure
34
+ * using a path string like 'children[0].children[1]'.
35
+ */
36
+ var treemapPayloadSearcher = (data, activeIndex) => {
37
+ if (!data || !activeIndex) return void 0;
38
+ return get(data, activeIndex);
39
+ };
40
+ var treemapOptions = {
41
+ chartName: "Treemap",
42
+ defaultTooltipEventType: "item",
43
+ validateTooltipEventTypes: ["item"],
44
+ tooltipPayloadSearcher: treemapPayloadSearcher,
45
+ eventEmitter: void 0
46
+ };
47
+ /**
48
+ * Build a hierarchical node structure with tooltipIndex paths for tooltip lookup.
49
+ */
50
+ function buildNodeTree(data, dataKey, nameKey, parentIndex = "") {
51
+ return {
52
+ children: data.map((item, i) => {
53
+ const tooltipIndex = `${parentIndex}children[${i}]`;
54
+ if (item.children && item.children.length > 0) {
55
+ const childTree = buildNodeTree(item.children, dataKey, nameKey, `${tooltipIndex}.`);
56
+ return {
57
+ ...item,
58
+ tooltipIndex,
59
+ ...childTree
60
+ };
61
+ }
62
+ return {
63
+ ...item,
64
+ tooltipIndex,
65
+ value: sumValues(item, dataKey)
66
+ };
67
+ }),
68
+ name: "root",
69
+ tooltipIndex: parentIndex
70
+ };
71
+ }
72
+ var TreemapVueProps = {
73
+ data: {
74
+ type: Array,
75
+ required: true
76
+ },
77
+ dataKey: {
78
+ type: String,
79
+ default: "value"
80
+ },
81
+ nameKey: {
82
+ type: String,
83
+ default: "name"
84
+ },
85
+ width: {
86
+ type: Number,
87
+ required: true
88
+ },
89
+ height: {
90
+ type: Number,
91
+ required: true
92
+ },
93
+ aspectRatio: {
94
+ type: Number,
95
+ default: 4 / 3
96
+ },
97
+ fill: {
98
+ type: String,
99
+ default: "#808080"
100
+ },
101
+ stroke: {
102
+ type: String,
103
+ default: "#fff"
104
+ },
105
+ type: {
106
+ type: String,
107
+ default: "flat"
108
+ },
109
+ colorPanel: {
110
+ type: Array,
111
+ default: void 0
112
+ },
113
+ isAnimationActive: {
114
+ type: Boolean,
115
+ default: true
116
+ },
117
+ transition: {
118
+ type: Object,
119
+ default: () => ({
120
+ duration: .8,
121
+ ease: "easeOut"
122
+ })
123
+ },
124
+ onClick: {
125
+ type: Function,
126
+ default: void 0
127
+ },
128
+ onMouseEnter: {
129
+ type: Function,
130
+ default: void 0
131
+ },
132
+ onMouseLeave: {
133
+ type: Function,
134
+ default: void 0
135
+ }
136
+ };
137
+ /**
138
+ * Inner component that has access to the Redux store (provided by Treemap wrapper).
139
+ */
140
+ var TreemapInner = /* @__PURE__ */ defineComponent({
141
+ name: "TreemapInner",
142
+ props: TreemapVueProps,
143
+ slots: Object,
144
+ setup(props, { slots }) {
145
+ const dispatch = useAppDispatch();
146
+ const colors = computed(() => props.colorPanel ?? DEFAULT_COLORS);
147
+ const breadcrumbTrail = ref([]);
148
+ const currentData = ref(null);
149
+ const animationKey = ref(0);
150
+ const isNestMode = computed(() => props.type === "nest");
151
+ const nestCurrentData = computed(() => {
152
+ if (!isNestMode.value) return null;
153
+ return currentData.value ?? props.data;
154
+ });
155
+ function computeNestLevelData(data) {
156
+ return data.map((item) => {
157
+ const aggregatedValue = sumValues(item, props.dataKey);
158
+ const { children: _, ...rest } = item;
159
+ return {
160
+ ...rest,
161
+ [props.dataKey]: aggregatedValue
162
+ };
163
+ });
164
+ }
165
+ const nodes = computed(() => {
166
+ return computeTreemapLayout({
167
+ data: isNestMode.value ? computeNestLevelData(nestCurrentData.value ?? props.data) : props.data,
168
+ width: props.width,
169
+ height: props.height,
170
+ dataKey: props.dataKey,
171
+ nameKey: props.nameKey,
172
+ aspectRatio: props.aspectRatio,
173
+ colorPanel: colors.value
174
+ });
175
+ });
176
+ const nodeTree = computed(() => {
177
+ return buildNodeTree(isNestMode.value ? nestCurrentData.value ?? props.data : props.data, props.dataKey, props.nameKey);
178
+ });
179
+ watchEffect((onCleanup) => {
180
+ const tooltipEntrySettings = {
181
+ dataDefinedOnItem: nodeTree.value,
182
+ positions: void 0,
183
+ settings: {
184
+ stroke: props.stroke,
185
+ strokeWidth: void 0,
186
+ fill: props.fill,
187
+ dataKey: props.dataKey,
188
+ nameKey: props.nameKey,
189
+ name: void 0,
190
+ hide: false,
191
+ type: void 0,
192
+ color: props.fill,
193
+ unit: ""
194
+ }
195
+ };
196
+ dispatch(addTooltipEntrySettings(tooltipEntrySettings));
197
+ onCleanup(() => {
198
+ dispatch(removeTooltipEntrySettings(tooltipEntrySettings));
199
+ });
200
+ });
201
+ function getTooltipIndex(node) {
202
+ const data = isNestMode.value ? nestCurrentData.value ?? props.data : props.data;
203
+ const idx = data.findIndex((item) => item[props.nameKey] === node.name);
204
+ if (idx >= 0) return `children[${idx}]`;
205
+ for (let i = 0; i < data.length; i++) if (data[i].children) {
206
+ const childIdx = data[i].children.findIndex((c) => c[props.nameKey] === node.name);
207
+ if (childIdx >= 0) return `children[${i}].children[${childIdx}]`;
208
+ }
209
+ return `children[0]`;
210
+ }
211
+ function handleNestClick(node, e) {
212
+ const sourceData = nestCurrentData.value ?? props.data;
213
+ const clickedItem = sourceData.find((item) => item[props.nameKey] === node.name);
214
+ if (clickedItem?.children && clickedItem.children.length > 0) {
215
+ breadcrumbTrail.value = [...breadcrumbTrail.value, {
216
+ name: clickedItem[props.nameKey] ?? clickedItem.name,
217
+ data: sourceData
218
+ }];
219
+ currentData.value = clickedItem.children;
220
+ animationKey.value++;
221
+ }
222
+ props.onClick?.(node, e);
223
+ }
224
+ function navigateToBreadcrumb(index) {
225
+ if (index < 0) {
226
+ currentData.value = null;
227
+ breadcrumbTrail.value = [];
228
+ } else {
229
+ currentData.value = breadcrumbTrail.value[index].data;
230
+ breadcrumbTrail.value = breadcrumbTrail.value.slice(0, index);
231
+ }
232
+ animationKey.value++;
233
+ }
234
+ function getNodeFill(node) {
235
+ return node.color ?? props.fill;
236
+ }
237
+ function handleNodeMouseEnter(node, e) {
238
+ const tooltipIndex = getTooltipIndex(node);
239
+ const activeCoordinate = {
240
+ x: node.x + node.width / 2,
241
+ y: node.y + node.height / 2
242
+ };
243
+ dispatch(setActiveMouseOverItemIndex({
244
+ activeIndex: tooltipIndex,
245
+ activeDataKey: props.dataKey,
246
+ activeCoordinate
247
+ }));
248
+ props.onMouseEnter?.(node, e);
249
+ }
250
+ function handleNodeMouseLeave(node, e) {
251
+ dispatch(mouseLeaveItem());
252
+ props.onMouseLeave?.(node, e);
253
+ }
254
+ function handleNodeClick(node, e) {
255
+ if (isNestMode.value) handleNestClick(node, e);
256
+ else {
257
+ const tooltipIndex = getTooltipIndex(node);
258
+ const activeCoordinate = {
259
+ x: node.x + node.width / 2,
260
+ y: node.y + node.height / 2
261
+ };
262
+ dispatch(setActiveClickItemIndex({
263
+ activeIndex: tooltipIndex,
264
+ activeDataKey: props.dataKey,
265
+ activeCoordinate
266
+ }));
267
+ props.onClick?.(node, e);
268
+ }
269
+ }
270
+ function renderNodeAtProgress(node, index, progress) {
271
+ const nodeFill = getNodeFill(node);
272
+ const translateX = (-node.x - node.width) * (1 - progress);
273
+ const transform = progress < 1 ? `translate(${translateX}, 0)` : void 0;
274
+ const nodeProps = {
275
+ ...node,
276
+ index,
277
+ fill: nodeFill,
278
+ stroke: props.stroke
279
+ };
280
+ if (slots.content) return createVNode("g", {
281
+ "key": `node-${index}`,
282
+ "class": "v-charts-treemap-node",
283
+ "style": { transformOrigin: `${node.x}px ${node.y}px` },
284
+ "transform": transform,
285
+ "onClick": (e) => handleNodeClick(node, e),
286
+ "onMouseenter": (e) => handleNodeMouseEnter(node, e),
287
+ "onMouseleave": (e) => handleNodeMouseLeave(node, e)
288
+ }, [slots.content(nodeProps)]);
289
+ const arrow = isNestMode.value && (() => {
290
+ const item = (nestCurrentData.value ?? props.data).find((d) => d[props.nameKey] === node.name);
291
+ return item?.children && item.children.length > 0;
292
+ })() && node.width > 10 && node.height > 10 ? createVNode("polygon", {
293
+ "points": `${node.x + 2},${node.y + node.height / 2} ${node.x + 6},${node.y + node.height / 2 + 3} ${node.x + 2},${node.y + node.height / 2 + 6}`,
294
+ "fill": "#fff"
295
+ }, null) : null;
296
+ const nameSize = node.width > 20 && node.height > 20 ? getStringSize(node.name, { fontSize: "14px" }) : {
297
+ width: Infinity,
298
+ height: Infinity
299
+ };
300
+ const text = node.width > 20 && node.height > 20 && nameSize.width < node.width && nameSize.height < node.height ? createVNode("text", {
301
+ "x": node.x + 8,
302
+ "y": node.y + node.height / 2 + 7,
303
+ "fill": "#fff",
304
+ "font-size": 14
305
+ }, [node.name]) : null;
306
+ return createVNode("g", {
307
+ "key": `node-${index}`,
308
+ "class": "v-charts-treemap-node",
309
+ "style": { transformOrigin: `${node.x}px ${node.y}px` },
310
+ "transform": transform,
311
+ "onClick": (e) => handleNodeClick(node, e),
312
+ "onMouseenter": (e) => handleNodeMouseEnter(node, e),
313
+ "onMouseleave": (e) => handleNodeMouseLeave(node, e)
314
+ }, [
315
+ createVNode("rect", {
316
+ "x": node.x,
317
+ "y": node.y,
318
+ "width": node.width,
319
+ "height": node.height,
320
+ "fill": nodeFill,
321
+ "stroke": props.stroke
322
+ }, null),
323
+ arrow,
324
+ text
325
+ ]);
326
+ }
327
+ function renderBreadcrumb() {
328
+ if (!isNestMode.value || breadcrumbTrail.value.length === 0) return null;
329
+ return createVNode("div", { "class": "v-charts-treemap-breadcrumb" }, [createVNode("span", {
330
+ "class": "v-charts-treemap-breadcrumb-item",
331
+ "style": { cursor: "pointer" },
332
+ "onClick": () => navigateToBreadcrumb(-1)
333
+ }, [createTextVNode("Root")]), breadcrumbTrail.value.map((entry, i) => createVNode("span", { "key": i }, [createVNode("span", { "style": { margin: "0 4px" } }, [createTextVNode("/")]), createVNode("span", {
334
+ "class": "v-charts-treemap-breadcrumb-item",
335
+ "style": { cursor: "pointer" },
336
+ "onClick": () => navigateToBreadcrumb(i)
337
+ }, [entry.name])]))]);
338
+ }
339
+ return () => createVNode(Fragment, null, [renderBreadcrumb(), createVNode(Surface, {
340
+ "width": props.width,
341
+ "height": props.height
342
+ }, { default: () => [createVNode(Layer, { "class": "v-charts-treemap" }, { default: () => [createVNode(Animate, {
343
+ "key": animationKey.value,
344
+ "isActive": props.isAnimationActive,
345
+ "from": 0,
346
+ "to": 1,
347
+ "transition": props.transition
348
+ }, { default: (progress) => nodes.value.map((node, index) => renderNodeAtProgress(node, index, progress)) })] })] })]);
349
+ }
350
+ });
351
+ /**
352
+ * Treemap chart — hierarchical data visualization using nested rectangles.
353
+ *
354
+ * Supports `<Tooltip>` as a child component (same pattern as BarChart, LineChart, etc.).
355
+ *
356
+ * Usage:
357
+ * ```vue
358
+ * <Treemap :data="data" data-key="value" :width="600" :height="400">
359
+ * <Tooltip />
360
+ * </Treemap>
361
+ * ```
362
+ */
363
+ var Treemap = /* @__PURE__ */ defineComponent({
364
+ name: "Treemap",
365
+ props: TreemapVueProps,
366
+ slots: Object,
367
+ setup(props, { slots }) {
368
+ provideStore({ store: createRechartsStore({ options: treemapOptions }, "Treemap") });
369
+ return () => {
370
+ if (!props.data || props.data.length === 0) return null;
371
+ return createVNode(RechartsWrapper, {
372
+ "width": props.width,
373
+ "height": props.height
374
+ }, { default: () => [createVNode(TreemapInner, props, { content: slots.content }), slots.default?.()] });
375
+ };
376
+ }
377
+ });
378
+ //#endregion
379
+ export { Treemap, TreemapVueProps, treemapPayloadSearcher };
@@ -1,7 +1,7 @@
1
1
  //#region src/chart/const.ts
2
- var e = {
2
+ var FULL_WIDTH_AND_HEIGHT = {
3
3
  width: "100%",
4
4
  height: "100%"
5
5
  };
6
6
  //#endregion
7
- export { e as FULL_WIDTH_AND_HEIGHT };
7
+ export { FULL_WIDTH_AND_HEIGHT };
@@ -1,27 +1,30 @@
1
- import { validateWidthHeight as e } from "../utils/validate.mjs";
2
- import { provideClipPathId as t } from "./provideClipPathId.mjs";
3
- import { createRechartsStore as n } from "../state/store.mjs";
4
- import r from "./Surface.mjs";
5
- import { ChartDataContextProvider as i } from "../context/ChartDataContextProvider.mjs";
6
- import a from "../container/ClipPath.mjs";
7
- import { RechartsWrapper as o } from "./RechartsWrapper.mjs";
8
- import { FULL_WIDTH_AND_HEIGHT as s } from "./const.mjs";
9
- import { ReportMainChartProps as c } from "../state/ReportMainChartProps.mjs";
10
- import l from "../state/ReportChartProps.mjs";
11
- import { applyDefaultProps as u } from "../utils/props.mjs";
12
- import { ReportPolarOptions as d } from "../state/ReportPolarOptions.mjs";
13
- import { Fragment as f, createVNode as p, defineComponent as m, mergeProps as h } from "vue";
14
- import { provideStore as g } from "@reduxjs/vue-redux";
1
+ import { classProp } from "../types/common.mjs";
2
+ import { validateWidthHeight } from "../utils/validate.mjs";
3
+ import { provideClipPathId } from "./provideClipPathId.mjs";
4
+ import { createRechartsStore } from "../state/store.mjs";
5
+ import Surface_default from "./Surface.mjs";
6
+ import { ChartDataContextProvider } from "../context/ChartDataContextProvider.mjs";
7
+ import ClipPath_default from "../container/ClipPath.mjs";
8
+ import { RechartsWrapper } from "./RechartsWrapper.mjs";
9
+ import { FULL_WIDTH_AND_HEIGHT } from "./const.mjs";
10
+ import { ReportMainChartProps } from "../state/ReportMainChartProps.mjs";
11
+ import ReportChartProps_default from "../state/ReportChartProps.mjs";
12
+ import { applyDefaultProps } from "../utils/props.mjs";
13
+ import { ReportPolarOptions } from "../state/ReportPolarOptions.mjs";
14
+ import { Fragment, createVNode, defineComponent, mergeProps } from "vue";
15
+ import { provideStore } from "@reduxjs/vue-redux";
15
16
  //#region src/chart/generateCategoricalChart.tsx
16
- var _ = "horizontal", v = {
17
+ var defaultLayout = "horizontal";
18
+ var defaultMargin = {
17
19
  top: 5,
18
20
  right: 5,
19
21
  bottom: 5,
20
22
  left: 5
21
- }, y = {
23
+ };
24
+ var CategoricalProps = {
22
25
  accessibilityLayer: {
23
26
  type: Boolean,
24
- default: !0
27
+ default: true
25
28
  },
26
29
  barCategoryGap: {
27
30
  type: [Number, String],
@@ -32,7 +35,7 @@ var _ = "horizontal", v = {
32
35
  default: 4
33
36
  },
34
37
  barSize: { type: [Number, String] },
35
- class: { type: String },
38
+ class: classProp,
36
39
  compact: { type: Boolean },
37
40
  cx: { type: [Number, String] },
38
41
  cy: { type: [Number, String] },
@@ -52,17 +55,17 @@ var _ = "horizontal", v = {
52
55
  innerRadius: { type: [Number, String] },
53
56
  layout: {
54
57
  type: String,
55
- default: _
58
+ default: defaultLayout
56
59
  },
57
60
  margin: {
58
61
  type: Object,
59
- default: () => v
62
+ default: () => defaultMargin
60
63
  },
61
64
  maxBarSize: { type: Number },
62
65
  outerRadius: { type: [Number, String] },
63
66
  reverseStackOrder: {
64
67
  type: Boolean,
65
- default: !1
68
+ default: false
66
69
  },
67
70
  role: { type: String },
68
71
  stackOffset: {
@@ -82,85 +85,92 @@ var _ = "horizontal", v = {
82
85
  width: { type: Number },
83
86
  to: { type: [String, Object] }
84
87
  };
85
- function b({ chartName: b, defaultProps: x = {}, defaultTooltipEventType: S = "axis", validateTooltipEventTypes: C = ["axis"], tooltipPayloadSearcher: w }) {
86
- return /* @__PURE__ */ m({
87
- name: b,
88
- props: u(y, x),
89
- setup(u, { attrs: m, slots: y }) {
90
- g({ store: n({ options: {
91
- chartName: b,
92
- defaultTooltipEventType: S,
93
- validateTooltipEventTypes: C,
94
- tooltipPayloadSearcher: w,
88
+ function generateCategoricalChart({ chartName, defaultProps = {}, defaultTooltipEventType = "axis", validateTooltipEventTypes = ["axis"], tooltipPayloadSearcher }) {
89
+ return /* @__PURE__ */ defineComponent({
90
+ name: chartName,
91
+ props: applyDefaultProps(CategoricalProps, defaultProps),
92
+ setup(props, { attrs, slots }) {
93
+ provideStore({ store: createRechartsStore({ options: {
94
+ chartName,
95
+ defaultTooltipEventType,
96
+ validateTooltipEventTypes,
97
+ tooltipPayloadSearcher,
95
98
  eventEmitter: void 0
96
- } }, u.id ?? b) });
97
- let T = t(u);
99
+ } }, props.id ?? chartName) });
100
+ const clipPathId = provideClipPathId(props);
98
101
  return () => {
99
- let { compact: t, width: n, height: g, title: b, desc: S, ...C } = u, w = { ...m };
100
- if (!e({
101
- width: n,
102
- height: g
102
+ const { compact, width, height, title, desc, ...rest } = props;
103
+ const attributes = { ...attrs };
104
+ if (!validateWidthHeight({
105
+ width,
106
+ height
103
107
  })) return null;
104
- let E = u.layout ?? x.layout ?? _, D = E === "centric" || E === "radial";
105
- if (t) return p(f, null, [
106
- p(i, { chartData: u.data }, null),
107
- p(c, {
108
- width: n,
109
- height: g,
110
- layout: E,
111
- margin: u.margin ?? v
108
+ const layout = props.layout ?? defaultProps.layout ?? defaultLayout;
109
+ const isPolarChart = layout === "centric" || layout === "radial";
110
+ if (compact) return createVNode(Fragment, null, [
111
+ createVNode(ChartDataContextProvider, { "chartData": props.data }, null),
112
+ createVNode(ReportMainChartProps, {
113
+ "width": width,
114
+ "height": height,
115
+ "layout": layout,
116
+ "margin": props.margin ?? defaultMargin
112
117
  }, null),
113
- D && p(d, {
114
- cx: u.cx ?? "50%",
115
- cy: u.cy ?? "50%",
116
- startAngle: u.startAngle ?? x.startAngle ?? 90,
117
- endAngle: u.endAngle ?? x.endAngle ?? -270,
118
- innerRadius: u.innerRadius ?? 0,
119
- outerRadius: u.outerRadius ?? "80%"
118
+ isPolarChart && createVNode(ReportPolarOptions, {
119
+ "cx": props.cx ?? "50%",
120
+ "cy": props.cy ?? "50%",
121
+ "startAngle": props.startAngle ?? defaultProps.startAngle ?? 90,
122
+ "endAngle": props.endAngle ?? defaultProps.endAngle ?? -270,
123
+ "innerRadius": props.innerRadius ?? 0,
124
+ "outerRadius": props.outerRadius ?? "80%"
120
125
  }, null),
121
- p(r, h(m, C, {
122
- width: n,
123
- height: g,
124
- title: b,
125
- desc: S
126
- }), { default: () => [p(a, { clipPathId: T }, null), y.default?.()] })
126
+ createVNode(Surface_default, mergeProps(attrs, rest, {
127
+ "width": width,
128
+ "height": height,
129
+ "title": title,
130
+ "desc": desc
131
+ }), { default: () => [createVNode(ClipPath_default, { "clipPathId": clipPathId }, null), slots.default?.()] })
127
132
  ]);
128
- u.accessibilityLayer && (w.tabIndex = u.tabIndex ?? 0, w.role = u.role ?? "application");
129
- let O = {}, k = {};
130
- for (let [e, t] of Object.entries(w)) e.startsWith("on") && typeof t == "function" ? O[e] = t : k[e] = t;
131
- return p(f, null, [
132
- p(i, { chartData: u.data }, null),
133
- p(c, {
134
- width: n,
135
- height: g,
136
- layout: E,
137
- margin: u.margin ?? v
133
+ if (props.accessibilityLayer) {
134
+ attributes.tabindex = props.tabIndex ?? 0;
135
+ attributes.role = props.role ?? "application";
136
+ }
137
+ const eventHandlerAttrs = {};
138
+ const svgAttributes = {};
139
+ for (const [key, value] of Object.entries(attributes)) if (key.startsWith("on") && typeof value === "function") eventHandlerAttrs[key] = value;
140
+ else svgAttributes[key] = value;
141
+ return createVNode(Fragment, null, [
142
+ createVNode(ChartDataContextProvider, { "chartData": props.data }, null),
143
+ createVNode(ReportMainChartProps, {
144
+ "width": width,
145
+ "height": height,
146
+ "layout": layout,
147
+ "margin": props.margin ?? defaultMargin
138
148
  }, null),
139
- D && p(d, {
140
- cx: u.cx ?? "50%",
141
- cy: u.cy ?? "50%",
142
- startAngle: u.startAngle ?? x.startAngle ?? 90,
143
- endAngle: u.endAngle ?? x.endAngle ?? -270,
144
- innerRadius: u.innerRadius ?? 0,
145
- outerRadius: u.outerRadius ?? "80%"
149
+ isPolarChart && createVNode(ReportPolarOptions, {
150
+ "cx": props.cx ?? "50%",
151
+ "cy": props.cy ?? "50%",
152
+ "startAngle": props.startAngle ?? defaultProps.startAngle ?? 90,
153
+ "endAngle": props.endAngle ?? defaultProps.endAngle ?? -270,
154
+ "innerRadius": props.innerRadius ?? 0,
155
+ "outerRadius": props.outerRadius ?? "80%"
146
156
  }, null),
147
- p(o, h({
148
- style: u.style,
149
- class: u.class,
150
- width: n,
151
- height: g
152
- }, O), { default: () => [p(r, h(k, {
153
- width: n,
154
- height: g,
155
- title: b,
156
- desc: S,
157
- style: s
158
- }), { default: () => [p(a, { clipPathId: T }, null), y.default?.()] }), y.tooltip?.()] }),
159
- p(l, u, null)
157
+ createVNode(RechartsWrapper, mergeProps({
158
+ "style": props.style,
159
+ "class": props.class,
160
+ "width": width,
161
+ "height": height
162
+ }, eventHandlerAttrs), { default: () => [createVNode(Surface_default, mergeProps(svgAttributes, {
163
+ "width": width,
164
+ "height": height,
165
+ "title": title,
166
+ "desc": desc,
167
+ "style": FULL_WIDTH_AND_HEIGHT
168
+ }), { default: () => [createVNode(ClipPath_default, { "clipPathId": clipPathId }, null), slots.default?.()] }), slots.tooltip?.()] }),
169
+ createVNode(ReportChartProps_default, props, null)
160
170
  ]);
161
171
  };
162
172
  }
163
173
  });
164
174
  }
165
175
  //#endregion
166
- export { b as generateCategoricalChart };
176
+ export { generateCategoricalChart };
@@ -1,10 +1,15 @@
1
- import { uniqueId as e } from "../utils/data-utils.mjs";
2
- import { createContext as t } from "../utils/createContext.mjs";
1
+ import { uniqueId } from "../utils/data-utils.mjs";
2
+ import { createContext } from "../utils/createContext.mjs";
3
3
  //#region src/chart/provideClipPathId.ts
4
- var [n, r] = t("clipPathId");
5
- function i(t) {
6
- let n = `${t.id ?? e("v-charts")}-clip`;
7
- return r(n), n;
4
+ var [useClipPathId, provideClipPathIdRaw] = createContext("clipPathId");
5
+ /**
6
+ * Provide the clipPathId to child components.
7
+ * @param props - The props object from the chart component
8
+ */
9
+ function provideClipPathId(props) {
10
+ const clipPathId = `${props.id ?? uniqueId("v-charts")}-clip`;
11
+ provideClipPathIdRaw(clipPathId);
12
+ return clipPathId;
8
13
  }
9
14
  //#endregion
10
- export { i as provideClipPathId, n as useClipPathId };
15
+ export { provideClipPathId, useClipPathId };