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,151 +1,185 @@
1
- import { isNan as e, isNullish as t, isNumber as n } from "../../utils/validate.mjs";
2
- import { interpolate as r } from "../../utils/data-utils.mjs";
3
- import { Curve as i } from "../../shape/Curve.mjs";
4
- import { isClipDot as a } from "../../utils/chart.mjs";
5
- import { useOffset as o } from "../../context/chartLayoutContext.mjs";
6
- import { useAreaContext as s } from "./hooks/useArea.mjs";
7
- import { Layer as c } from "../../container/Layer.mjs";
8
- import { Dot as l } from "../../shape/Dot.mjs";
9
- import { LabelList as u } from "../../components/label/LabelList.mjs";
10
- import { Fragment as d, createVNode as f, defineComponent as p, mergeProps as m, ref as h, watch as g } from "vue";
11
- import { animate as _ } from "motion-v";
1
+ import { isNan, isNullish, isNumber } from "../../utils/validate.mjs";
2
+ import { interpolate } from "../../utils/data-utils.mjs";
3
+ import { Curve } from "../../shape/Curve.mjs";
4
+ import { isClipDot } from "../../utils/chart.mjs";
5
+ import { useOffset } from "../../context/chartLayoutContext.mjs";
6
+ import { useAreaContext } from "./hooks/useArea.mjs";
7
+ import { Layer } from "../../container/Layer.mjs";
8
+ import { Dot } from "../../shape/Dot.mjs";
9
+ import { LabelList } from "../../components/label/LabelList.mjs";
10
+ import { Fragment, createVNode, defineComponent, mergeProps, ref, watch } from "vue";
11
+ import { animate } from "motion-v";
12
12
  //#region src/cartesian/area/RenderArea.tsx
