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,148 +1,217 @@
1
- import { interpolate as e } from "../../utils/data-utils.mjs";
2
- import { Curve as t } from "../../shape/Curve.mjs";
3
- import { Layer as n } from "../../container/Layer.mjs";
4
- import { Dot as r } from "../../shape/Dot.mjs";
5
- import { LabelList as i } from "../../components/label/LabelList.mjs";
6
- import { useLineContext as a } from "./hooks/useLine.mjs";
7
- import { Fragment as o, createVNode as s, defineComponent as c, mergeProps as l, onBeforeUnmount as u, ref as d, watch as f } from "vue";
8
- import { animate as p } from "motion-v";
1
+ import { interpolate } from "../../utils/data-utils.mjs";
2
+ import { Curve } from "../../shape/Curve.mjs";
3
+ import { Layer } from "../../container/Layer.mjs";
4
+ import { Dot } from "../../shape/Dot.mjs";
5
+ import { LabelList } from "../../components/label/LabelList.mjs";
6
+ import { useLineContext } from "./hooks/useLine.mjs";
7
+ import { Fragment, createVNode, defineComponent, mergeProps, onBeforeUnmount, ref, watch } from "vue";
8
+ import { animate } from "motion-v";
9
9
  //#region src/cartesian/line/StaticLine.tsx
