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,82 +1,93 @@
1
- import { LegendVueProps as e } from "./type.mjs";
2
- import { useLegend as t } from "./hooks/useLegend.mjs";
3
- import { useLegendContent as n } from "./hooks/useLegendContent.mjs";
4
- import r from "../../container/Surface.mjs";
5
- import { LegendSymbol as i } from "./LegendSymbol.mjs";
6
- import { Teleport as a, createVNode as o, defineComponent as s, isVNode as c, watchEffect as l } from "vue";
1
+ import Surface from "../../container/Surface.mjs";
2
+ import { LegendVueProps } from "./type.mjs";
3
+ import { useLegend } from "./hooks/useLegend.mjs";
4
+ import { useLegendContent } from "./hooks/useLegendContent.mjs";
5
+ import { LegendSymbol } from "./LegendSymbol.mjs";
6
+ import { Teleport, createVNode, defineComponent, isVNode, watchEffect } from "vue";
7
7
  //#region src/components/legend/Legend.tsx
8
- function u(e) {
9
- return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !c(e);
8
+ function _isSlot(s) {
9
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
10
10
  }
11
- var d = /* @__PURE__ */ s({
11
+ var Legend_default = /* @__PURE__ */ defineComponent({
12
12
  name: "Legend",
13
- props: e,
14
- setup(e, { slots: s }) {
15
- let { legendRef: c, processedPayload: d, outerStyle: f, legendPortal: p, syncSettings: m, syncSize: h } = t(e), { getItemStyle: g, getSvgStyle: _, formatValue: v, handleClick: y, handleMouseEnter: b, handleMouseLeave: x } = n(e);
16
- l(() => {
17
- m(), h();
13
+ props: LegendVueProps,
14
+ setup(props, { slots }) {
15
+ const { legendRef, processedPayload, outerStyle, legendPortal, syncSettings, syncSize } = useLegend(props);
16
+ const { getItemStyle, getSvgStyle, formatValue, handleClick, handleMouseEnter, handleMouseLeave } = useLegendContent(props);
17
+ watchEffect(() => {
18
+ syncSettings();
19
+ syncSize();
18
20
  });
19
- let S = () => {
20
- if (!d.value || d.value.length === 0) return null;
21
- let { layout: t = "horizontal", align: n = "center", iconSize: a = 14 } = e;
22
- return o("ul", {
23
- class: "v-charts-default-legend",
24
- style: {
25
- padding: 0,
26
- margin: 0,
27
- textAlign: t === "horizontal" ? n : "left"
28
- }
29
- }, [d.value.map((n, s) => n.type === "none" ? null : o("li", {
30
- key: `legend-item-${s}`,
31
- class: "v-charts-legend-item",
32
- style: g(t),
33
- tabindex: 0,
34
- role: "button",
35
- "aria-label": `Toggle ${v(n)} series`,
36
- onClick: () => y(n, s),
37
- onKeydown: (e) => {
38
- (e.key === "Enter" || e.key === " ") && (e.preventDefault(), y(n, s));
39
- },
40
- onMouseenter: () => b(n, s),
41
- onMouseleave: () => x(n, s)
42
- }, [o(r, {
43
- width: a,
44
- height: a,
45
- viewBox: {
46
- x: 0,
47
- y: 0,
48
- width: 32,
49
- height: 32
50
- },
51
- style: _(),
52
- "aria-label": `${v(n)} legend icon`
53
- }, { default: () => [o(i, {
54
- type: e.iconType ?? n.type,
55
- color: n.inactive ? "#a3a3a3" : n.color,
56
- size: a,
57
- data: n
58
- }, null)] }), o("span", {
59
- class: "v-charts-legend-item-text",
60
- style: { color: n.inactive ? "#a3a3a3" : n.color }
61
- }, [v(n)])]))]);
62
- }, C = () => {
63
- if (!d.value || d.value.length === 0) return null;
64
- let t = {
65
- ...e,
66
- payload: d.value
21
+ const renderDefaultContent = () => {
22
+ if (!processedPayload.value || processedPayload.value.length === 0) return null;
23
+ const { layout = "horizontal", align = "center", iconSize = 14 } = props;
24
+ const finalStyle = {
25
+ padding: 0,
26
+ margin: 0,
27
+ textAlign: layout === "horizontal" ? align : "left"
67
28
  };
68
- return s.content ? s.content(t) : S();
29
+ return createVNode("ul", {
30
+ "class": "v-charts-default-legend",
31
+ "style": finalStyle
32
+ }, [processedPayload.value.map((entry, index) => {
33
+ if (entry.type === "none") return null;
34
+ return createVNode("li", {
35
+ "key": `legend-item-${index}`,
36
+ "class": "v-charts-legend-item",
37
+ "style": getItemStyle(layout),
38
+ "tabindex": 0,
39
+ "role": "button",
40
+ "aria-label": `Toggle ${formatValue(entry)} series`,
41
+ "onClick": () => handleClick(entry, index),
42
+ "onKeydown": (e) => {
43
+ if (e.key === "Enter" || e.key === " ") {
44
+ e.preventDefault();
45
+ handleClick(entry, index);
46
+ }
47
+ },
48
+ "onMouseenter": () => handleMouseEnter(entry, index),
49
+ "onMouseleave": () => handleMouseLeave(entry, index)
50
+ }, [createVNode(Surface, {
51
+ "width": iconSize,
52
+ "height": iconSize,
53
+ "viewBox": {
54
+ x: 0,
55
+ y: 0,
56
+ width: 32,
57
+ height: 32
58
+ },
59
+ "style": getSvgStyle(),
60
+ "aria-label": `${formatValue(entry)} legend icon`
61
+ }, { default: () => [createVNode(LegendSymbol, {
62
+ "type": props.iconType ?? entry.type,
63
+ "color": entry.inactive ? "#a3a3a3" : entry.color,
64
+ "size": iconSize,
65
+ "data": entry
66
+ }, null)] }), createVNode("span", {
67
+ "class": "v-charts-legend-item-text",
68
+ "style": { color: entry.inactive ? "#a3a3a3" : entry.color }
69
+ }, [formatValue(entry)])]);
70
+ })]);
71
+ };
72
+ const renderContent = () => {
73
+ if (!processedPayload.value || processedPayload.value.length === 0) return null;
74
+ const contentProps = {
75
+ ...props,
76
+ payload: processedPayload.value
77
+ };
78
+ if (slots.content) return slots.content(contentProps);
79
+ return renderDefaultContent();
69
80
  };
70
81
  return () => {
71
- if (p.value == null) return null;
72
- let e = o("div", {
73
- class: "v-charts-legend-wrapper",
74
- style: f.value,
75
- ref: c
76
- }, [C()]);
77
- return o("foreignObject", null, [o(a, { to: p.value }, u(e) ? e : { default: () => [e] })]);
82
+ if (legendPortal.value == null) return null;
83
+ const legendElement = createVNode("div", {
84
+ "class": "v-charts-legend-wrapper",
85
+ "style": outerStyle.value,
86
+ "ref": legendRef
87
+ }, [renderContent()]);
88
+ return createVNode("foreignObject", null, [createVNode(Teleport, { "to": legendPortal.value }, _isSlot(legendElement) ? legendElement : { default: () => [legendElement] })]);
78
89
  };
79
90
  }
80
91
  });
81
92
  //#endregion
82
- export { d as default };
93
+ export { Legend_default as default };
@@ -1,6 +1,6 @@
1
- import { Symbols as e } from "../../shape/Symbols.mjs";
2
- import { createVNode as t, defineComponent as n } from "vue";
3
- var r = /* @__PURE__ */ n({
1
+ import { Symbols } from "../../shape/Symbols.mjs";
2
+ import { createVNode, defineComponent } from "vue";
3
+ var LegendSymbol = /* @__PURE__ */ defineComponent({
4
4
  name: "LegendSymbol",
5
5
  props: {
6
6
  type: String,
@@ -11,50 +11,52 @@ var r = /* @__PURE__ */ n({
11
11
  },
12
12
  data: { type: Object }
13
13
  },
14
- setup(n) {
14
+ setup(props) {
15
15
  return () => {
16
- let { type: r, color: i, data: a } = n;
17
- if (r === "none") return null;
18
- let o = 32 / 3, s = 32 / 6;
19
- switch (r) {
20
- case "line": return t("path", {
16
+ const { type, color, data } = props;
17
+ if (type === "none") return null;
18
+ const halfSize = 32 / 2;
19
+ const thirdSize = 32 / 3;
20
+ const sixthSize = 32 / 6;
21
+ switch (type) {
22
+ case "line": return createVNode("path", {
21
23
  "stroke-width": 4,
22
- fill: "none",
23
- stroke: i,
24
- d: `M0,16h${o}
25
- A${s},${s},0,1,1,${2 * o},16
26
- H32M${2 * o},16
27
- A${s},${s},0,1,1,${o},16`,
28
- class: "v-charts-legend-icon"
24
+ "fill": "none",
25
+ "stroke": color,
26
+ "d": `M0,${halfSize}h${thirdSize}
27
+ A${sixthSize},${sixthSize},0,1,1,${2 * thirdSize},${halfSize}
28
+ H32M${2 * thirdSize},${halfSize}
29
+ A${sixthSize},${sixthSize},0,1,1,${thirdSize},${halfSize}`,
30
+ "class": "v-charts-legend-icon"
29
31
  }, null);
30
- case "plainline": return t("line", {
32
+ case "plainline": return createVNode("line", {
31
33
  "stroke-width": 4,
32
- fill: "none",
33
- stroke: i,
34
- "stroke-dasharray": a?.payload?.strokeDasharray,
35
- x1: 0,
36
- y1: 16,
37
- x2: 32,
38
- y2: 16,
39
- class: "v-charts-legend-icon"
34
+ "fill": "none",
35
+ "stroke": color,
36
+ "stroke-dasharray": data?.payload?.strokeDasharray,
37
+ "x1": 0,
38
+ "y1": halfSize,
39
+ "x2": 32,
40
+ "y2": halfSize,
41
+ "class": "v-charts-legend-icon"
40
42
  }, null);
41
- case "rect": return t("path", {
42
- stroke: "none",
43
- fill: i,
44
- d: `M0,${32 / 8}h32v${96 / 4}h-32z`,
45
- class: "v-charts-legend-icon"
43
+ case "rect": return createVNode("path", {
44
+ "stroke": "none",
45
+ "fill": color,
46
+ "d": `M0,${32 / 8}h32v${96 / 4}h-32z`,
47
+ "class": "v-charts-legend-icon"
46
48
  }, null);
47
- default: return t(e, {
48
- fill: i,
49
- cx: 16,
50
- cy: 16,
51
- size: 32,
52
- sizeType: "diameter",
53
- type: r
49
+ default: return createVNode(Symbols, {
50
+ "fill": color,
51
+ "cx": halfSize,
52
+ "cy": halfSize,
53
+ "size": 32,
54
+ "sizeType": "diameter",
55
+ "type": type
54
56
  }, null);
55
57
  }
56
58
  };
57
59
  }
58
60
  });
59
61
  //#endregion
60
- export { r as LegendSymbol };
62
+ export { LegendSymbol };
@@ -1,52 +1,77 @@
1
- import { selectLegendPayload as e } from "../../../state/selectors/legendSelectors.mjs";
2
- import { useAppDispatch as t, useAppSelector as n } from "../../../state/hooks.mjs";
3
- import { useChartHeight as r, useChartWidth as i, useMargin as a } from "../../../context/chartLayoutContext.mjs";
4
- import { setLegendSettings as o, setLegendSize as s } from "../../../state/legendSlice.mjs";
5
- import { useLegendPortal as c } from "../../../chart/LegendPortalContext.mjs";
6
- import { getUniqPayload as l } from "../../../utils/payload/getUniqPayload.mjs";
7
- import { defaultUniqBy as u, getDefaultPosition as d, getWidthOrHeight as f } from "../utils.mjs";
8
- import { computed as p, ref as m } from "vue";
9
- import { sortBy as h } from "es-toolkit/compat";
10
- import { useElementBounding as g } from "@vueuse/core";
1
+ import { selectLegendPayload } from "../../../state/selectors/legendSelectors.mjs";
2
+ import { useAppDispatch, useAppSelector } from "../../../state/hooks.mjs";
3
+ import { useChartHeight, useChartWidth, useMargin } from "../../../context/chartLayoutContext.mjs";
4
+ import { setLegendSettings, setLegendSize } from "../../../state/legendSlice.mjs";
5
+ import { useLegendPortal } from "../../../chart/LegendPortalContext.mjs";
6
+ import { getUniqPayload } from "../../../utils/payload/getUniqPayload.mjs";
7
+ import { defaultUniqBy, getDefaultPosition, getWidthOrHeight } from "../utils.mjs";
8
+ import { computed, ref } from "vue";
9
+ import { sortBy } from "es-toolkit/compat";
10
+ import { useElementBounding } from "@vueuse/core";
11
11
  //#region src/components/legend/hooks/useLegend.ts
12
- function _(_) {
13
- let v = t(), y = n(e), b = c(), x = a(), S = i(), C = r(), w = m(), { width: T, height: E } = g(w), D = p(() => S.value - (x.value.left || 0) - (x.value.right || 0)), O = p(() => f(_.layout, _.height, _.width, D.value)), k = p(() => ({
14
- width: T.value,
15
- height: E.value
12
+ function useLegend(props) {
13
+ const dispatch = useAppDispatch();
14
+ const contextPayload = useAppSelector(selectLegendPayload);
15
+ const legendPortalFromContext = useLegendPortal();
16
+ const margin = useMargin();
17
+ const chartWidth = useChartWidth();
18
+ const chartHeight = useChartHeight();
19
+ const legendRef = ref();
20
+ const { width: boundingWidth, height: boundingHeight } = useElementBounding(legendRef);
21
+ const maxWidth = computed(() => chartWidth.value - (margin.value.left || 0) - (margin.value.right || 0));
22
+ const widthOrHeight = computed(() => getWidthOrHeight(props.layout, props.height, props.width, maxWidth.value));
23
+ const boundingBox = computed(() => ({
24
+ width: boundingWidth.value,
25
+ height: boundingHeight.value
16
26
  }));
17
- return {
18
- legendRef: w,
19
- boundingBox: k,
20
- widthOrHeight: O,
21
- processedPayload: p(() => {
22
- if (!y.value || y.value.length === 0) return [];
23
- let e = l(y.value, _.payloadUniqBy, u);
24
- return _.itemSorter && (typeof _.itemSorter == "string" || typeof _.itemSorter == "function") && (e = h(e, _.itemSorter)), Array.from(e);
25
- }),
26
- outerStyle: p(() => {
27
- if (_.portal) return _.wrapperStyle || {};
28
- let e = {
29
- position: "absolute",
30
- width: O.value?.width ? `${O.value.width}px` : _.width ? `${_.width}px` : "auto",
31
- height: O.value?.height ? `${O.value.height}px` : _.height ? `${_.height}px` : "auto"
32
- }, t = d(_.wrapperStyle, _, x.value, S.value, C.value, k.value);
33
- return Object.assign({}, e, t, _.wrapperStyle || {});
34
- }),
35
- legendPortal: p(() => _.portal ?? b?.value),
36
- syncSettings: () => {
37
- v(o({
38
- layout: _.layout,
39
- align: _.align,
40
- verticalAlign: _.verticalAlign
41
- }));
42
- },
43
- syncSize: () => {
44
- v(s({
45
- width: k.value.width,
46
- height: k.value.height
47
- }));
27
+ const processedPayload = computed(() => {
28
+ if (!contextPayload.value || contextPayload.value.length === 0) return [];
29
+ let finalPayload = getUniqPayload(contextPayload.value, props.payloadUniqBy, defaultUniqBy);
30
+ if (props.itemSorter) {
31
+ if (typeof props.itemSorter === "string") finalPayload = sortBy(finalPayload, props.itemSorter);
32
+ else if (typeof props.itemSorter === "function") finalPayload = sortBy(finalPayload, props.itemSorter);
48
33
  }
34
+ return Array.from(finalPayload);
35
+ });
36
+ const outerStyle = computed(() => {
37
+ const userStyle = props.wrapperStyle ? { ...props.wrapperStyle } : {};
38
+ if (props.portal) return userStyle;
39
+ const baseStyle = {
40
+ position: "absolute",
41
+ width: widthOrHeight.value?.width ? `${widthOrHeight.value.width}px` : props.width ? `${props.width}px` : "auto",
42
+ height: widthOrHeight.value?.height ? `${widthOrHeight.value.height}px` : props.height ? `${props.height}px` : "auto"
43
+ };
44
+ const positionStyle = getDefaultPosition(userStyle, props, margin.value, chartWidth.value, chartHeight.value, boundingBox.value);
45
+ return {
46
+ ...baseStyle,
47
+ ...positionStyle,
48
+ ...userStyle
49
+ };
50
+ });
51
+ const legendPortal = computed(() => props.portal ?? legendPortalFromContext?.value);
52
+ const syncSettings = () => {
53
+ dispatch(setLegendSettings({
54
+ layout: props.layout,
55
+ align: props.align,
56
+ verticalAlign: props.verticalAlign
57
+ }));
58
+ };
59
+ const syncSize = () => {
60
+ dispatch(setLegendSize({
61
+ width: boundingBox.value.width,
62
+ height: boundingBox.value.height
63
+ }));
64
+ };
65
+ return {
66
+ legendRef,
67
+ boundingBox,
68
+ widthOrHeight,
69
+ processedPayload,
70
+ outerStyle,
71
+ legendPortal,
72
+ syncSettings,
73
+ syncSize
49
74
  };
50
75
  }
51
76
  //#endregion
52
- export { _ as useLegend };
77
+ export { useLegend };
@@ -1,47 +1,68 @@
1
1
  //#region src/components/legend/hooks/useLegendContent.ts
2
- function e(e) {
3
- return {
4
- getWrapperStyle: (t = "horizontal", n = "center", r = "bottom") => ({
2
+ function useLegendContent(props) {
3
+ const getWrapperStyle = (layout = "horizontal", align = "center", verticalAlign = "bottom") => {
4
+ return {
5
5
  display: "flex",
6
- flexDirection: t === "horizontal" ? "row" : "column",
7
- justifyContent: n === "left" ? "flex-start" : n === "right" ? "flex-end" : "center",
8
- alignItems: r === "top" ? "flex-start" : r === "bottom" ? "flex-end" : "center",
6
+ flexDirection: layout === "horizontal" ? "row" : "column",
7
+ justifyContent: align === "left" ? "flex-start" : align === "right" ? "flex-end" : "center",
8
+ alignItems: verticalAlign === "top" ? "flex-start" : verticalAlign === "bottom" ? "flex-end" : "center",
9
9
  flexWrap: "wrap",
10
10
  gap: "8px",
11
- ...e.wrapperStyle || {}
12
- }),
13
- getContentStyle: (t = "horizontal") => ({
11
+ ...props.wrapperStyle || {}
12
+ };
13
+ };
14
+ const getContentStyle = (layout = "horizontal") => {
15
+ return {
14
16
  display: "flex",
15
- flexDirection: t === "horizontal" ? "row" : "column",
16
- gap: t === "horizontal" ? "16px" : "8px",
17
- ...e.contentStyle || {}
18
- }),
19
- getItemStyle: (e = "horizontal") => ({
20
- display: e === "horizontal" ? "inline-block" : "block",
17
+ flexDirection: layout === "horizontal" ? "row" : "column",
18
+ gap: layout === "horizontal" ? "16px" : "8px",
19
+ ...props.contentStyle || {}
20
+ };
21
+ };
22
+ const getItemStyle = (layout = "horizontal") => {
23
+ return {
24
+ display: layout === "horizontal" ? "inline-block" : "block",
21
25
  marginRight: "10px"
22
- }),
23
- getViewBox: () => ({
26
+ };
27
+ };
28
+ const getViewBox = () => {
29
+ return {
24
30
  x: 0,
25
31
  y: 0,
26
32
  width: 32,
27
33
  height: 32
28
- }),
29
- getSvgStyle: () => ({
34
+ };
35
+ };
36
+ const getSvgStyle = () => {
37
+ return {
30
38
  display: "inline-block",
31
39
  verticalAlign: "middle",
32
40
  marginRight: "4px"
33
- }),
34
- formatValue: (t) => e.formatter ? e.formatter(t.value, t) : t.value,
35
- handleClick: (t, n) => {
36
- e.onClick?.(t, n);
37
- },
38
- handleMouseEnter: (t, n) => {
39
- e.onMouseEnter?.(t, n);
40
- },
41
- handleMouseLeave: (t, n) => {
42
- e.onMouseLeave?.(t, n);
43
- }
41
+ };
42
+ };
43
+ const formatValue = (entry) => {
44
+ return props.formatter ? props.formatter(entry.value, entry) : entry.value;
45
+ };
46
+ const handleClick = (entry, index) => {
47
+ props.onClick?.(entry, index);
48
+ };
49
+ const handleMouseEnter = (entry, index) => {
50
+ props.onMouseEnter?.(entry, index);
51
+ };
52
+ const handleMouseLeave = (entry, index) => {
53
+ props.onMouseLeave?.(entry, index);
54
+ };
55
+ return {
56
+ getWrapperStyle,
57
+ getContentStyle,
58
+ getItemStyle,
59
+ getViewBox,
60
+ getSvgStyle,
61
+ formatValue,
62
+ handleClick,
63
+ handleMouseEnter,
64
+ handleMouseLeave
44
65
  };
45
66
  }
46
67
  //#endregion
47
- export { e as useLegendContent };
68
+ export { useLegendContent };
@@ -1,5 +1,5 @@
1
1
  //#region src/components/legend/type.ts
2
- var e = {
2
+ var LegendVueProps = {
3
3
  layout: {
4
4
  type: String,
5
5
  default: "horizontal"
@@ -38,4 +38,4 @@ var e = {
38
38
  onBBoxUpdate: Function
39
39
  };
40
40
  //#endregion
41
- export { e as LegendVueProps };
41
+ export { LegendVueProps };
@@ -1,17 +1,25 @@
1
- import { isNumber as e } from "../../utils/validate.mjs";
1
+ import { isNumber } from "../../utils/validate.mjs";
2
2
  //#region src/components/legend/utils.ts
3
- function t(e, t, n, r, i, a) {
4
- let { layout: o, align: s, verticalAlign: c } = t, l = {}, u = {};
5
- return (!e || (e.left === void 0 || e.left === null) && (e.right === void 0 || e.right === null)) && (l = s === "center" && o === "vertical" ? { left: `${((r || 0) - a.width) / 2}px` } : s === "right" ? { right: `${n?.right || 0}px` } : { left: `${n?.left || 0}px` }), (!e || (e.top === void 0 || e.top === null) && (e.bottom === void 0 || e.bottom === null)) && (u = c === "middle" ? { top: `${((i || 0) - a.height) / 2}px` } : c === "bottom" ? { bottom: `${n?.bottom || 0}px` } : { top: `${n?.top || 0}px` }), {
6
- ...l,
7
- ...u
3
+ function getDefaultPosition(style, props, margin, chartWidth, chartHeight, box) {
4
+ const { layout, align, verticalAlign } = props;
5
+ let hPos = {};
6
+ let vPos = {};
7
+ if (!style || (style.left === void 0 || style.left === null) && (style.right === void 0 || style.right === null)) if (align === "center" && layout === "vertical") hPos = { left: `${((chartWidth || 0) - box.width) / 2}px` };
8
+ else hPos = align === "right" ? { right: `${margin?.right || 0}px` } : { left: `${margin?.left || 0}px` };
9
+ if (!style || (style.top === void 0 || style.top === null) && (style.bottom === void 0 || style.bottom === null)) if (verticalAlign === "middle") vPos = { top: `${((chartHeight || 0) - box.height) / 2}px` };
10
+ else vPos = verticalAlign === "bottom" ? { bottom: `${margin?.bottom || 0}px` } : { top: `${margin?.top || 0}px` };
11
+ return {
12
+ ...hPos,
13
+ ...vPos
8
14
  };
9
15
  }
10
- function n(t, n, r, i) {
11
- return t === "vertical" && e(n) ? { height: n } : t === "horizontal" ? { width: r || i } : null;
16
+ function getWidthOrHeight(layout, height, width, maxWidth) {
17
+ if (layout === "vertical" && isNumber(height)) return { height };
18
+ if (layout === "horizontal") return { width: width || maxWidth };
19
+ return null;
12
20
  }
13
- function r(e) {
14
- return e.value;
21
+ function defaultUniqBy(entry) {
22
+ return entry.value;
15
23
  }
16
24
  //#endregion
17
- export { r as defaultUniqBy, t as getDefaultPosition, n as getWidthOrHeight };
25
+ export { defaultUniqBy, getDefaultPosition, getWidthOrHeight };
@@ -1,31 +1,44 @@
1
- import { polarToCartesian as e } from "../utils/polar.mjs";
1
+ import { polarToCartesian } from "../utils/polar.mjs";
2
2
  //#region src/components/utils.ts
3
- function t(t) {
4
- let { cx: n, cy: r, radius: i, startAngle: a, endAngle: o } = t;
3
+ function getRadialCursorPoints(activeCoordinate) {
4
+ const { cx, cy, radius, startAngle, endAngle } = activeCoordinate;
5
5
  return {
6
- points: [e(n, r, i, a), e(n, r, i, o)],
7
- cx: n,
8
- cy: r,
9
- radius: i,
10
- startAngle: a,
11
- endAngle: o
6
+ points: [polarToCartesian(cx, cy, radius, startAngle), polarToCartesian(cx, cy, radius, endAngle)],
7
+ cx,
8
+ cy,
9
+ radius,
10
+ startAngle,
11
+ endAngle
12
12
  };
13
13
  }
14
- function n(n, r, i) {
15
- let a, o, s, c;
16
- if (n === "horizontal") a = r.x, s = a, o = i.top, c = i.top + i.height;
17
- else if (n === "vertical") o = r.y, c = o, a = i.left, s = i.left + i.width;
18
- else if (r.cx != null && r.cy != null) if (n === "centric") {
19
- let { cx: t, cy: n, innerRadius: i, outerRadius: l, angle: u } = r, d = e(t, n, i, u), f = e(t, n, l, u);
20
- a = d.x, o = d.y, s = f.x, c = f.y;
21
- } else return t(r);
14
+ function getCursorPoints(layout, activeCoordinate, offset) {
15
+ let x1, y1, x2, y2;
16
+ if (layout === "horizontal") {
17
+ x1 = activeCoordinate.x;
18
+ x2 = x1;
19
+ y1 = offset.top;
20
+ y2 = offset.top + offset.height;
21
+ } else if (layout === "vertical") {
22
+ y1 = activeCoordinate.y;
23
+ y2 = y1;
24
+ x1 = offset.left;
25
+ x2 = offset.left + offset.width;
26
+ } else if (activeCoordinate.cx != null && activeCoordinate.cy != null) if (layout === "centric") {
27
+ const { cx, cy, innerRadius, outerRadius, angle } = activeCoordinate;
28
+ const innerPoint = polarToCartesian(cx, cy, innerRadius, angle);
29
+ const outerPoint = polarToCartesian(cx, cy, outerRadius, angle);
30
+ x1 = innerPoint.x;
31
+ y1 = innerPoint.y;
32
+ x2 = outerPoint.x;
33
+ y2 = outerPoint.y;
34
+ } else return getRadialCursorPoints(activeCoordinate);
22
35
  return [{
23
- x: a,
24
- y: o
36
+ x: x1,
37
+ y: y1
25
38
  }, {
26
- x: s,
27
- y: c
39
+ x: x2,
40
+ y: y2
28
41
  }];
29
42
  }
30
43
  //#endregion
31
- export { n as getCursorPoints };
44
+ export { getCursorPoints };
@@ -1,25 +1,25 @@
1
- import { useOffset as e } from "../context/chartLayoutContext.mjs";
2
- import { createVNode as t, defineComponent as n } from "vue";
1
+ import { useOffset } from "../context/chartLayoutContext.mjs";
2
+ import { createVNode, defineComponent } from "vue";
3
3
  //#region src/container/ClipPath.tsx
4
- var r = /* @__PURE__ */ n({
4
+ var ClipPath_default = /* @__PURE__ */ defineComponent({
5
5
  name: "ClipPath",
6
6
  props: { clipPathId: {
7
7
  type: String,
8
- required: !0
8
+ required: true
9
9
  } },
10
- setup(n) {
11
- let r = e();
10
+ setup(props) {
11
+ const offset = useOffset();
12
12
  return () => {
13
- if (!r.value) return null;
14
- let { left: e, top: i, height: a, width: o } = r.value;
15
- return t("defs", null, [t("clipPath", { id: n.clipPathId }, [t("rect", {
16
- x: e,
17
- y: i,
18
- height: a,
19
- width: o
13
+ if (!offset.value) return null;
14
+ const { left, top, height, width } = offset.value;
15
+ return createVNode("defs", null, [createVNode("clipPath", { "id": props.clipPathId }, [createVNode("rect", {
16
+ "x": left,
17
+ "y": top,
18
+ "height": height,
19
+ "width": width
20
20
  }, null)])]);
21
21
  };
22
22
  }
23
23
  });
24
24
  //#endregion
25
- export { r as default };
25
+ export { ClipPath_default as default };