13
- var v = /* @__PURE__ */ p({
13
+ var Dots = /* @__PURE__ */ defineComponent({
14
14
  name: "Dots",
15
15
  props: { points: {
16
16
  type: Array,
17
17
  default: () => []
18
18
  } },
19
- setup(e) {
20
- let { clipPathId: t, props: n, attrs: r, dotSlot: i } = s();
19
+ setup(_props) {
20
+ const { clipPathId, props, attrs, dotSlot } = useAreaContext();
21
21
  return () => {
22
- let { points: o } = e;
23
- if (!b(o, n.dot)) return null;
24
- let s = a(n.dot), u = {
25
- fill: n.fill,
26
- "fill-opacity": n.fillOpacity,
27
- "stroke-width": n.strokeWidth,
28
- stroke: n.stroke
22
+ const { points } = _props;
23
+ if (!shouldRenderDots(points, props.dot)) return null;
24
+ const clipDot = isClipDot(props.dot);
25
+ const dotsProps = {
26
+ "fill": props.fill,
27
+ "fill-opacity": props.fillOpacity,
28
+ "stroke-width": props.strokeWidth,
29
+ "stroke": props.stroke
29
30
  };
30
- return f(c, {
31
- class: "v-charts-area-dots",
32
- "clip-path": n.needClip ? `url(#clipPath-${s ? "" : "dots-"}${t.value})` : void 0
33
- }, { default: () => [o?.map((e) => {
34
- let t = {
35
- ...u,
36
- ...r,
31
+ return createVNode(Layer, {
32
+ "class": "v-charts-area-dots",
33
+ "clip-path": props.needClip ? `url(#clipPath-${clipDot ? "" : "dots-"}${clipPathId.value})` : void 0
34
+ }, { default: () => [points?.map((point) => {
35
+ const dotProps = {
36
+ ...dotsProps,
37
+ ...attrs,
37
38
  r: 3,
38
- cx: e.x,
39
- cy: e.y,
39
+ cx: point.x,
40
+ cy: point.y,
40
41
  class: "v-charts-area-dot",
41
- clipDot: s
42
+ clipDot
42
43
  };
43
- return i ? i(t) : f(l, t, null);
44
+ if (dotSlot) return dotSlot(dotProps);
45
+ return createVNode(Dot, dotProps, null);
44
46
  })] });
45
47
  };
46
48
  }
47
- }), y = /* @__PURE__ */ p({
49
+ });
50
+ var StaticArea = /* @__PURE__ */ defineComponent({
48
51
  name: "StaticArea",
49
52
  setup() {
50
- let { points: a, clipPathId: l, layout: p, attrs: y, areaData: b, props: x, isAnimating: S, isClipRectAnimating: C } = s(), w = o(), T = h(a.value || []), E = h(b.value?.baseLine || []), D = T.value || [], O = b.value?.baseLine || [], k = !1;
51
- return g(a, (i, a, o) => {
52
- if (C.value) {
53
- T.value = i, E.value = b.value?.baseLine || [];
53
+ const { points, clipPathId, layout, attrs, areaData, props, isAnimating, isClipRectAnimating } = useAreaContext();
54
+ const offset = useOffset();
55
+ const currentPoints = ref(points.value || []);
56
+ const currentBaseLine = ref(areaData.value?.baseLine || []);
57
+ let prevPoints = currentPoints.value || [];
58
+ let prevBaseLine = areaData.value?.baseLine || [];
59
+ let animationStopped = false;
60
+ watch(points, (newPoints, _, onCleanup) => {
61
+ if (isClipRectAnimating.value) {
62
+ currentPoints.value = newPoints;
63
+ currentBaseLine.value = areaData.value?.baseLine || [];
54
64
  return;
55
65
  }
56
- if (i && i.length > 0) {
57
- k = !1, S.value = !0;
58
- let a = _(0, 1, {
59
- ...x.transition,
60
- onUpdate(a) {
61
- if (!k && D.length) {
62
- let o = D.length / i.length, s = a === 1 ? i : i.map((e, t) => {
63
- let n = Math.floor(t * o);
64
- if (D[n]) {
65
- let t = D[n];
66
+ if (newPoints && newPoints.length > 0) {
67
+ animationStopped = false;
68
+ isAnimating.value = true;
69
+ const animation = animate(0, 1, {
70
+ ...props.transition,
71
+ onUpdate(t) {
72
+ if (animationStopped) return;
73
+ if (prevPoints.length) {
74
+ const prevPointsDiffFactor = prevPoints.length / newPoints.length;
75
+ const stepPoints = t === 1 ? newPoints : newPoints.map((entry, index) => {
76
+ const prevPointIndex = Math.floor(index * prevPointsDiffFactor);
77
+ if (prevPoints[prevPointIndex]) {
78
+ const prev = prevPoints[prevPointIndex];
66
79
  return {
67
- ...e,
68
- x: r(t.x, e.x, a),
69
- y: r(t.y, e.y, a)
80
+ ...entry,
81
+ x: interpolate(prev.x, entry.x, t),
82
+ y: interpolate(prev.y, entry.y, t)
70
83
  };
71
84
  }
72
- return e;
73
- }), c;
74
- c = n(b.value?.baseLine) ? r(O, b.value?.baseLine, a) : t(b.value?.baseLine) || e(b.value?.baseLine) ? r(O, 0, a) : b?.value.baseLine.map((e, t) => {
75
- let n = Math.floor(t * o);
76
- if (Array.isArray(O) && O[n]) {
77
- let t = O[n];
85
+ return entry;
86
+ });
87
+ let stepBaseLine;
88
+ if (isNumber(areaData.value?.baseLine)) stepBaseLine = interpolate(prevBaseLine, areaData.value?.baseLine, t);
89
+ else if (isNullish(areaData.value?.baseLine) || isNan(areaData.value?.baseLine)) stepBaseLine = interpolate(prevBaseLine, 0, t);
90
+ else stepBaseLine = areaData?.value.baseLine.map((entry, index) => {
91
+ const prevPointIndex = Math.floor(index * prevPointsDiffFactor);
92
+ if (Array.isArray(prevBaseLine) && prevBaseLine[prevPointIndex]) {
93
+ const prev = prevBaseLine[prevPointIndex];
78
94
  return {
79
- ...e,
80
- x: r(t.x, e.x, a),
81
- y: r(t.y, e.y, a)
95
+ ...entry,
96
+ x: interpolate(prev.x, entry.x, t),
97
+ y: interpolate(prev.y, entry.y, t)
82
98
  };
83
99
  }
84
- return e;
85
- }), T.value = s, E.value = c;
100
+ return entry;
101
+ });
102
+ currentPoints.value = stepPoints;
103
+ currentBaseLine.value = stepBaseLine;
86
104
  }
87
105
  },
88
106
  onPlay() {
89
- x.onAnimationStart?.();
107
+ props.onAnimationStart?.();
90
108
  },
91
109
  onComplete() {
92
- S.value = !1, x.onAnimationEnd?.();
110
+ isAnimating.value = false;
111
+ props.onAnimationEnd?.();
93
112
  }
94
113
  });
95
- o(() => {
96
- k = !0, a.stop(), D = T.value, O = E.value;
114
+ onCleanup(() => {
115
+ animationStopped = true;
116
+ animation.stop();
117
+ prevPoints = currentPoints.value;
118
+ prevBaseLine = currentBaseLine.value;
97
119
  });
98
- } else S.value = !1, T.value = i || [], E.value = b.value?.baseLine || [], D = T.value, O = E.value;
99
- }, { immediate: !0 }), () => {
100
- let e = {
101
- ...y,
102
- fill: x.fill,
103
- "fill-opacity": x.fillOpacity,
104
- height: w.value.height,
105
- width: w.value.width,
106
- "stroke-width": x.strokeWidth
107
- }, t = b.value?.isRange, n = !S.value && x.label, r = typeof x.label == "object" ? x.label : {};
108
- return f(d, null, [
109
- T.value && T.value.length > 1 && f(c, { "clip-path": x.needClip ? `url(#clipPath-${l.value})` : void 0 }, { default: () => [
110
- f(i, m(e, {
111
- points: T.value,
112
- connectNulls: x.connectNulls,
113
- type: x.type,
114
- layout: p.value,
115
- baseLine: E.value,
116
- stroke: "none",
117
- class: "v-charts-area-area"
120
+ } else {
121
+ isAnimating.value = false;
122
+ currentPoints.value = newPoints || [];
123
+ currentBaseLine.value = areaData.value?.baseLine || [];
124
+ prevPoints = currentPoints.value;
125
+ prevBaseLine = currentBaseLine.value;
126
+ }
127
+ }, { immediate: true });
128
+ return () => {
129
+ const curveAttrs = {
130
+ ...attrs,
131
+ "fill": props.fill,
132
+ "fill-opacity": props.fillOpacity,
133
+ "height": offset.value.height,
134
+ "width": offset.value.width,
135
+ "stroke-width": props.strokeWidth
136
+ };
137
+ const isRange = areaData.value?.isRange;
138
+ const showLabels = !isAnimating.value && props.label;
139
+ const labelProps = typeof props.label === "object" ? props.label : {};
140
+ return createVNode(Fragment, null, [
141
+ currentPoints.value && currentPoints.value.length > 1 && createVNode(Layer, { "clip-path": props.needClip ? `url(#clipPath-${clipPathId.value})` : void 0 }, { default: () => [
142
+ createVNode(Curve, mergeProps(curveAttrs, {
143
+ "points": currentPoints.value,
144
+ "connectNulls": props.connectNulls,
145
+ "type": props.type,
146
+ "layout": layout.value,
147
+ "baseLine": currentBaseLine.value,
148
+ "stroke": "none",
149
+ "class": "v-charts-area-area"
118
150
  }), null),
119
- y.stroke !== "none" && f(i, m(e, {
120
- layout: p.value,
121
- type: x.type,
122
- connectNulls: x.connectNulls,
123
- fill: "none",
124
- points: T.value,
125
- stroke: x.stroke,
126
- class: "v-charts-area-curve"
151
+ attrs.stroke !== "none" && createVNode(Curve, mergeProps(curveAttrs, {
152
+ "layout": layout.value,
153
+ "type": props.type,
154
+ "connectNulls": props.connectNulls,
155
+ "fill": "none",
156
+ "points": currentPoints.value,
157
+ "stroke": props.stroke,
158
+ "class": "v-charts-area-curve"
127
159
  }), null),
128
- y.stroke !== "none" && t && f(i, m(e, {
129
- class: "v-charts-area-curve",
130
- layout: p.value,
131
- type: x.type,
132
- connectNulls: x.connectNulls,
133
- fill: "none",
134
- points: E.value,
135
- stroke: x.stroke
160
+ attrs.stroke !== "none" && isRange && createVNode(Curve, mergeProps(curveAttrs, {
161
+ "class": "v-charts-area-curve",
162
+ "layout": layout.value,
163
+ "type": props.type,
164
+ "connectNulls": props.connectNulls,
165
+ "fill": "none",
166
+ "points": currentBaseLine.value,
167
+ "stroke": props.stroke
136
168
  }), null)
137
169
  ] }),
138
- f(v, { points: T.value }, null),
139
- n && f(u, m(r, {
140
- data: b.value?.points ?? [],
141
- dataKey: x.dataKey
170
+ createVNode(Dots, { "points": currentPoints.value }, null),
171
+ showLabels && createVNode(LabelList, mergeProps(labelProps, {
172
+ "data": areaData.value?.points ?? [],
173
+ "dataKey": props.dataKey
142
174
  }), null)
143
175
  ]);
144
176
  };
145
177
  }
146
178
  });
147
- function b(e, t) {
148
- return e == null || !e.length ? !1 : t ? !0 : e.length === 1;
179
+ function shouldRenderDots(points, dot) {
180
+ if (points == null || !points.length) return false;
181
+ if (dot) return true;
182
+ return points.length === 1;
149
183
  }
150
184
  //#endregion
151
- export { y as StaticArea };
185
+ export { StaticArea };
@@ -1,57 +1,81 @@
1
- import { uniqueId as e } from "../../../utils/data-utils.mjs";
2
- import { useIsPanorama as t } from "../../../context/PanoramaContextProvider.mjs";
3
- import { isClipDot 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 { useChartName as a } from "../../../state/selectors/selectors.mjs";
7
- import { selectArea as o } from "../../../state/selectors/areaSelectors.mjs";
8
- import { filterProps as s } from "../../../utils/VueUtils.mjs";
9
- import { computed as c, inject as l, provide as u, ref as d, watch as f } from "vue";
1
+ import { uniqueId } from "../../../utils/data-utils.mjs";
2
+ import { useIsPanorama } from "../../../context/PanoramaContextProvider.mjs";
3
+ import { isClipDot } from "../../../utils/chart.mjs";
4
+ import { useAppSelector } from "../../../state/hooks.mjs";
5
+ import { useChartLayout } from "../../../context/chartLayoutContext.mjs";
6
+ import { useChartName } from "../../../state/selectors/selectors.mjs";
7
+ import { selectArea } from "../../../state/selectors/areaSelectors.mjs";
8
+ import { useIsAnimating } from "../../../hooks/useIsAnimating.mjs";
9
+ import { filterProps } from "../../../utils/VueUtils.mjs";
10
+ import { computed, inject, provide, ref, watch } from "vue";
10
11
  //#region src/cartesian/area/hooks/useArea.ts
11
- var p = Symbol("AreaContext");
12
- function m(e) {
13
- u(p, e);
12
+ var AreaContextKey = Symbol("AreaContext");
13
+ function provideAreaContext(context) {
14
+ provide(AreaContextKey, context);
14
15
  }
15
- function h() {
16
- let e = l(p);
17
- if (!e) throw Error("useAreaContext must be used within Area component");
18
- return e;
16
+ function useAreaContext() {
17
+ const context = inject(AreaContextKey);
18
+ if (!context) throw new Error("useAreaContext must be used within Area component");
19
+ return context;
19
20
  }
20
- function g(l, u = {}, p) {
21
- let h = i(), g = a(), _ = e("v-charts-area-"), v = c(() => l.id || _), y = t(), b = d(l.isAnimationActive), x = c(() => (h.value === "horizontal" || h.value === "vertical") && (g.value === "AreaChart" || g.value === "ComposedChart") && !l.hide), S = c(() => ({
22
- baseValue: l.baseValue,
23
- stackId: l.stackId,
24
- connectNulls: l.connectNulls,
25
- data: l.data,
26
- dataKey: l.dataKey
27
- })), C = r((e) => o(e, l.xAxisId, l.yAxisId, y, S.value)), w = d(!0);
28
- f(() => l.hide, (e) => {
29
- e || (w.value = !0);
21
+ function useArea(props, attrs = {}, dotSlot) {
22
+ const layout = useChartLayout();
23
+ const chartName = useChartName();
24
+ const localId = uniqueId("v-charts-area-");
25
+ const clipPathId = computed(() => props.id || localId);
26
+ const isPanorama = useIsPanorama();
27
+ /**
28
+ * is Area animating
29
+ */
30
+ const isAnimating = useIsAnimating(() => props.isAnimationActive);
31
+ /**
32
+ * render only when layout is horizontal or vertical and chartName is AreaChart or ComposedChart
33
+ */
34
+ const shouldRender = computed(() => (layout.value === "horizontal" || layout.value === "vertical") && (chartName.value === "AreaChart" || chartName.value === "ComposedChart") && !props.hide);
35
+ const areaSettings = computed(() => ({
36
+ baseValue: props.baseValue,
37
+ stackId: props.stackId,
38
+ connectNulls: props.connectNulls,
39
+ data: props.data,
40
+ dataKey: props.dataKey
41
+ }));
42
+ const areaData = useAppSelector((state) => selectArea(state, props.xAxisId, props.yAxisId, isPanorama, areaSettings.value));
43
+ const isClipRectAnimating = ref(true);
44
+ watch(() => props.hide, (v) => {
45
+ if (!v) isClipRectAnimating.value = true;
30
46
  });
31
- let T = c(() => l.isAnimationActive && C.value?.points?.length && w.value), E = l.dot, D = n(E), { r: O = 3, strokeWidth: k = 2 } = s(E, !1) ?? {
47
+ const shouldShowAnimation = computed(() => {
48
+ return props.isAnimationActive && areaData.value?.points?.length && isClipRectAnimating.value;
49
+ });
50
+ const dot = props.dot;
51
+ const clipDot = isClipDot(dot);
52
+ const { r = 3, strokeWidth = 2 } = filterProps(dot, false) ?? {
32
53
  r: 3,
33
54
  strokeWidth: 2
34
- }, A = O * 2 + k, j = {
35
- clipPathId: v,
36
- layout: h,
37
- points: c(() => C.value?.points),
38
- props: l,
39
- attrs: u,
40
- dot: E,
41
- clipDot: D,
42
- dotSize: A,
43
- dotSlot: p,
44
- areaData: C,
45
- isAnimating: b,
46
- isClipRectAnimating: w
47
55
  };
48
- return m(j), {
49
- shouldRender: x,
50
- areaData: C,
51
- points: j.points,
52
- clipPathId: v,
53
- shouldShowAnimation: T
56
+ const dotSize = r * 2 + strokeWidth;
57
+ const areaContext = {
58
+ clipPathId,
59
+ layout,
60
+ points: computed(() => areaData.value?.points),
61
+ props,
62
+ attrs,
63
+ dot,
64
+ clipDot,
65
+ dotSize,
66
+ dotSlot,
67
+ areaData,
68
+ isAnimating,
69
+ isClipRectAnimating
70
+ };
71
+ provideAreaContext(areaContext);
72
+ return {
73
+ shouldRender,
74
+ areaData,
75
+ points: areaContext.points,
76
+ clipPathId,
77
+ shouldShowAnimation
54
78
  };
55
79
  }
56
80
  //#endregion
57
- export { g as useArea, h as useAreaContext };
81
+ export { useArea, useAreaContext };
@@ -1,10 +1,11 @@
1
- import { CurveVueProps as e } from "../../shape/Curve.mjs";
1
+ import { classProp } from "../../types/common.mjs";
2
+ import { CurveVueProps } from "../../shape/Curve.mjs";
2
3
  //#region src/cartesian/area/type.ts
3
- var t = {
4
- ...e,
4
+ var AreaVueProps = {
5
+ ...CurveVueProps,
5
6
  activeDot: {
6
7
  type: Boolean,
7
- default: !0
8
+ default: true
8
9
  },
9
10
  baseValue: {
10
11
  type: [Number, String],
@@ -12,7 +13,7 @@ var t = {
12
13
  },
13
14
  connectNulls: {
14
15
  type: Boolean,
15
- default: !1
16
+ default: false
16
17
  },
17
18
  data: {
18
19
  type: Array,
@@ -24,11 +25,11 @@ var t = {
24
25
  Number,
25
26
  Function
26
27
  ],
27
- required: !0
28
+ required: true
28
29
  },
29
30
  dot: {
30
31
  type: Boolean,
31
- default: !1
32
+ default: false
32
33
  },
33
34
  fill: {
34
35
  type: String,
@@ -45,11 +46,11 @@ var t = {
45
46
  },
46
47
  hide: {
47
48
  type: Boolean,
48
- default: !1
49
+ default: false
49
50
  },
50
51
  isAnimationActive: {
51
52
  type: Boolean,
52
- default: !0
53
+ default: true
53
54
  },
54
55
  label: {
55
56
  type: [Boolean, Object],
@@ -76,7 +77,7 @@ var t = {
76
77
  },
77
78
  needClip: {
78
79
  type: Boolean,
79
- default: !1
80
+ default: false
80
81
  },
81
82
  stackId: {
82
83
  type: [String, Number],
@@ -127,10 +128,7 @@ var t = {
127
128
  default: 0
128
129
  },
129
130
  name: { type: [String, Number] },
130
- class: {
131
- type: String,
132
- default: void 0
133
- }
131
+ class: classProp
134
132
  };
135
133
  //#endregion
136
- export { t as AreaVueProps };
134
+ export { AreaVueProps };
@@ -1,59 +1,79 @@
1
- import { isNumber as e } from "../../utils/validate.mjs";
2
- import { getCateCoordinateOfLine as t, getValueByDataKey as n } from "../../utils/chart.mjs";
1
+ import { isNumber } from "../../utils/validate.mjs";
2
+ import { getCateCoordinateOfLine, getValueByDataKey } from "../../utils/chart.mjs";
3
3
  //#region src/cartesian/area/utils.ts
4
- function r(t, n, r, i, a) {
5
- let o = r ?? n;
6
- if (e(o)) return o;
7
- let s = t === "horizontal" ? a : i, c = s.scale.domain();
8
- if (s.type === "number") {
9
- let e = Math.max(c[0], c[1]), t = Math.min(c[0], c[1]);
10
- return o === "dataMin" ? t : o === "dataMax" || e < 0 ? e : Math.max(Math.min(c[0], c[1]), 0);
4
+ function getBaseValue(layout, chartBaseValue, itemBaseValue, xAxis, yAxis) {
5
+ const baseValue = itemBaseValue ?? chartBaseValue;
6
+ if (isNumber(baseValue)) return baseValue;
7
+ const numericAxis = layout === "horizontal" ? yAxis : xAxis;
8
+ const domain = numericAxis.scale.domain();
9
+ if (numericAxis.type === "number") {
10
+ const domainMax = Math.max(domain[0], domain[1]);
11
+ const domainMin = Math.min(domain[0], domain[1]);
12
+ if (baseValue === "dataMin") return domainMin;
13
+ if (baseValue === "dataMax") return domainMax;
14
+ return domainMax < 0 ? domainMax : Math.max(Math.min(domain[0], domain[1]), 0);
11
15
  }
12
- return o === "dataMin" ? c[0] : o === "dataMax" ? c[1] : c[0];
16
+ if (baseValue === "dataMin") return domain[0];
17
+ if (baseValue === "dataMax") return domain[1];
18
+ return domain[0];
13
19
  }
14
- function i({ areaSettings: { connectNulls: e, baseValue: i, dataKey: a }, stackedData: o, layout: s, chartBaseValue: c, xAxis: l, yAxis: u, displayedData: d, dataStartIndex: f, xAxisTicks: p, yAxisTicks: m, bandSize: h }) {
15
- let g = o && o.length, _ = r(s, c, i, l, u), v = s === "horizontal", y = !1, b = d.map((r, i) => {
16
- let s;
17
- g ? s = o[f + i] : (s = n(r, a), Array.isArray(s) ? y = !0 : s = [_, s]);
18
- let c = s[1] == null || g && !e && n(r, a) == null;
19
- return v ? {
20
- x: t({
21
- axis: l,
22
- ticks: p,
23
- bandSize: h,
24
- entry: r,
25
- index: i
20
+ function computeArea({ areaSettings: { connectNulls, baseValue: itemBaseValue, dataKey }, stackedData, layout, chartBaseValue, xAxis, yAxis, displayedData, dataStartIndex, xAxisTicks, yAxisTicks, bandSize }) {
21
+ const hasStack = stackedData && stackedData.length;
22
+ const baseValue = getBaseValue(layout, chartBaseValue, itemBaseValue, xAxis, yAxis);
23
+ const isHorizontalLayout = layout === "horizontal";
24
+ let isRange = false;
25
+ const points = displayedData.map((entry, index) => {
26
+ let value;
27
+ if (hasStack) value = stackedData[dataStartIndex + index];
28
+ else {
29
+ value = getValueByDataKey(entry, dataKey);
30
+ if (!Array.isArray(value)) value = [baseValue, value];
31
+ else isRange = true;
32
+ }
33
+ const isBreakPoint = value[1] == null || hasStack && !connectNulls && getValueByDataKey(entry, dataKey) == null;
34
+ if (isHorizontalLayout) return {
35
+ x: getCateCoordinateOfLine({
36
+ axis: xAxis,
37
+ ticks: xAxisTicks,
38
+ bandSize,
39
+ entry,
40
+ index
26
41
  }),
27
- y: c ? null : u.scale(s[1]),
28
- value: s,
29
- payload: r
30
- } : {
31
- x: c ? null : l.scale(s[1]),
32
- y: t({
33
- axis: u,
34
- ticks: m,
35
- bandSize: h,
36
- entry: r,
37
- index: i
42
+ y: isBreakPoint ? null : yAxis.scale(value[1]),
43
+ value,
44
+ payload: entry
45
+ };
46
+ return {
47
+ x: isBreakPoint ? null : xAxis.scale(value[1]),
48
+ y: getCateCoordinateOfLine({
49
+ axis: yAxis,
50
+ ticks: yAxisTicks,
51
+ bandSize,
52
+ entry,
53
+ index
38
54
  }),
39
- value: s,
40
- payload: r
55
+ value,
56
+ payload: entry
57
+ };
58
+ });
59
+ let baseLine;
60
+ if (hasStack || isRange) baseLine = points.map((entry) => {
61
+ const x = Array.isArray(entry.value) ? entry.value[0] : null;
62
+ if (isHorizontalLayout) return {
63
+ x: entry.x,
64
+ y: x != null && entry.y != null ? yAxis.scale(x) : null
41
65
  };
42
- }), x;
43
- return x = g || y ? b.map((e) => {
44
- let t = Array.isArray(e.value) ? e.value[0] : null;
45
- return v ? {
46
- x: e.x,
47
- y: t != null && e.y != null ? u.scale(t) : null
48
- } : {
49
- x: t == null ? null : l.scale(t),
50
- y: e.y
66
+ return {
67
+ x: x != null ? xAxis.scale(x) : null,
68
+ y: entry.y
51
69
  };
52
- }) : v ? u.scale(_) : l.scale(_), {
53
- points: b,
54
- baseLine: x,
55
- isRange: y
70
+ });
71
+ else baseLine = isHorizontalLayout ? yAxis.scale(baseValue) : xAxis.scale(baseValue);
72
+ return {
73
+ points,
74
+ baseLine,
75
+ isRange
56
76
  };
57
77
  }
58
78
  //#endregion
59
- export { i as computeArea };
79
+ export { computeArea };