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,13 +1,19 @@
1
- import { isNumber as e } from "../../utils/validate.mjs";
2
- import { filterProps as t } from "../../utils/VueUtils.mjs";
3
- import { Layer as n } from "../../container/Layer.mjs";
4
- import r from "../../components/Text.mjs";
5
- import { Label as i } from "../../components/label/Label.mjs";
6
- import { getTicks as a } from "../utils/get-ticks.mjs";
7
- import { createVNode as o, defineComponent as s, mergeProps as c, reactive as l } from "vue";
8
- import { get as u } from "es-toolkit/compat";
1
+ import { isNumber } from "../../utils/validate.mjs";
2
+ import { filterProps } from "../../utils/VueUtils.mjs";
3
+ import { Layer } from "../../container/Layer.mjs";
4
+ import Text_default from "../../components/Text.mjs";
5
+ import { Label } from "../../components/label/Label.mjs";
6
+ import { getTicks } from "../utils/get-ticks.mjs";
7
+ import { createVNode, defineComponent, mergeProps, reactive } from "vue";
8
+ import { get } from "es-toolkit/compat";
9
9
  //#region src/cartesian/cartesian-axis/CartesianAxis.tsx
10
- var d = /* @__PURE__ */ s({
10
+ /**
11
+ * @fileOverview Cartesian Axis
12
+ */
13
+ /** The orientation of the axis in correspondence to the chart */
14
+ /** A unit to be appended to a value */
15
+ /** The formatter function of tick */
16
+ var CartesianAxis = /* @__PURE__ */ defineComponent({
11
17
  name: "CartesianAxis",
12
18
  props: {
13
19
  x: {
@@ -42,19 +48,19 @@ var d = /* @__PURE__ */ s({
42
48
  },
43
49
  tick: {
44
50
  type: Boolean,
45
- default: !0
51
+ default: true
46
52
  },
47
53
  axisLine: {
48
54
  type: [Boolean, Object],
49
- default: () => !0
55
+ default: () => true
50
56
  },
51
57
  tickLine: {
52
58
  type: [Boolean, Object],
53
- default: () => !0
59
+ default: () => true
54
60
  },
55
61
  mirror: {
56
62
  type: Boolean,
57
- default: !1
63
+ default: false
58
64
  },
59
65
  tickMargin: {
60
66
  type: Number,
@@ -86,161 +92,205 @@ var d = /* @__PURE__ */ s({
86
92
  default: "#666"
87
93
  }
88
94
  },
89
- inheritAttrs: !1,
90
- setup(s, { attrs: d, slots: f }) {
91
- let p = l({
95
+ inheritAttrs: false,
96
+ setup(props, { attrs, slots }) {
97
+ const state = reactive({
92
98
  fontSize: "",
93
99
  letterSpacing: ""
94
- }), m = (t) => {
95
- let { x: n, y: r, width: i, height: a, orientation: o, tickSize: c, mirror: l, tickMargin: u } = s, d, f, p, m, h, g, _ = l ? -1 : 1, v = t.tickSize || c, y = e(t.tickCoord) ? t.tickCoord : t.coordinate;
96
- switch (o) {
100
+ });
101
+ const getTickLineCoord = (data) => {
102
+ const { x, y, width, height, orientation, tickSize, mirror, tickMargin } = props;
103
+ let x1, x2, y1, y2, tx, ty;
104
+ const sign = mirror ? -1 : 1;
105
+ const finalTickSize = data.tickSize || tickSize;
106
+ const tickCoord = isNumber(data.tickCoord) ? data.tickCoord : data.coordinate;
107
+ switch (orientation) {
97
108
  case "top":
98
- d = f = t.coordinate, m = r + +!l * a, p = m - _ * v, g = p - _ * u, h = y;
109
+ x1 = x2 = data.coordinate;
110
+ y2 = y + +!mirror * height;
111
+ y1 = y2 - sign * finalTickSize;
112
+ ty = y1 - sign * tickMargin;
113
+ tx = tickCoord;
99
114
  break;
100
115
  case "left":
101
- p = m = t.coordinate, f = n + +!l * i, d = f - _ * v, h = d - _ * u, g = y;
116
+ y1 = y2 = data.coordinate;
117
+ x2 = x + +!mirror * width;
118
+ x1 = x2 - sign * finalTickSize;
119
+ tx = x1 - sign * tickMargin;
120
+ ty = tickCoord;
102
121
  break;
103
122
  case "right":
104
- p = m = t.coordinate, f = n + +l * i, d = f + _ * v, h = d + _ * u, g = y;
123
+ y1 = y2 = data.coordinate;
124
+ x2 = x + +mirror * width;
125
+ x1 = x2 + sign * finalTickSize;
126
+ tx = x1 + sign * tickMargin;
127
+ ty = tickCoord;
105
128
  break;
106
129
  default:
107
- d = f = t.coordinate, m = r + +l * a, p = m + _ * v, g = p + _ * u, h = y;
130
+ x1 = x2 = data.coordinate;
131
+ y2 = y + +mirror * height;
132
+ y1 = y2 + sign * finalTickSize;
133
+ ty = y1 + sign * tickMargin;
134
+ tx = tickCoord;
108
135
  break;
109
136
  }
110
137
  return {
111
138
  line: {
112
- x1: d,
113
- y1: p,
114
- x2: f,
115
- y2: m
139
+ x1,
140
+ y1,
141
+ x2,
142
+ y2
116
143
  },
117
144
  tick: {
118
- x: h,
119
- y: g
145
+ x: tx,
146
+ y: ty
120
147
  }
121
148
  };
122
- }, h = () => {
123
- let { orientation: e, mirror: t } = s, n;
124
- switch (e) {
149
+ };
150
+ const getTickTextAnchor = () => {
151
+ const { orientation, mirror } = props;
152
+ let textAnchor;
153
+ switch (orientation) {
125
154
  case "left":
126
- n = t ? "start" : "end";
155
+ textAnchor = mirror ? "start" : "end";
127
156
  break;
128
157
  case "right":
129
- n = t ? "end" : "start";
158
+ textAnchor = mirror ? "end" : "start";
130
159
  break;
131
160
  default:
132
- n = "middle";
161
+ textAnchor = "middle";
133
162
  break;
134
163
  }
135
- return n;
136
- }, g = () => {
137
- let { orientation: e, mirror: t } = s;
138
- switch (e) {
164
+ return textAnchor;
165
+ };
166
+ const getTickVerticalAnchor = () => {
167
+ const { orientation, mirror } = props;
168
+ switch (orientation) {
139
169
  case "left":
140
170
  case "right": return "middle";
141
- case "top": return t ? "start" : "end";
142
- default: return t ? "end" : "start";
171
+ case "top": return mirror ? "start" : "end";
172
+ default: return mirror ? "end" : "start";
143
173
  }
144
- }, _ = () => {
145
- let { x: e, y: n, width: r, height: i, orientation: a, mirror: l, axisLine: d } = s, f = {
146
- ...t(s, !1),
147
- ...t(d, !1),
174
+ };
175
+ const renderAxisLine = () => {
176
+ const { x, y, width, height, orientation, mirror, axisLine } = props;
177
+ let lineProps = {
178
+ ...filterProps(props, false),
179
+ ...filterProps(axisLine, false),
148
180
  fill: "none",
149
181
  x1: 0,
150
182
  y1: 0,
151
183
  x2: 0,
152
184
  y2: 0
153
185
  };
154
- if (a === "top" || a === "bottom") {
155
- let t = +(a === "top" && !l || a === "bottom" && l);
156
- f = {
157
- ...f,
158
- x1: e,
159
- y1: n + t * i,
160
- x2: e + r,
161
- y2: n + t * i
186
+ if (orientation === "top" || orientation === "bottom") {
187
+ const needHeight = +(orientation === "top" && !mirror || orientation === "bottom" && mirror);
188
+ lineProps = {
189
+ ...lineProps,
190
+ x1: x,
191
+ y1: y + needHeight * height,
192
+ x2: x + width,
193
+ y2: y + needHeight * height
162
194
  };
163
195
  } else {
164
- let t = +(a === "left" && !l || a === "right" && l);
165
- f = {
166
- ...f,
167
- x1: e + t * r,
168
- y1: n,
169
- x2: e + t * r,
170
- y2: n + i
196
+ const needWidth = +(orientation === "left" && !mirror || orientation === "right" && mirror);
197
+ lineProps = {
198
+ ...lineProps,
199
+ x1: x + needWidth * width,
200
+ y1: y,
201
+ x2: x + needWidth * width,
202
+ y2: y + height
171
203
  };
172
204
  }
173
- return o("line", c(f, { class: ["v-charts-cartesian-axis-line", u(d, "class")] }), null);
205
+ return createVNode("line", mergeProps(lineProps, { "class": ["v-charts-cartesian-axis-line", get(axisLine, "class")] }), null);
174
206
  };
175
- function v(e, t) {
176
- return o(r, c(e, {
177
- class: ["v-charts-cartesian-axis-tick-value", e.class],
178
- value: t
207
+ function renderTickItem(props, value) {
208
+ const className = ["v-charts-cartesian-axis-tick-value", props.class];
209
+ return createVNode(Text_default, mergeProps(props, {
210
+ "class": className,
211
+ "value": value
179
212
  }), null);
180
213
  }
181
- let y = (e, r, i) => {
182
- let { tickLine: s, stroke: l, tick: d, tickFormatter: p, unit: _ } = e, y = a(e, r, i), b = h(), x = g(), S = t(e, !1), C = t(d, !1), w = {
183
- ...S,
214
+ const renderTicks = (props, fontSize, letterSpacing) => {
215
+ const { tickLine, stroke, tick, tickFormatter, unit } = props;
216
+ const finalTicks = getTicks(props, fontSize, letterSpacing);
217
+ const textAnchor = getTickTextAnchor();
218
+ const verticalAnchor = getTickVerticalAnchor();
219
+ const axisProps = filterProps(props, false);
220
+ const customTickProps = filterProps(tick, false);
221
+ const tickLineProps = {
222
+ ...axisProps,
184
223
  fill: "none",
185
- ...t(s, !1)
186
- }, T = y.map((e, t) => {
187
- let { line: r, tick: i } = m(e), a = {
188
- textAnchor: b,
189
- verticalAnchor: x,
190
- ...S,
224
+ ...filterProps(tickLine, false)
225
+ };
226
+ const items = finalTicks.map((entry, i) => {
227
+ const { line: lineCoord, tick: tickCoord } = getTickLineCoord(entry);
228
+ const tickProps = {
229
+ textAnchor,
230
+ verticalAnchor,
231
+ ...axisProps,
191
232
  stroke: "none",
192
- fill: l,
193
- ...C,
194
- ...i,
195
- index: t,
196
- payload: e,
197
- visibleTicksCount: y.length,
198
- tickFormatter: p
233
+ fill: stroke,
234
+ ...customTickProps,
235
+ ...tickCoord,
236
+ index: i,
237
+ payload: entry,
238
+ visibleTicksCount: finalTicks.length,
239
+ tickFormatter
199
240
  };
200
- return o(n, {
201
- class: "v-charts-cartesian-axis-tick",
202
- key: `tick-${e.value}-${e.coordinate}-${e.tickCoord}`
203
- }, { default: () => [s && o("line", c(w, r, { class: ["v-charts-cartesian-axis-tick-line", u(s, "class")] }), null), d && (f.tick ? f.tick({
204
- ...a,
205
- value: e.value
206
- }) : v(a, `${typeof p == "function" ? p(e.value, t) : e.value}${_ || ""}`))] });
241
+ return createVNode(Layer, {
242
+ "class": "v-charts-cartesian-axis-tick",
243
+ "key": `tick-${entry.value}-${entry.coordinate}-${entry.tickCoord}`
244
+ }, { default: () => [tickLine && createVNode("line", mergeProps(tickLineProps, lineCoord, { "class": ["v-charts-cartesian-axis-tick-line", get(tickLine, "class")] }), null), tick && (slots.tick ? slots.tick({
245
+ ...tickProps,
246
+ value: entry.value
247
+ }) : renderTickItem(tickProps, `${typeof tickFormatter === "function" ? tickFormatter(entry.value, i) : entry.value}${unit || ""}`))] });
207
248
  });
208
- return T.length > 0 ? o("g", { class: "v-charts-cartesian-axis-ticks" }, [T]) : null;
209
- }, b = () => {
210
- let { label: e, x: t, y: n, width: r, height: a } = s;
211
- if (!e) return null;
212
- let l = {
213
- x: t,
214
- y: n,
215
- width: r,
216
- height: a
249
+ return items.length > 0 ? createVNode("g", { "class": "v-charts-cartesian-axis-ticks" }, [items]) : null;
250
+ };
251
+ const renderLabel = () => {
252
+ const { label, x, y, width, height } = props;
253
+ if (!label) return null;
254
+ const axisViewBox = {
255
+ x,
256
+ y,
257
+ width,
258
+ height
217
259
  };
218
- return typeof e == "string" || typeof e == "number" ? o(i, {
219
- value: e,
220
- viewBox: l
221
- }, null) : typeof e == "object" ? o(i, c(e, { viewBox: l }), null) : null;
260
+ if (typeof label === "string" || typeof label === "number") return createVNode(Label, {
261
+ "value": label,
262
+ "viewBox": axisViewBox
263
+ }, null);
264
+ if (typeof label === "object") return createVNode(Label, mergeProps(label, { "viewBox": axisViewBox }), null);
265
+ return null;
222
266
  };
223
267
  return () => {
224
- let { axisLine: e, width: t, height: r, hide: i } = s;
225
- return i || t != null && t <= 0 || r != null && r <= 0 ? null : o(n, {
226
- class: ["v-charts-cartesian-axis", d.class],
227
- ref: (e) => {
228
- let t = e?.$el;
229
- if (t) {
230
- let e = t?.getElementsByClassName("v-charts-cartesian-axis-tick-value")[0];
231
- if (e) {
232
- let t = window.getComputedStyle(e).fontSize, n = window.getComputedStyle(e).letterSpacing;
233
- (t !== p.fontSize || n !== p.letterSpacing) && (p.fontSize = window.getComputedStyle(e).fontSize, p.letterSpacing = window.getComputedStyle(e).letterSpacing);
268
+ const { axisLine, width, height, hide } = props;
269
+ if (hide) return null;
270
+ if (width != null && width <= 0 || height != null && height <= 0) return null;
271
+ return createVNode(Layer, {
272
+ "class": ["v-charts-cartesian-axis", attrs.class],
273
+ "ref": (ref) => {
274
+ const elm = ref?.$el;
275
+ if (elm) {
276
+ const tick = elm?.getElementsByClassName("v-charts-cartesian-axis-tick-value")[0];
277
+ if (tick) {
278
+ const calculatedFontSize = window.getComputedStyle(tick).fontSize;
279
+ const calculatedLetterSpacing = window.getComputedStyle(tick).letterSpacing;
280
+ if (calculatedFontSize !== state.fontSize || calculatedLetterSpacing !== state.letterSpacing) {
281
+ state.fontSize = window.getComputedStyle(tick).fontSize;
282
+ state.letterSpacing = window.getComputedStyle(tick).letterSpacing;
283
+ }
234
284
  }
235
285
  }
236
286
  }
237
287
  }, { default: () => [
238
- e && _(),
239
- y(s, p.fontSize, p.letterSpacing),
240
- b()
288
+ axisLine && renderAxisLine(),
289
+ renderTicks(props, state.fontSize, state.letterSpacing),
290
+ renderLabel()
241
291
  ] });
242
292
  };
243
293
  }
244
294
  });
245
295
  //#endregion
246
- export { d as CartesianAxis };
296
+ export { CartesianAxis };
@@ -1,8 +1,8 @@
1
- import { createVNode as e, defineComponent as t } from "vue";
1
+ import { createVNode, defineComponent } from "vue";
2
2
  //#region src/cartesian/cartesian-grid/Background.tsx
3
- var n = /* @__PURE__ */ t({
3
+ var Background = /* @__PURE__ */ defineComponent({
4
4
  name: "Background",
5
- inheritAttrs: !1,
5
+ inheritAttrs: false,
6
6
  props: {
7
7
  fill: String,
8
8
  fillOpacity: Number,
@@ -12,19 +12,22 @@ var n = /* @__PURE__ */ t({
12
12
  height: Number,
13
13
  ry: Number
14
14
  },
15
- setup(t) {
16
- return () => !t.fill || t.fill === "none" ? null : e("rect", {
17
- x: t.x,
18
- y: t.y,
19
- ry: t.ry,
20
- width: t.width,
21
- height: t.height,
22
- stroke: "none",
23
- fill: t.fill,
24
- "fill-opacity": t.fillOpacity,
25
- class: "v-charts-cartesian-grid-bg"
26
- }, null);
15
+ setup(props) {
16
+ return () => {
17
+ if (!props.fill || props.fill === "none") return null;
18
+ return createVNode("rect", {
19
+ "x": props.x,
20
+ "y": props.y,
21
+ "ry": props.ry,
22
+ "width": props.width,
23
+ "height": props.height,
24
+ "stroke": "none",
25
+ "fill": props.fill,
26
+ "fill-opacity": props.fillOpacity,
27
+ "class": "v-charts-cartesian-grid-bg"
28
+ }, null);
29
+ };
27
30
  }
28
31
  });
29
32
  //#endregion
30
- export { n as default };
33
+ export { Background as default };