10
- var m = /* @__PURE__ */ c({
10
+ var Dots = /* @__PURE__ */ defineComponent({
11
11
  name: "LineDots",
12
12
  props: { points: {
13
13
  type: Array,
14
14
  default: () => []
15
15
  } },
16
- setup(e) {
17
- let { clipPathId: t, clipDot: i, props: o, attrs: c, needClip: u, dotSlot: d } = a();
16
+ setup(_props) {
17
+ const { clipPathId, clipDot, props, attrs, needClip, dotSlot } = useLineContext();
18
18
  return () => {
19
- let { points: a } = e;
20
- if (!g(a, o.dot)) return null;
21
- let f = typeof o.dot == "object" && o.dot !== null ? o.dot : {}, p = {
22
- fill: "#fff",
23
- stroke: o.stroke,
24
- "stroke-width": o.strokeWidth,
25
- ...f
19
+ const { points } = _props;
20
+ if (!shouldRenderDots(points, props.dot)) return null;
21
+ const dotObjProps = typeof props.dot === "object" && props.dot !== null ? props.dot : {};
22
+ const dotsProps = {
23
+ "fill": "#fff",
24
+ "stroke": props.stroke,
25
+ "stroke-width": props.strokeWidth,
26
+ ...dotObjProps
26
27
  };
27
- return s(n, {
28
- class: "v-charts-line-dots",
29
- "clip-path": u.value ? `url(#clipPath-${i ? "" : "dots-"}${t.value})` : void 0
30
- }, { default: () => [a?.map((e, t) => {
31
- let n = e;
32
- return d ? d({
33
- ...p,
34
- ...c,
35
- cx: e.x,
36
- cy: e.y,
37
- index: t,
38
- value: n.value,
39
- payload: n.payload
40
- }) : s(r, l({ r: 3 }, p, c, {
41
- cx: e.x,
42
- cy: e.y,
43
- class: "v-charts-line-dot",
44
- clipDot: i
28
+ return createVNode(Layer, {
29
+ "class": "v-charts-line-dots",
30
+ "clip-path": needClip.value ? `url(#clipPath-${clipDot ? "" : "dots-"}${clipPathId.value})` : void 0
31
+ }, { default: () => [points?.map((point, index) => {
32
+ const pointAsLine = point;
33
+ if (dotSlot) return dotSlot({
34
+ ...dotsProps,
35
+ ...attrs,
36
+ cx: point.x,
37
+ cy: point.y,
38
+ index,
39
+ value: pointAsLine.value,
40
+ payload: pointAsLine.payload
41
+ });
42
+ return createVNode(Dot, mergeProps({ "r": 3 }, dotsProps, attrs, {
43
+ "cx": point.x,
44
+ "cy": point.y,
45
+ "class": "v-charts-line-dot",
46
+ "clipDot": clipDot
45
47
  }), null);
46
48
  })] });
47
49
  };
48
50
  }
49
- }), h = /* @__PURE__ */ c({
51
+ });
52
+ var StaticLine = /* @__PURE__ */ defineComponent({
50
53
  name: "StaticLine",
51
54
  setup() {
52
- let { points: r, clipPathId: c, layout: h, attrs: g, lineData: _, props: v, isAnimating: y, needClip: b, shapeSlot: x, labelSlot: S } = a(), C = d([]), w = d(1), T = !0, E = [], D = [], O = null, k = !1;
53
- function A() {
54
- O &&= (O.stop(), null);
55
+ const { points, clipPathId, layout, attrs, lineData, props, isAnimating, needClip, shapeSlot, labelSlot } = useLineContext();
56
+ const currentPoints = ref([]);
57
+ const strokeDashRatio = ref(1);
58
+ let isFirstRender = true;
59
+ let prevPoints = [];
60
+ let animationTarget = [];
61
+ let currentAnimation = null;
62
+ let revealAnimationRunning = false;
63
+ function stopCurrentAnimation() {
64
+ if (currentAnimation) {
65
+ currentAnimation.stop();
66
+ currentAnimation = null;
67
+ }
55
68
  }
56
- return u(() => {
57
- A();
58
- }), f(r, (t) => {
59
- if (!(t && D.length === t.length && t.every((e, t) => e.x === D[t].x && e.y === D[t].y))) if (t && t.length > 0) {
60
- if (!v.isAnimationActive) {
61
- T = !1, A(), k = !1, y.value = !1, C.value = t, E = t, D = t, w.value = 0;
69
+ onBeforeUnmount(() => {
70
+ stopCurrentAnimation();
71
+ });
72
+ watch(points, (newPoints) => {
73
+ if (newPoints && animationTarget.length === newPoints.length && newPoints.every((p, i) => p.x === animationTarget[i].x && p.y === animationTarget[i].y)) return;
74
+ if (newPoints && newPoints.length > 0) {
75
+ if (!props.isAnimationActive) {
76
+ isFirstRender = false;
77
+ stopCurrentAnimation();
78
+ revealAnimationRunning = false;
79
+ isAnimating.value = false;
80
+ currentPoints.value = newPoints;
81
+ prevPoints = newPoints;
82
+ animationTarget = newPoints;
83
+ strokeDashRatio.value = 0;
62
84
  return;
63
85
  }
64
- T ? (T = !1, k = !0, y.value = !0, C.value = t, D = t, w.value = 1, A(), O = p(1, 0, {
65
- ...v.transition,
66
- onUpdate(e) {
67
- k && (w.value = e);
68
- },
69
- onPlay() {
70
- v.onAnimationStart?.();
71
- },
72
- onComplete() {
73
- w.value = 0, y.value = !1, k = !1, O = null, E = C.value, D = E, v.onAnimationEnd?.();
74
- }
75
- })) : k ? (C.value = t, D = t) : (y.value = !0, w.value = 0, C.value.length && (E = C.value), D = t, A(), O = p(0, 1, {
76
- ...v.transition,
77
- onUpdate(n) {
78
- if (E.length) {
79
- let r = E.length / t.length;
80
- C.value = n === 1 ? t : t.map((t, i) => {
81
- let a = Math.floor(i * r);
82
- if (E[a]) {
83
- let r = E[a];
84
- return {
85
- ...t,
86
- x: e(r.x, t.x, n),
87
- y: e(r.y, t.y, n)
88
- };
89
- }
90
- return t;
91
- });
92
- } else C.value = t;
93
- },
94
- onPlay() {
95
- v.onAnimationStart?.();
96
- },
97
- onComplete() {
98
- y.value = !1, E = t, D = t, O = null, v.onAnimationEnd?.();
99
- }
100
- }));
101
- } else A(), k = !1, y.value = !1, C.value = t || [], E = C.value, D = E, w.value = 0;
102
- }, { immediate: !0 }), () => {
103
- let e = {
104
- ...g,
105
- fill: "none",
106
- stroke: v.stroke,
107
- "stroke-width": v.strokeWidth
108
- }, r = w.value, a = !y.value && (v.label || S), u = typeof v.label == "object" ? v.label : {}, d = null;
109
- C.value && C.value.length > 1 && (d = x ? x({
110
- ...e,
111
- points: C.value,
112
- connectNulls: v.connectNulls,
113
- type: v.type,
114
- layout: h.value,
86
+ if (isFirstRender) {
87
+ isFirstRender = false;
88
+ revealAnimationRunning = true;
89
+ isAnimating.value = true;
90
+ currentPoints.value = newPoints;
91
+ animationTarget = newPoints;
92
+ strokeDashRatio.value = 1;
93
+ stopCurrentAnimation();
94
+ currentAnimation = animate(1, 0, {
95
+ ...props.transition,
96
+ onUpdate(v) {
97
+ if (!revealAnimationRunning) return;
98
+ strokeDashRatio.value = v;
99
+ },
100
+ onPlay() {
101
+ props.onAnimationStart?.();
102
+ },
103
+ onComplete() {
104
+ strokeDashRatio.value = 0;
105
+ isAnimating.value = false;
106
+ revealAnimationRunning = false;
107
+ currentAnimation = null;
108
+ prevPoints = currentPoints.value;
109
+ animationTarget = prevPoints;
110
+ props.onAnimationEnd?.();
111
+ }
112
+ });
113
+ } else if (revealAnimationRunning) {
114
+ currentPoints.value = newPoints;
115
+ animationTarget = newPoints;
116
+ } else {
117
+ isAnimating.value = true;
118
+ strokeDashRatio.value = 0;
119
+ if (currentPoints.value.length) prevPoints = currentPoints.value;
120
+ animationTarget = newPoints;
121
+ stopCurrentAnimation();
122
+ currentAnimation = animate(0, 1, {
123
+ ...props.transition,
124
+ onUpdate(t) {
125
+ if (prevPoints.length) {
126
+ const prevPointsDiffFactor = prevPoints.length / newPoints.length;
127
+ currentPoints.value = t === 1 ? newPoints : newPoints.map((entry, index) => {
128
+ const prevPointIndex = Math.floor(index * prevPointsDiffFactor);
129
+ if (prevPoints[prevPointIndex]) {
130
+ const prev = prevPoints[prevPointIndex];
131
+ return {
132
+ ...entry,
133
+ x: interpolate(prev.x, entry.x, t),
134
+ y: interpolate(prev.y, entry.y, t)
135
+ };
136
+ }
137
+ return entry;
138
+ });
139
+ } else currentPoints.value = newPoints;
140
+ },
141
+ onPlay() {
142
+ props.onAnimationStart?.();
143
+ },
144
+ onComplete() {
145
+ isAnimating.value = false;
146
+ prevPoints = newPoints;
147
+ animationTarget = newPoints;
148
+ currentAnimation = null;
149
+ props.onAnimationEnd?.();
150
+ }
151
+ });
152
+ }
153
+ } else {
154
+ stopCurrentAnimation();
155
+ revealAnimationRunning = false;
156
+ isAnimating.value = false;
157
+ currentPoints.value = newPoints || [];
158
+ prevPoints = currentPoints.value;
159
+ animationTarget = prevPoints;
160
+ strokeDashRatio.value = 0;
161
+ }
162
+ }, { immediate: true });
163
+ return () => {
164
+ const curveAttrs = {
165
+ ...attrs,
166
+ "fill": "none",
167
+ "stroke": props.stroke,
168
+ "stroke-width": props.strokeWidth
169
+ };
170
+ const dashRatio = strokeDashRatio.value;
171
+ const showLabels = !isAnimating.value && (props.label || labelSlot);
172
+ const labelProps = typeof props.label === "object" ? props.label : {};
173
+ let curveContent = null;
174
+ if (currentPoints.value && currentPoints.value.length > 1) if (shapeSlot) curveContent = shapeSlot({
175
+ ...curveAttrs,
176
+ points: currentPoints.value,
177
+ connectNulls: props.connectNulls,
178
+ type: props.type,
179
+ layout: layout.value,
115
180
  class: "v-charts-line-curve"
116
- }) : s(t, l(e, g["stroke-dasharray"] == null && r > 0 ? {
117
- pathLength: 1,
181
+ });
182
+ else curveContent = createVNode(Curve, mergeProps(curveAttrs, !(attrs["stroke-dasharray"] != null) && dashRatio > 0 ? {
183
+ "pathLength": 1,
118
184
  "stroke-dasharray": 1,
119
- "stroke-dashoffset": r
185
+ "stroke-dashoffset": dashRatio
120
186
  } : {}, {
121
- points: C.value,
122
- connectNulls: v.connectNulls,
123
- type: v.type,
124
- layout: h.value,
125
- class: "v-charts-line-curve"
126
- }), null));
127
- let f = g["stroke-dasharray"] != null, p = (x || f) && r > 0 && d;
128
- return s(o, null, [
129
- d && s(n, { "clip-path": b.value ? `url(#clipPath-${c.value})` : void 0 }, { default: () => [p ? s("g", null, [s("defs", null, [s("clipPath", { id: `line-anim-${c.value}` }, [s("rect", {
130
- x: "0",
131
- y: "0",
132
- width: `${(1 - r) * 100}%`,
133
- height: "100%"
134
- }, null)])]), s("g", { "clip-path": `url(#line-anim-${c.value})` }, [d])]) : d] }),
135
- s(m, { points: C.value }, null),
136
- a && s(i, l(u, {
137
- data: _.value ?? [],
138
- dataKey: v.dataKey
139
- }), S ? { label: S } : void 0)
187
+ "points": currentPoints.value,
188
+ "connectNulls": props.connectNulls,
189
+ "type": props.type,
190
+ "layout": layout.value,
191
+ "class": "v-charts-line-curve"
192
+ }), null);
193
+ const hasCustomDashArray = attrs["stroke-dasharray"] != null;
194
+ const needClipAnim = (shapeSlot || hasCustomDashArray) && dashRatio > 0 && curveContent;
195
+ return createVNode(Fragment, null, [
196
+ curveContent && createVNode(Layer, { "clip-path": needClip.value ? `url(#clipPath-${clipPathId.value})` : void 0 }, { default: () => [needClipAnim ? createVNode("g", null, [createVNode("defs", null, [createVNode("clipPath", { "id": `line-anim-${clipPathId.value}` }, [createVNode("rect", {
197
+ "x": "0",
198
+ "y": "0",
199
+ "width": `${(1 - dashRatio) * 100}%`,
200
+ "height": "100%"
201
+ }, null)])]), createVNode("g", { "clip-path": `url(#line-anim-${clipPathId.value})` }, [curveContent])]) : curveContent] }),
202
+ createVNode(Dots, { "points": currentPoints.value }, null),
203
+ showLabels && createVNode(LabelList, mergeProps(labelProps, {
204
+ "data": lineData.value ?? [],
205
+ "dataKey": props.dataKey
206
+ }), labelSlot ? { label: labelSlot } : void 0)
140
207
  ]);
141
208
  };
142
209
  }
143
210
  });
144
- function g(e, t) {
145
- return e == null || !e.length ? !1 : t ? !0 : e.length === 1;
211
+ function shouldRenderDots(points, dot) {
212
+ if (points == null || !points.length) return false;
213
+ if (dot) return true;
214
+ return points.length === 1;
146
215
  }
147
216
  //#endregion
148
- export { h as StaticLine };
217
+ export { StaticLine };
@@ -1,53 +1,69 @@
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 { filterProps as o } from "../../../utils/VueUtils.mjs";
8
- import { useNeedsClip as s } from "../../useNeedsClip.mjs";
9
- import { selectLinePoints as c } from "../../../state/selectors/lineSelectors.mjs";
10
- import { computed as l, inject as u, provide as d, ref 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 { useIsAnimating } from "../../../hooks/useIsAnimating.mjs";
8
+ import { filterProps } from "../../../utils/VueUtils.mjs";
9
+ import { useNeedsClip } from "../../useNeedsClip.mjs";
10
+ import { selectLinePoints } from "../../../state/selectors/lineSelectors.mjs";
11
+ import { computed, inject, provide } from "vue";
11
12
  //#region src/cartesian/line/hooks/useLine.ts
12
- var p = Symbol("LineContext");
13
- function m(e) {
14
- d(p, e);
13
+ var LineContextKey = Symbol("LineContext");
14
+ function provideLineContext(context) {
15
+ provide(LineContextKey, context);
15
16
  }
16
- function h() {
17
- let e = u(p);
18
- if (!e) throw Error("useLineContext must be used within Line component");
19
- return e;
17
+ function useLineContext() {
18
+ const context = inject(LineContextKey);
19
+ if (!context) throw new Error("useLineContext must be used within Line component");
20
+ return context;
20
21
  }
21
- function g(u, d = {}, p, h, g) {
22
- let _ = i(), v = a(), y = e("v-charts-line-"), b = l(() => u.id || y), x = t(), S = f(u.isAnimationActive), { needClip: C } = s(u.xAxisId, u.yAxisId), w = l(() => (_.value === "horizontal" || _.value === "vertical") && (v.value === "LineChart" || v.value === "ComposedChart") && !u.hide), T = l(() => ({
23
- data: u.data,
24
- dataKey: u.dataKey
25
- })), E = r((e) => c(e, u.xAxisId, u.yAxisId, x, T.value)), D = u.dot, O = n(D), { r: k = 3, strokeWidth: A = 2 } = o(D, !1) ?? {
22
+ function useLine(props, attrs = {}, shapeSlot, dotSlot, labelSlot) {
23
+ const layout = useChartLayout();
24
+ const chartName = useChartName();
25
+ const localId = uniqueId("v-charts-line-");
26
+ const clipPathId = computed(() => props.id || localId);
27
+ const isPanorama = useIsPanorama();
28
+ const isAnimating = useIsAnimating(() => props.isAnimationActive);
29
+ const { needClip } = useNeedsClip(props.xAxisId, props.yAxisId);
30
+ const shouldRender = computed(() => (layout.value === "horizontal" || layout.value === "vertical") && (chartName.value === "LineChart" || chartName.value === "ComposedChart") && !props.hide);
31
+ const lineSettings = computed(() => ({
32
+ data: props.data,
33
+ dataKey: props.dataKey
34
+ }));
35
+ const lineData = useAppSelector((state) => selectLinePoints(state, props.xAxisId, props.yAxisId, isPanorama, lineSettings.value));
36
+ const dot = props.dot;
37
+ const clipDot = isClipDot(dot);
38
+ const { r = 3, strokeWidth = 2 } = filterProps(dot, false) ?? {
26
39
  r: 3,
27
40
  strokeWidth: 2
28
- }, j = k * 2 + A, M = {
29
- clipPathId: b,
30
- layout: _,
31
- points: l(() => E.value),
32
- props: u,
33
- attrs: d,
34
- lineData: E,
35
- isAnimating: S,
36
- needClip: C,
37
- dot: D,
38
- clipDot: O,
39
- dotSize: j,
40
- shapeSlot: p,
41
- dotSlot: h,
42
- labelSlot: g
43
41
  };
44
- return m(M), {
45
- shouldRender: w,
46
- needClip: C,
47
- lineData: E,
48
- points: M.points,
49
- clipPathId: b
42
+ const dotSize = r * 2 + strokeWidth;
43
+ const lineContext = {
44
+ clipPathId,
45
+ layout,
46
+ points: computed(() => lineData.value),
47
+ props,
48
+ attrs,
49
+ lineData,
50
+ isAnimating,
51
+ needClip,
52
+ dot,
53
+ clipDot,
54
+ dotSize,
55
+ shapeSlot,
56
+ dotSlot,
57
+ labelSlot
58
+ };
59
+ provideLineContext(lineContext);
60
+ return {
61
+ shouldRender,
62
+ needClip,
63
+ lineData,
64
+ points: lineContext.points,
65
+ clipPathId
50
66
  };
51
67
  }
52
68
  //#endregion
53
- export { p as LineContextKey, m as provideLineContext, g as useLine, h as useLineContext };
69
+ export { LineContextKey, provideLineContext, useLine, useLineContext };
@@ -1,29 +1,24 @@
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/line/type.ts
3
- var t = {
4
- ...e,
4
+ var LineVueProps = {
5
+ ...CurveVueProps,
5
6
  activeDot: {
6
7
  type: [
7
8
  Boolean,
8
9
  Object,
9
10
  Function
10
11
  ],
11
- default: !0
12
- },
13
- animationDuration: { type: Number },
14
- animationEasing: { type: String },
15
- animationBegin: {
16
- type: Number,
17
- default: 0
12
+ default: true
18
13
  },
19
14
  animationId: { type: String },
20
15
  isAnimationActive: {
21
16
  type: Boolean,
22
- default: !0
17
+ default: true
23
18
  },
24
19
  connectNulls: {
25
20
  type: Boolean,
26
- default: !1
21
+ default: false
27
22
  },
28
23
  data: {
29
24
  type: Array,
@@ -35,7 +30,7 @@ var t = {
35
30
  Number,
36
31
  Function
37
32
  ],
38
- required: !0
33
+ required: true
39
34
  },
40
35
  dot: {
41
36
  type: [
@@ -43,11 +38,11 @@ var t = {
43
38
  Object,
44
39
  Function
45
40
  ],
46
- default: !0
41
+ default: true
47
42
  },
48
43
  hide: {
49
44
  type: Boolean,
50
- default: !1
45
+ default: false
51
46
  },
52
47
  label: { type: [Boolean, Object] },
53
48
  legendType: {
@@ -84,7 +79,7 @@ var t = {
84
79
  },
85
80
  needClip: {
86
81
  type: Boolean,
87
- default: !1
82
+ default: false
88
83
  },
89
84
  id: { type: String },
90
85
  activeIndex: { type: Number },
@@ -106,7 +101,7 @@ var t = {
106
101
  default: 0
107
102
  },
108
103
  name: { type: [String, Number] },
109
- class: { type: String }
104
+ class: classProp
110
105
  };
111
106
  //#endregion
112
- export { t as LineVueProps };
107
+ export { LineVueProps };
@@ -1,33 +1,34 @@
1
- import { isNullish as e } from "../../utils/validate.mjs";
2
- import { getCateCoordinateOfLine as t, getValueByDataKey as n } from "../../utils/chart.mjs";
1
+ import { isNullish } from "../../utils/validate.mjs";
2
+ import { getCateCoordinateOfLine, getValueByDataKey } from "../../utils/chart.mjs";
3
3
  //#region src/cartesian/line/utils.ts
4
- function r({ layout: r, xAxis: i, yAxis: a, xAxisTicks: o, yAxisTicks: s, dataKey: c, bandSize: l, displayedData: u }) {
5
- return u.map((u, d) => {
6
- let f = n(u, c);
7
- return r === "horizontal" ? {
8
- x: t({
9
- axis: i,
10
- ticks: o,
11
- bandSize: l,
12
- entry: u,
13
- index: d
4
+ function computeLinePoints({ layout, xAxis, yAxis, xAxisTicks, yAxisTicks, dataKey, bandSize, displayedData }) {
5
+ return displayedData.map((entry, index) => {
6
+ const value = getValueByDataKey(entry, dataKey);
7
+ if (layout === "horizontal") return {
8
+ x: getCateCoordinateOfLine({
9
+ axis: xAxis,
10
+ ticks: xAxisTicks,
11
+ bandSize,
12
+ entry,
13
+ index
14
14
  }),
15
- y: e(f) ? null : a.scale(f),
16
- value: f,
17
- payload: u
18
- } : {
19
- x: e(f) ? null : i.scale(f),
20
- y: t({
21
- axis: a,
22
- ticks: s,
23
- bandSize: l,
24
- entry: u,
25
- index: d
15
+ y: isNullish(value) ? null : yAxis.scale(value),
16
+ value,
17
+ payload: entry
18
+ };
19
+ return {
20
+ x: isNullish(value) ? null : xAxis.scale(value),
21
+ y: getCateCoordinateOfLine({
22
+ axis: yAxis,
23
+ ticks: yAxisTicks,
24
+ bandSize,
25
+ entry,
26
+ index
26
27
  }),
27
- value: f,
28
- payload: u
28
+ value,
29
+ payload: entry
29
30
  };
30
31
  });
31
32
  }
32
33
  //#endregion
33
- export { r as computeLinePoints };
34
+ export { computeLinePoints };