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,29 +1,16 @@
1
- import { isNumOrStr as e, isWellBehavedNumber as t } from "../../utils/validate.mjs";
2
- import { useIsPanorama as n } from "../../context/PanoramaContextProvider.mjs";
3
- import { selectAxisScale as r } from "../../state/selectors/axisSelectors.mjs";
4
- import { useAppDispatch as i, useAppSelector as a } from "../../state/hooks.mjs";
5
- import { Layer as o } from "../../container/Layer.mjs";
6
- import { Label as s } from "../../components/label/Label.mjs";
7
- import { Rectangle as c } from "../../shape/Rectangle.mjs";
8
- import { addArea as l, removeArea as u } from "../../state/referenceElementsSlice.mjs";
9
- import { useClipPathId as d } from "../../chart/provideClipPathId.mjs";
10
- import { computed as f, createVNode as p, defineComponent as m, mergeProps as h, onMounted as g, onUnmounted as _, reactive as v } from "vue";
11
- //#region src/cartesian/reference-area/ReferenceArea.tsx
12
- function y(e, n, r) {
13
- let i = e(n);
14
- if (!t(i)) return;
15
- let a = e.bandwidth?.() ?? 0;
16
- return r === "start" ? i : i + a;
17
- }
18
- function b(e) {
19
- let t = e.range();
20
- return Math.min(t[0], t[1]);
21
- }
22
- function x(e) {
23
- let t = e.range();
24
- return Math.max(t[0], t[1]);
25
- }
26
- var S = /* @__PURE__ */ m({
1
+ import { classProp } from "../../types/common.mjs";
2
+ import { isNumOrStr } from "../../utils/validate.mjs";
3
+ import { useIsPanorama } from "../../context/PanoramaContextProvider.mjs";
4
+ import { selectAxisScale } from "../../state/selectors/axisSelectors.mjs";
5
+ import { useAppDispatch, useAppSelector } from "../../state/hooks.mjs";
6
+ import { Layer } from "../../container/Layer.mjs";
7
+ import { Label } from "../../components/label/Label.mjs";
8
+ import { Rectangle } from "../../shape/Rectangle.mjs";
9
+ import { addArea, removeArea } from "../../state/referenceElementsSlice.mjs";
10
+ import { useClipPathId } from "../../chart/provideClipPathId.mjs";
11
+ import { rangeMax, rangeMin, scaleValue } from "../../utils/scale.mjs";
12
+ import { computed, createVNode, defineComponent, mergeProps, onMounted, onUnmounted, reactive } from "vue";
13
+ var ReferenceArea = /* @__PURE__ */ defineComponent({
27
14
  name: "ReferenceArea",
28
15
  props: {
29
16
  x1: {
@@ -79,68 +66,82 @@ var S = /* @__PURE__ */ m({
79
66
  type: String,
80
67
  default: "discard"
81
68
  },
82
- className: {
83
- type: String,
84
- default: void 0
85
- },
86
69
  radius: {
87
70
  type: [Number, Array],
88
71
  default: 0
89
- }
72
+ },
73
+ class: classProp
90
74
  },
91
- inheritAttrs: !1,
92
- setup(t, { attrs: m }) {
93
- let S = i(), C = n(), w = d(), T = v({
94
- xAxisId: t.xAxisId,
95
- yAxisId: t.yAxisId,
96
- ifOverflow: t.ifOverflow,
97
- x1: t.x1,
98
- x2: t.x2,
99
- y1: t.y1,
100
- y2: t.y2
75
+ inheritAttrs: false,
76
+ setup(props, { attrs }) {
77
+ const dispatch = useAppDispatch();
78
+ const isPanorama = useIsPanorama();
79
+ const clipPathId = useClipPathId();
80
+ const settings = reactive({
81
+ xAxisId: props.xAxisId,
82
+ yAxisId: props.yAxisId,
83
+ ifOverflow: props.ifOverflow,
84
+ x1: props.x1,
85
+ x2: props.x2,
86
+ y1: props.y1,
87
+ y2: props.y2
88
+ });
89
+ onMounted(() => {
90
+ dispatch(addArea(settings));
101
91
  });
102
- g(() => {
103
- S(l(T));
104
- }), _(() => {
105
- S(u(T));
92
+ onUnmounted(() => {
93
+ dispatch(removeArea(settings));
106
94
  });
107
- let E = a((e) => r(e, "xAxis", t.xAxisId, C)), D = a((e) => r(e, "yAxis", t.yAxisId, C)), O = f(() => {
108
- let n = E.value, r = D.value;
109
- if (!n || !r) return null;
110
- let i = e(t.x1), a = e(t.x2), o = e(t.y1), s = e(t.y2);
111
- if (!i && !a && !o && !s) return null;
112
- let c = i ? y(n, t.x1, "start") : b(n), l = a ? y(n, t.x2, "end") : x(n), u = o ? y(r, t.y1, "start") : b(r), d = s ? y(r, t.y2, "end") : x(r);
113
- return c == null || l == null || u == null || d == null ? null : {
114
- x: Math.min(c, l),
115
- y: Math.min(u, d),
116
- width: Math.abs(l - c),
117
- height: Math.abs(d - u)
95
+ const xAxisScale = useAppSelector((state) => selectAxisScale(state, "xAxis", props.xAxisId, isPanorama));
96
+ const yAxisScale = useAppSelector((state) => selectAxisScale(state, "yAxis", props.yAxisId, isPanorama));
97
+ const rect = computed(() => {
98
+ const xScale = xAxisScale.value;
99
+ const yScale = yAxisScale.value;
100
+ if (!xScale || !yScale) return null;
101
+ const hasX1 = isNumOrStr(props.x1);
102
+ const hasX2 = isNumOrStr(props.x2);
103
+ const hasY1 = isNumOrStr(props.y1);
104
+ const hasY2 = isNumOrStr(props.y2);
105
+ if (!hasX1 && !hasX2 && !hasY1 && !hasY2) return null;
106
+ const px1 = hasX1 ? scaleValue(xScale, props.x1, "start") : rangeMin(xScale);
107
+ const px2 = hasX2 ? scaleValue(xScale, props.x2, "end") : rangeMax(xScale);
108
+ const py1 = hasY1 ? scaleValue(yScale, props.y1, "start") : rangeMin(yScale);
109
+ const py2 = hasY2 ? scaleValue(yScale, props.y2, "end") : rangeMax(yScale);
110
+ if (px1 == null || px2 == null || py1 == null || py2 == null) return null;
111
+ return {
112
+ x: Math.min(px1, px2),
113
+ y: Math.min(py1, py2),
114
+ width: Math.abs(px2 - px1),
115
+ height: Math.abs(py2 - py1)
118
116
  };
119
117
  });
120
118
  return () => {
121
- let e = O.value;
122
- if (!e) return null;
123
- let n = t.ifOverflow === "hidden" ? `url(#${w})` : void 0, r = {
124
- ...m,
125
- stroke: t.stroke,
126
- "stroke-width": t.strokeWidth,
127
- fill: t.fill,
128
- "fill-opacity": t.fillOpacity
129
- }, i = t.label, a = typeof i == "object" && i ? i : {};
130
- return p(o, { class: ["v-charts-reference-area", t.className] }, { default: () => [p(c, h(r, {
131
- "clip-path": n,
132
- x: e.x,
133
- y: e.y,
134
- width: e.width,
135
- height: e.height,
136
- radius: t.radius,
137
- class: "v-charts-reference-area-rect"
138
- }), null), i != null && i !== !1 && p(s, h({
139
- viewBox: e,
140
- value: typeof i == "string" || typeof i == "number" ? i : void 0
141
- }, a), null)] });
119
+ const r = rect.value;
120
+ if (!r) return null;
121
+ const clipPath = props.ifOverflow === "hidden" ? `url(#${clipPathId})` : void 0;
122
+ const svgAttrs = {
123
+ ...attrs,
124
+ "stroke": props.stroke,
125
+ "stroke-width": props.strokeWidth,
126
+ "fill": props.fill,
127
+ "fill-opacity": props.fillOpacity
128
+ };
129
+ const labelValue = props.label;
130
+ const labelProps = typeof labelValue === "object" && labelValue !== null ? labelValue : {};
131
+ return createVNode(Layer, { "class": ["v-charts-reference-area", props.class] }, { default: () => [createVNode(Rectangle, mergeProps(svgAttrs, {
132
+ "clip-path": clipPath,
133
+ "x": r.x,
134
+ "y": r.y,
135
+ "width": r.width,
136
+ "height": r.height,
137
+ "radius": props.radius,
138
+ "class": "v-charts-reference-area-rect"
139
+ }), null), labelValue != null && labelValue !== false && createVNode(Label, mergeProps({
140
+ "viewBox": r,
141
+ "value": typeof labelValue === "string" || typeof labelValue === "number" ? labelValue : void 0
142
+ }, labelProps), null)] });
142
143
  };
143
144
  }
144
145
  });
145
146
  //#endregion
146
- export { S as ReferenceArea };
147
+ export { ReferenceArea };
@@ -0,0 +1,134 @@
1
+ import { isNumOrStr } from "../../utils/validate.mjs";
2
+ import { useIsPanorama } from "../../context/PanoramaContextProvider.mjs";
3
+ import { selectAxisScale } from "../../state/selectors/axisSelectors.mjs";
4
+ import { useAppDispatch, useAppSelector } from "../../state/hooks.mjs";
5
+ import { Layer } from "../../container/Layer.mjs";
6
+ import { Dot } from "../../shape/Dot.mjs";
7
+ import { Label } from "../../components/label/Label.mjs";
8
+ import { addDot, removeDot } from "../../state/referenceElementsSlice.mjs";
9
+ import { useClipPathId } from "../../chart/provideClipPathId.mjs";
10
+ import { isInRange, scaleCoord } from "../../utils/scale.mjs";
11
+ import { computed, createVNode, defineComponent, mergeProps, onMounted, onUnmounted, reactive } from "vue";
12
+ var ReferenceDot = /* @__PURE__ */ defineComponent({
13
+ name: "ReferenceDot",
14
+ props: {
15
+ x: {
16
+ type: [Number, String],
17
+ default: void 0
18
+ },
19
+ y: {
20
+ type: [Number, String],
21
+ default: void 0
22
+ },
23
+ r: {
24
+ type: Number,
25
+ default: 10
26
+ },
27
+ xAxisId: {
28
+ type: [Number, String],
29
+ default: 0
30
+ },
31
+ yAxisId: {
32
+ type: [Number, String],
33
+ default: 0
34
+ },
35
+ fill: {
36
+ type: String,
37
+ default: "#fff"
38
+ },
39
+ stroke: {
40
+ type: String,
41
+ default: "#ccc"
42
+ },
43
+ label: {
44
+ type: [
45
+ String,
46
+ Number,
47
+ Boolean,
48
+ Object
49
+ ],
50
+ default: void 0
51
+ },
52
+ ifOverflow: {
53
+ type: String,
54
+ default: "discard"
55
+ }
56
+ },
57
+ inheritAttrs: false,
58
+ slots: Object,
59
+ setup(props, { attrs, slots }) {
60
+ const dispatch = useAppDispatch();
61
+ const isPanorama = useIsPanorama();
62
+ const clipPathId = useClipPathId();
63
+ const settings = reactive({
64
+ xAxisId: props.xAxisId,
65
+ yAxisId: props.yAxisId,
66
+ ifOverflow: props.ifOverflow,
67
+ x: props.x,
68
+ y: props.y,
69
+ r: props.r
70
+ });
71
+ onMounted(() => {
72
+ dispatch(addDot(settings));
73
+ });
74
+ onUnmounted(() => {
75
+ dispatch(removeDot(settings));
76
+ });
77
+ const xAxisScale = useAppSelector((state) => selectAxisScale(state, "xAxis", props.xAxisId, isPanorama));
78
+ const yAxisScale = useAppSelector((state) => selectAxisScale(state, "yAxis", props.yAxisId, isPanorama));
79
+ const dotCoord = computed(() => {
80
+ const xScale = xAxisScale.value;
81
+ const yScale = yAxisScale.value;
82
+ if (!xScale || !yScale) return null;
83
+ if (!isNumOrStr(props.x) || !isNumOrStr(props.y)) return null;
84
+ const cx = scaleCoord(xScale, props.x);
85
+ const cy = scaleCoord(yScale, props.y);
86
+ if (cx == null || cy == null) return null;
87
+ if (props.ifOverflow === "discard") {
88
+ if (!isInRange(xScale, cx) || !isInRange(yScale, cy)) return null;
89
+ }
90
+ return {
91
+ cx,
92
+ cy
93
+ };
94
+ });
95
+ return () => {
96
+ const coord = dotCoord.value;
97
+ if (!coord) return null;
98
+ const { cx, cy } = coord;
99
+ const clipPath = props.ifOverflow === "hidden" ? `url(#${clipPathId})` : void 0;
100
+ const { class: userClass, ...restAttrs } = attrs;
101
+ const svgAttrs = {
102
+ ...restAttrs,
103
+ fill: props.fill,
104
+ stroke: props.stroke
105
+ };
106
+ const labelViewBox = {
107
+ x: cx - props.r,
108
+ y: cy - props.r,
109
+ width: props.r * 2,
110
+ height: props.r * 2
111
+ };
112
+ const labelValue = props.label;
113
+ const labelProps = typeof labelValue === "object" && labelValue !== null ? labelValue : {};
114
+ const shapeProps = {
115
+ ...svgAttrs,
116
+ cx,
117
+ cy,
118
+ r: props.r,
119
+ clipPath
120
+ };
121
+ return createVNode(Layer, { "class": ["v-charts-reference-dot", userClass] }, { default: () => [slots.shape ? slots.shape(shapeProps) : createVNode(Dot, mergeProps(svgAttrs, {
122
+ "cx": cx,
123
+ "cy": cy,
124
+ "r": props.r,
125
+ "clip-path": clipPath
126
+ }), null), labelValue != null && labelValue !== false && createVNode(Label, mergeProps({
127
+ "viewBox": labelViewBox,
128
+ "value": typeof labelValue === "string" || typeof labelValue === "number" ? labelValue : void 0
129
+ }, labelProps), null)] });
130
+ };
131
+ }
132
+ });
133
+ //#endregion
134
+ export { ReferenceDot };
@@ -1,23 +1,16 @@
1
- import { isNumOrStr as e, isWellBehavedNumber as t } from "../../utils/validate.mjs";
2
- import { useIsPanorama as n } from "../../context/PanoramaContextProvider.mjs";
3
- import { selectAxisScale as r, selectXAxisSettings as i, selectYAxisSettings as a } from "../../state/selectors/axisSelectors.mjs";
4
- import { useAppDispatch as o, useAppSelector as s } from "../../state/hooks.mjs";
5
- import { useViewBox as c } from "../../context/chartLayoutContext.mjs";
6
- import { Layer as l } from "../../container/Layer.mjs";
7
- import { Label as u } from "../../components/label/Label.mjs";
8
- import { addLine as d, removeLine as f } from "../../state/referenceElementsSlice.mjs";
9
- import { useClipPathId as p } from "../../chart/provideClipPathId.mjs";
10
- import { computed as m, createVNode as h, defineComponent as g, mergeProps as _, onMounted as v, onUnmounted as y, reactive as b } from "vue";
11
- //#region src/cartesian/reference-line/ReferenceLine.tsx
12
- function x(e, n) {
13
- let r = e(n);
14
- if (t(r)) return r + (e.bandwidth?.() ?? 0) / 2;
15
- }
16
- function S(e, t) {
17
- let n = e.range(), r = Math.min(n[0], n[1]), i = Math.max(n[0], n[1]);
18
- return t >= r && t <= i;
19
- }
20
- var C = /* @__PURE__ */ g({
1
+ import { classProp } from "../../types/common.mjs";
2
+ import { isNumOrStr, isWellBehavedNumber } from "../../utils/validate.mjs";
3
+ import { useIsPanorama } from "../../context/PanoramaContextProvider.mjs";
4
+ import { selectAxisScale, selectXAxisSettings, selectYAxisSettings } from "../../state/selectors/axisSelectors.mjs";
5
+ import { useAppDispatch, useAppSelector } from "../../state/hooks.mjs";
6
+ import { useViewBox } from "../../context/chartLayoutContext.mjs";
7
+ import { Layer } from "../../container/Layer.mjs";
8
+ import { Label } from "../../components/label/Label.mjs";
9
+ import { addLine, removeLine } from "../../state/referenceElementsSlice.mjs";
10
+ import { useClipPathId } from "../../chart/provideClipPathId.mjs";
11
+ import { isInRange, scaleCoord } from "../../utils/scale.mjs";
12
+ import { computed, createVNode, defineComponent, mergeProps, onMounted, onUnmounted, reactive } from "vue";
13
+ var ReferenceLine = /* @__PURE__ */ defineComponent({
21
14
  name: "ReferenceLine",
22
15
  props: {
23
16
  x: {
@@ -61,83 +54,99 @@ var C = /* @__PURE__ */ g({
61
54
  type: String,
62
55
  default: "discard"
63
56
  },
64
- className: {
65
- type: String,
66
- default: void 0
67
- }
57
+ class: classProp
68
58
  },
69
- inheritAttrs: !1,
70
- setup(g, { attrs: C }) {
71
- let w = o(), T = n(), E = p(), D = c(), O = b({
72
- xAxisId: g.xAxisId,
73
- yAxisId: g.yAxisId,
74
- ifOverflow: g.ifOverflow,
75
- x: g.x,
76
- y: g.y
59
+ inheritAttrs: false,
60
+ setup(props, { attrs }) {
61
+ const dispatch = useAppDispatch();
62
+ const isPanorama = useIsPanorama();
63
+ const clipPathId = useClipPathId();
64
+ const viewBox = useViewBox();
65
+ const settings = reactive({
66
+ xAxisId: props.xAxisId,
67
+ yAxisId: props.yAxisId,
68
+ ifOverflow: props.ifOverflow,
69
+ x: props.x,
70
+ y: props.y
71
+ });
72
+ onMounted(() => {
73
+ dispatch(addLine(settings));
77
74
  });
78
- v(() => {
79
- w(d(O));
80
- }), y(() => {
81
- w(f(O));
75
+ onUnmounted(() => {
76
+ dispatch(removeLine(settings));
82
77
  });
83
- let k = s((e) => i(e, g.xAxisId)), A = s((e) => a(e, g.yAxisId)), j = s((e) => r(e, "xAxis", g.xAxisId, T)), M = s((e) => r(e, "yAxis", g.yAxisId, T)), N = m(() => {
84
- let t = D.value, n = j.value, r = M.value;
85
- if (!t || !n || !r) return null;
86
- if (e(g.y)) {
87
- let e = x(r, g.y);
88
- if (e == null || g.ifOverflow === "discard" && !S(r, e)) return null;
89
- let n = A.value?.orientation, i = [{
90
- x: t.x + t.width,
91
- y: e
78
+ const xAxisSettings = useAppSelector((state) => selectXAxisSettings(state, props.xAxisId));
79
+ const yAxisSettings = useAppSelector((state) => selectYAxisSettings(state, props.yAxisId));
80
+ const xAxisScale = useAppSelector((state) => selectAxisScale(state, "xAxis", props.xAxisId, isPanorama));
81
+ const yAxisScale = useAppSelector((state) => selectAxisScale(state, "yAxis", props.yAxisId, isPanorama));
82
+ const endPoints = computed(() => {
83
+ const vb = viewBox.value;
84
+ const xScale = xAxisScale.value;
85
+ const yScale = yAxisScale.value;
86
+ if (!vb || !xScale || !yScale) return null;
87
+ if (isNumOrStr(props.y)) {
88
+ const coord = scaleCoord(yScale, props.y);
89
+ if (coord == null) return null;
90
+ if (props.ifOverflow === "discard" && !isInRange(yScale, coord)) return null;
91
+ const yOrientation = yAxisSettings.value?.orientation;
92
+ const points = [{
93
+ x: vb.x + vb.width,
94
+ y: coord
92
95
  }, {
93
- x: t.x,
94
- y: e
96
+ x: vb.x,
97
+ y: coord
95
98
  }];
96
- return n === "left" ? i.reverse() : i;
99
+ return yOrientation === "left" ? points.reverse() : points;
97
100
  }
98
- if (e(g.x)) {
99
- let e = x(n, g.x);
100
- if (e == null || g.ifOverflow === "discard" && !S(n, e)) return null;
101
- let r = k.value?.orientation, i = [{
102
- x: e,
103
- y: t.y + t.height
101
+ if (isNumOrStr(props.x)) {
102
+ const coord = scaleCoord(xScale, props.x);
103
+ if (coord == null) return null;
104
+ if (props.ifOverflow === "discard" && !isInRange(xScale, coord)) return null;
105
+ const xOrientation = xAxisSettings.value?.orientation;
106
+ const points = [{
107
+ x: coord,
108
+ y: vb.y + vb.height
104
109
  }, {
105
- x: e,
106
- y: t.y
110
+ x: coord,
111
+ y: vb.y
107
112
  }];
108
- return r === "top" ? i.reverse() : i;
113
+ return xOrientation === "top" ? points.reverse() : points;
109
114
  }
110
115
  return null;
111
116
  });
112
117
  return () => {
113
- let e = N.value;
114
- if (!e || e.length < 2) return null;
115
- let [n, r] = e;
116
- if (!t(n.x) || !t(n.y) || !t(r.x) || !t(r.y)) return null;
117
- let i = g.ifOverflow === "hidden" ? `url(#${E})` : void 0, a = {
118
- ...C,
119
- stroke: g.stroke,
120
- "stroke-width": g.strokeWidth,
121
- fill: g.fill
122
- }, o = {
123
- x: Math.min(n.x, r.x),
124
- y: Math.min(n.y, r.y),
125
- width: Math.abs(r.x - n.x),
126
- height: Math.abs(r.y - n.y)
127
- }, s = g.label, c = typeof s == "object" && s ? s : {};
128
- return h(l, { class: ["v-charts-reference-line", g.className] }, { default: () => [h("line", _(a, {
129
- "clip-path": i,
130
- x1: n.x,
131
- y1: n.y,
132
- x2: r.x,
133
- y2: r.y,
134
- class: "v-charts-reference-line-line"
135
- }), null), s != null && s !== !1 && h(u, _({
136
- viewBox: o,
137
- value: typeof s == "string" || typeof s == "number" ? s : void 0
138
- }, c), null)] });
118
+ const pts = endPoints.value;
119
+ if (!pts || pts.length < 2) return null;
120
+ const [p1, p2] = pts;
121
+ if (!isWellBehavedNumber(p1.x) || !isWellBehavedNumber(p1.y) || !isWellBehavedNumber(p2.x) || !isWellBehavedNumber(p2.y)) return null;
122
+ const clipPath = props.ifOverflow === "hidden" ? `url(#${clipPathId})` : void 0;
123
+ const svgAttrs = {
124
+ ...attrs,
125
+ "stroke": props.stroke,
126
+ "stroke-width": props.strokeWidth,
127
+ "fill": props.fill
128
+ };
129
+ const labelViewBox = {
130
+ x: Math.min(p1.x, p2.x),
131
+ y: Math.min(p1.y, p2.y),
132
+ width: Math.abs(p2.x - p1.x),
133
+ height: Math.abs(p2.y - p1.y)
134
+ };
135
+ const labelValue = props.label;
136
+ const labelProps = typeof labelValue === "object" && labelValue !== null ? labelValue : {};
137
+ return createVNode(Layer, { "class": ["v-charts-reference-line", props.class] }, { default: () => [createVNode("line", mergeProps(svgAttrs, {
138
+ "clip-path": clipPath,
139
+ "x1": p1.x,
140
+ "y1": p1.y,
141
+ "x2": p2.x,
142
+ "y2": p2.y,
143
+ "class": "v-charts-reference-line-line"
144
+ }), null), labelValue != null && labelValue !== false && createVNode(Label, mergeProps({
145
+ "viewBox": labelViewBox,
146
+ "value": typeof labelValue === "string" || typeof labelValue === "number" ? labelValue : void 0
147
+ }, labelProps), null)] });
139
148
  };
140
149
  }
141
150
  });
142
151
  //#endregion
143
- export { C as ReferenceLine };
152
+ export { ReferenceLine };