vccs 0.2.0 → 0.4.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 (99) 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/axis/XAxis.d.ts +3 -3
  5. package/dist/cartesian/bar/type.d.ts +1 -13
  6. package/dist/cartesian/brush/components/Slide.d.ts +1 -1
  7. package/dist/cartesian/brush/components/TravellerLayer.d.ts +1 -1
  8. package/dist/cartesian/brush/type.d.ts +2 -1
  9. package/dist/cartesian/cartesian-axis/CartesianAxis.d.ts +7 -6
  10. package/dist/cartesian/funnel/type.d.ts +4 -5
  11. package/dist/cartesian/index.d.ts +1 -0
  12. package/dist/cartesian/line/Line.d.ts +7 -13
  13. package/dist/cartesian/line/type.d.ts +4 -17
  14. package/dist/cartesian/reference-area/ReferenceArea.d.ts +16 -16
  15. package/dist/cartesian/reference-dot/ReferenceDot.d.ts +143 -0
  16. package/dist/cartesian/reference-dot/index.d.ts +2 -0
  17. package/dist/cartesian/reference-line/ReferenceLine.d.ts +8 -8
  18. package/dist/cartesian/scatter/Scatter.d.ts +1 -1
  19. package/dist/chart/RechartsWrapper.d.ts +7 -3
  20. package/dist/chart/Surface.d.ts +2 -1
  21. package/dist/chart/Treemap.d.ts +237 -0
  22. package/dist/chart/generateCategoricalChart.d.ts +2 -1
  23. package/dist/chart/index.d.ts +1 -0
  24. package/dist/chart/treemapUtils.d.ts +22 -0
  25. package/dist/components/Customized.d.ts +23 -0
  26. package/dist/components/Text.d.ts +20 -5
  27. package/dist/components/Tooltip.d.ts +47 -3
  28. package/dist/components/index.d.ts +2 -0
  29. package/dist/components/label/Label.d.ts +3 -3
  30. package/dist/components/label/types.d.ts +1 -1
  31. package/dist/container/Surface.d.ts +3 -2
  32. package/dist/es/cartesian/area/type.mjs +2 -4
  33. package/dist/es/cartesian/axis/XAxis.mjs +2 -2
  34. package/dist/es/cartesian/axis/YAxis.mjs +1 -1
  35. package/dist/es/cartesian/bar/Bar.mjs +2 -17
  36. package/dist/es/cartesian/bar/type.mjs +2 -16
  37. package/dist/es/cartesian/cartesian-axis/CartesianAxis.mjs +2 -3
  38. package/dist/es/cartesian/cartesian-grid/const.mjs +7 -1
  39. package/dist/es/cartesian/funnel/Funnel.mjs +3 -18
  40. package/dist/es/cartesian/funnel/type.mjs +3 -5
  41. package/dist/es/cartesian/line/type.mjs +2 -7
  42. package/dist/es/cartesian/reference-area/ReferenceArea.mjs +6 -22
  43. package/dist/es/cartesian/reference-dot/ReferenceDot.mjs +134 -0
  44. package/dist/es/cartesian/reference-line/ReferenceLine.mjs +6 -19
  45. package/dist/es/chart/RechartsWrapper.mjs +2 -1
  46. package/dist/es/chart/Treemap.mjs +379 -0
  47. package/dist/es/chart/generateCategoricalChart.mjs +3 -2
  48. package/dist/es/chart/treemapUtils.mjs +32 -0
  49. package/dist/es/components/Customized.mjs +43 -0
  50. package/dist/es/components/Text.vue_vue_type_script_setup_true_lang.mjs +3 -3
  51. package/dist/es/components/Tooltip.mjs +14 -7
  52. package/dist/es/components/label/types.mjs +2 -1
  53. package/dist/es/components/legend/Legend.mjs +1 -1
  54. package/dist/es/components/legend/hooks/useLegend.mjs +8 -3
  55. package/dist/es/container/Surface.mjs +2 -4
  56. package/dist/es/hooks/publicHooks.mjs +207 -0
  57. package/dist/es/index.mjs +9 -1
  58. package/dist/es/polar/pie/Pie.mjs +1 -1
  59. package/dist/es/polar/pie/type.mjs +2 -4
  60. package/dist/es/shape/Curve.mjs +2 -1
  61. package/dist/es/shape/Polygon.mjs +19 -0
  62. package/dist/es/shape/Rectangle.mjs +0 -4
  63. package/dist/es/shape/Sector.mjs +4 -6
  64. package/dist/es/shape/Symbols.mjs +1 -1
  65. package/dist/es/shape/Trapezoid.mjs +5 -7
  66. package/dist/es/state/ReportChartProps.mjs +2 -4
  67. package/dist/es/state/hooks.mjs +21 -1
  68. package/dist/es/state/referenceElementsSlice.mjs +1 -1
  69. package/dist/es/state/selectors/axisSelectors.mjs +30 -1
  70. package/dist/es/state/selectors/tooltipSelectors.mjs +2 -2
  71. package/dist/es/types/common.mjs +12 -0
  72. package/dist/es/utils/VueUtils.mjs +1 -1
  73. package/dist/es/utils/cell.mjs +28 -0
  74. package/dist/es/utils/createCategoricalInverse.mjs +46 -0
  75. package/dist/es/utils/scale.mjs +46 -0
  76. package/dist/hooks/publicHooks.d.ts +143 -0
  77. package/dist/index.d.ts +1 -0
  78. package/dist/polar/pie/type.d.ts +2 -2
  79. package/dist/polar/radar/Radar.d.ts +4 -4
  80. package/dist/shape/Curve.d.ts +2 -1
  81. package/dist/shape/Polygon.d.ts +9 -0
  82. package/dist/shape/Rectangle.d.ts +0 -4
  83. package/dist/shape/Sector.d.ts +2 -2
  84. package/dist/shape/Symbols.d.ts +2 -1
  85. package/dist/shape/Trapezoid.d.ts +9 -10
  86. package/dist/shape/index.d.ts +1 -0
  87. package/dist/shape/types.d.ts +4 -5
  88. package/dist/state/ReportChartProps.d.ts +3 -3
  89. package/dist/state/rootPropsSlice.d.ts +2 -2
  90. package/dist/state/selectors/axisSelectors.d.ts +5 -0
  91. package/dist/types/axis.d.ts +2 -2
  92. package/dist/types/bar.d.ts +2 -6
  93. package/dist/types/categorical.d.ts +2 -2
  94. package/dist/types/common.d.ts +7 -1
  95. package/dist/types/tooltip.d.ts +2 -2
  96. package/dist/utils/cell.d.ts +11 -0
  97. package/dist/utils/createCategoricalInverse.d.ts +16 -0
  98. package/dist/utils/scale.d.ts +23 -0
  99. package/package.json +2 -1
@@ -0,0 +1,207 @@
1
+ import { selectAxisDomain, selectAxisInverseDataSnapScale, selectAxisInverseScale, selectAxisInverseTickSnapScale, selectAxisScale, selectTicksOfAxis } from "../state/selectors/axisSelectors.mjs";
2
+ import { selectActiveLabel, selectActiveTooltipCoordinate, selectIsTooltipActive } from "../state/selectors/tooltipSelectors.mjs";
3
+ import { useAppSelector } from "../state/hooks.mjs";
4
+ import { useOffset } from "../context/chartLayoutContext.mjs";
5
+ import { computed } from "vue";
6
+ //#region src/hooks/publicHooks.ts
7
+ /**
8
+ * Returns whether the tooltip is currently active (visible).
9
+ *
10
+ * Must be used inside a chart component tree (where the Redux store is provided).
11
+ *
12
+ * @returns A reactive boolean indicating tooltip active state
13
+ */
14
+ function useIsTooltipActive() {
15
+ return useAppSelector(selectIsTooltipActive);
16
+ }
17
+ /**
18
+ * Returns the current coordinate of the active tooltip.
19
+ *
20
+ * Must be used inside a chart component tree (where the Redux store is provided).
21
+ *
22
+ * @returns A reactive Coordinate ({ x, y }) or undefined when no tooltip is active
23
+ */
24
+ function useActiveTooltipCoordinate() {
25
+ return useAppSelector(selectActiveTooltipCoordinate);
26
+ }
27
+ /**
28
+ * Returns the label of the currently active tooltip (the value from the axis dataKey at the hovered index).
29
+ *
30
+ * Must be used inside a chart component tree (where the Redux store is provided).
31
+ *
32
+ * @returns A reactive string label or undefined when no tooltip is active
33
+ */
34
+ function useActiveTooltipLabel() {
35
+ return useAppSelector(selectActiveLabel);
36
+ }
37
+ /**
38
+ * Returns the plot area rectangle { x, y, width, height }.
39
+ * This is the area inside all axes, legend, and brush — where graphical items render.
40
+ *
41
+ * Must be used inside a chart component tree (where the Redux store is provided).
42
+ *
43
+ * @returns A reactive object with x, y, width, height or undefined if offset is not yet available
44
+ */
45
+ function usePlotArea() {
46
+ const offset = useOffset();
47
+ return computed(() => {
48
+ const o = offset.value;
49
+ if (o == null) return void 0;
50
+ return {
51
+ x: o.left,
52
+ y: o.top,
53
+ width: o.width,
54
+ height: o.height
55
+ };
56
+ });
57
+ }
58
+ /**
59
+ * Returns the computed domain of an X axis.
60
+ *
61
+ * @param axisId - The axis ID (defaults to 0)
62
+ * @returns A reactive domain (categorical or numerical) or undefined
63
+ */
64
+ function useXAxisDomain(axisId = 0) {
65
+ return useAppSelector((state) => selectAxisDomain(state, "xAxis", axisId, false));
66
+ }
67
+ /**
68
+ * Returns the computed domain of a Y axis.
69
+ *
70
+ * @param axisId - The axis ID (defaults to 0)
71
+ * @returns A reactive domain (categorical or numerical) or undefined
72
+ */
73
+ function useYAxisDomain(axisId = 0) {
74
+ return useAppSelector((state) => selectAxisDomain(state, "yAxis", axisId, false));
75
+ }
76
+ /**
77
+ * Returns the computed tick items of an X axis.
78
+ *
79
+ * @param axisId - The axis ID (defaults to 0)
80
+ * @returns A reactive array of TickItem or undefined
81
+ */
82
+ function useXAxisTicks(axisId = 0) {
83
+ return useAppSelector((state) => selectTicksOfAxis(state, "xAxis", axisId, false));
84
+ }
85
+ /**
86
+ * Returns the computed tick items of a Y axis.
87
+ *
88
+ * @param axisId - The axis ID (defaults to 0)
89
+ * @returns A reactive array of TickItem or undefined
90
+ */
91
+ function useYAxisTicks(axisId = 0) {
92
+ return useAppSelector((state) => selectTicksOfAxis(state, "yAxis", axisId, false));
93
+ }
94
+ /**
95
+ * Returns the scale function for an X axis, mapping data values to pixel coordinates.
96
+ *
97
+ * @param axisId - The axis ID (defaults to 0)
98
+ * @returns A reactive ScaleFunction or undefined if the axis is not yet initialized
99
+ */
100
+ function useXAxisScale(axisId = 0) {
101
+ const scale = useAppSelector((state) => selectAxisScale(state, "xAxis", axisId, false));
102
+ return computed(() => {
103
+ const s = scale.value;
104
+ if (s == null) return void 0;
105
+ return (value) => {
106
+ const result = s(value);
107
+ return typeof result === "number" ? result : void 0;
108
+ };
109
+ });
110
+ }
111
+ /**
112
+ * Returns the scale function for a Y axis, mapping data values to pixel coordinates.
113
+ *
114
+ * @param axisId - The axis ID (defaults to 0)
115
+ * @returns A reactive ScaleFunction or undefined if the axis is not yet initialized
116
+ */
117
+ function useYAxisScale(axisId = 0) {
118
+ const scale = useAppSelector((state) => selectAxisScale(state, "yAxis", axisId, false));
119
+ return computed(() => {
120
+ const s = scale.value;
121
+ if (s == null) return void 0;
122
+ return (value) => {
123
+ const result = s(value);
124
+ return typeof result === "number" ? result : void 0;
125
+ };
126
+ });
127
+ }
128
+ /**
129
+ * Returns the inverse scale function for an X axis, mapping pixel coordinates back to data values.
130
+ *
131
+ * @param axisId - The axis ID (defaults to 0)
132
+ * @returns A reactive InverseScaleFunction or undefined
133
+ */
134
+ function useXAxisInverseScale(axisId = 0) {
135
+ return useAppSelector((state) => selectAxisInverseScale(state, "xAxis", axisId, false));
136
+ }
137
+ /**
138
+ * Returns the inverse scale function for a Y axis, mapping pixel coordinates back to data values.
139
+ *
140
+ * @param axisId - The axis ID (defaults to 0)
141
+ * @returns A reactive InverseScaleFunction or undefined
142
+ */
143
+ function useYAxisInverseScale(axisId = 0) {
144
+ return useAppSelector((state) => selectAxisInverseScale(state, "yAxis", axisId, false));
145
+ }
146
+ /**
147
+ * Returns the inverse scale function for an X axis that snaps to the nearest data point.
148
+ *
149
+ * @param axisId - The axis ID (defaults to 0)
150
+ * @returns A reactive InverseScaleFunction or undefined
151
+ */
152
+ function useXAxisInverseDataSnapScale(axisId = 0) {
153
+ return useAppSelector((state) => selectAxisInverseDataSnapScale(state, "xAxis", axisId, false));
154
+ }
155
+ /**
156
+ * Returns the inverse scale function for a Y axis that snaps to the nearest data point.
157
+ *
158
+ * @param axisId - The axis ID (defaults to 0)
159
+ * @returns A reactive InverseScaleFunction or undefined
160
+ */
161
+ function useYAxisInverseDataSnapScale(axisId = 0) {
162
+ return useAppSelector((state) => selectAxisInverseDataSnapScale(state, "yAxis", axisId, false));
163
+ }
164
+ /**
165
+ * Returns the inverse scale function for an X axis that snaps to the nearest tick.
166
+ *
167
+ * @param axisId - The axis ID (defaults to 0)
168
+ * @returns A reactive InverseScaleFunction or undefined
169
+ */
170
+ function useXAxisInverseTickSnapScale(axisId = 0) {
171
+ return useAppSelector((state) => selectAxisInverseTickSnapScale(state, "xAxis", axisId, false));
172
+ }
173
+ /**
174
+ * Returns the inverse scale function for a Y axis that snaps to the nearest tick.
175
+ *
176
+ * @param axisId - The axis ID (defaults to 0)
177
+ * @returns A reactive InverseScaleFunction or undefined
178
+ */
179
+ function useYAxisInverseTickSnapScale(axisId = 0) {
180
+ return useAppSelector((state) => selectAxisInverseTickSnapScale(state, "yAxis", axisId, false));
181
+ }
182
+ /**
183
+ * Convenience hook that maps a data point to pixel coordinates using both X and Y axis scales.
184
+ *
185
+ * @param dataPoint - An object with x and y data values
186
+ * @param xAxisId - The X axis ID (defaults to 0)
187
+ * @param yAxisId - The Y axis ID (defaults to 0)
188
+ * @returns A reactive Coordinate ({ x, y }) or undefined if either scale is unavailable
189
+ */
190
+ function useCartesianScale(dataPoint, xAxisId = 0, yAxisId = 0) {
191
+ const xScale = useXAxisScale(xAxisId);
192
+ const yScale = useYAxisScale(yAxisId);
193
+ return computed(() => {
194
+ const xFn = xScale.value;
195
+ const yFn = yScale.value;
196
+ if (xFn == null || yFn == null) return void 0;
197
+ const pixelX = xFn(dataPoint.x);
198
+ const pixelY = yFn(dataPoint.y);
199
+ if (pixelX == null || pixelY == null) return void 0;
200
+ return {
201
+ x: pixelX,
202
+ y: pixelY
203
+ };
204
+ });
205
+ }
206
+ //#endregion
207
+ export { useActiveTooltipCoordinate, useActiveTooltipLabel, useCartesianScale, useIsTooltipActive, usePlotArea, useXAxisDomain, useXAxisInverseDataSnapScale, useXAxisInverseScale, useXAxisInverseTickSnapScale, useXAxisScale, useXAxisTicks, useYAxisDomain, useYAxisInverseDataSnapScale, useYAxisInverseScale, useYAxisInverseTickSnapScale, useYAxisScale, useYAxisTicks };
package/dist/es/index.mjs CHANGED
@@ -1,5 +1,8 @@
1
1
  import { Curve, CurveVueProps, getPath } from "./shape/Curve.mjs";
2
+ import { useActiveTooltipDataPoints } from "./state/hooks.mjs";
3
+ import { useChartHeight, useChartWidth, useMargin, useOffset } from "./context/chartLayoutContext.mjs";
2
4
  import { Dot } from "./shape/Dot.mjs";
5
+ import Text_default from "./components/Text.mjs";
3
6
  import { Label } from "./components/label/Label.mjs";
4
7
  import { LabelList } from "./components/label/LabelList.mjs";
5
8
  import { Area } from "./cartesian/area/Area.mjs";
@@ -15,6 +18,7 @@ import { ErrorBar, ErrorBarVueProps } from "./cartesian/error-bar/ErrorBar.mjs";
15
18
  import { LineContextKey, provideLineContext, useLine, useLineContext } from "./cartesian/line/hooks/useLine.mjs";
16
19
  import { Line } from "./cartesian/line/Line.mjs";
17
20
  import { ReferenceArea } from "./cartesian/reference-area/ReferenceArea.mjs";
21
+ import { ReferenceDot } from "./cartesian/reference-dot/ReferenceDot.mjs";
18
22
  import { ReferenceLine } from "./cartesian/reference-line/ReferenceLine.mjs";
19
23
  import { Symbols } from "./shape/Symbols.mjs";
20
24
  import { Scatter } from "./cartesian/scatter/Scatter.mjs";
@@ -31,7 +35,9 @@ import { RadarChart } from "./chart/RadarChart.mjs";
31
35
  import { ScatterChart } from "./chart/ScatterChart.mjs";
32
36
  import { RadialBarChart } from "./chart/RadialBarChart.mjs";
33
37
  import { FunnelChart } from "./chart/FunnelChart.mjs";
38
+ import { Treemap, TreemapVueProps, treemapPayloadSearcher } from "./chart/Treemap.mjs";
34
39
  import ResponsiveContainer_default from "./container/ResponsiveContainer.mjs";
40
+ import { Customized } from "./components/Customized.mjs";
35
41
  import Legend_default from "./components/legend/Legend.mjs";
36
42
  import { Cross } from "./shape/Cross.mjs";
37
43
  import { Sector } from "./shape/Sector.mjs";
@@ -43,4 +49,6 @@ import { PolarGrid } from "./polar/radar/PolarGrid.mjs";
43
49
  import { PolarAngleAxis } from "./polar/radar/PolarAngleAxis.mjs";
44
50
  import { PolarRadiusAxis } from "./polar/radar/PolarRadiusAxis.mjs";
45
51
  import { RadialBar } from "./polar/radial-bar/RadialBar.mjs";
46
- export { Area, AreaChart, Bar, BarChart, CartesianAxis, CartesianGrid, Cell, ComposedChart, Cross, Curve, CurveVueProps, Dot, ErrorBar, ErrorBarVueProps, Funnel, FunnelChart, FunnelVueProps, Label, LabelList, Legend_default as Legend, Line, LineChart, LineContextKey, Pie, PieChart, PieVueProps, PolarAngleAxis, PolarGrid, PolarRadiusAxis, Radar, RadarChart, RadialBar, RadialBarChart, Rectangle, ReferenceArea, ReferenceLine, ResponsiveContainer_default as ResponsiveContainer, Scatter, ScatterChart, Sector, Symbols, Tooltip, Trapezoid, XAxis, YAxis, ZAxis, createErrorBarRegistry, getPath, getUniqPayload, provideErrorBarContext, provideErrorBarRegistry, provideLineContext, useErrorBarContext, useErrorBarRegistry, useLine, useLineContext };
52
+ import { Polygon } from "./shape/Polygon.mjs";
53
+ import { useActiveTooltipCoordinate, useActiveTooltipLabel, useCartesianScale, useIsTooltipActive, usePlotArea, useXAxisDomain, useXAxisInverseDataSnapScale, useXAxisInverseScale, useXAxisInverseTickSnapScale, useXAxisScale, useXAxisTicks, useYAxisDomain, useYAxisInverseDataSnapScale, useYAxisInverseScale, useYAxisInverseTickSnapScale, useYAxisScale, useYAxisTicks } from "./hooks/publicHooks.mjs";
54
+ export { Area, AreaChart, Bar, BarChart, CartesianAxis, CartesianGrid, Cell, ComposedChart, Cross, Curve, CurveVueProps, Customized, Dot, ErrorBar, ErrorBarVueProps, Funnel, FunnelChart, FunnelVueProps, Label, LabelList, Legend_default as Legend, Line, LineChart, LineContextKey, Pie, PieChart, PieVueProps, PolarAngleAxis, PolarGrid, PolarRadiusAxis, Polygon, Radar, RadarChart, RadialBar, RadialBarChart, Rectangle, ReferenceArea, ReferenceDot, ReferenceLine, ResponsiveContainer_default as ResponsiveContainer, Scatter, ScatterChart, Sector, Symbols, Text_default as Text, Tooltip, Trapezoid, Treemap, TreemapVueProps, XAxis, YAxis, ZAxis, createErrorBarRegistry, getPath, getUniqPayload, provideErrorBarContext, provideErrorBarRegistry, provideLineContext, treemapPayloadSearcher, useActiveTooltipCoordinate, useActiveTooltipDataPoints, useActiveTooltipLabel, useCartesianScale, useChartHeight, useChartWidth, useErrorBarContext, useErrorBarRegistry, useIsTooltipActive, useLine, useLineContext, useMargin, useOffset, usePlotArea, useXAxisDomain, useXAxisInverseDataSnapScale, useXAxisInverseScale, useXAxisInverseTickSnapScale, useXAxisScale, useXAxisTicks, useYAxisDomain, useYAxisInverseDataSnapScale, useYAxisInverseScale, useYAxisInverseTickSnapScale, useYAxisScale, useYAxisTicks };
@@ -116,7 +116,7 @@ var Pie = /* @__PURE__ */ defineComponent({
116
116
  const sectorList = sectors.value;
117
117
  if (!sectorList || sectorList.length === 0) return null;
118
118
  const stroke = attrs.stroke ?? props.stroke;
119
- return createVNode(Layer, { "class": ["v-charts-pie", props.className] }, { default: () => [createVNode(Animate, {
119
+ return createVNode(Layer, { "class": ["v-charts-pie", props.class] }, { default: () => [createVNode(Animate, {
120
120
  "isActive": props.isAnimationActive,
121
121
  "from": 0,
122
122
  "to": 1,
@@ -1,3 +1,4 @@
1
+ import { classProp } from "../../types/common.mjs";
1
2
  //#region src/polar/pie/type.ts
2
3
  var PieVueProps = {
3
4
  data: {
@@ -88,10 +89,7 @@ var PieVueProps = {
88
89
  type: Boolean,
89
90
  default: false
90
91
  },
91
- className: {
92
- type: String,
93
- default: void 0
94
- }
92
+ class: classProp
95
93
  };
96
94
  //#endregion
97
95
  export { PieVueProps };
@@ -1,3 +1,4 @@
1
+ import { classProp } from "../types/common.mjs";
1
2
  import { isNumber } from "../utils/validate.mjs";
2
3
  import { computed, createVNode, defineComponent, mergeProps } from "vue";
3
4
  import { area, curveBasis, curveBasisClosed, curveBasisOpen, curveBumpX, curveBumpY, curveLinear, curveLinearClosed, curveMonotoneX, curveMonotoneY, curveNatural, curveStep, curveStepAfter, curveStepBefore, line } from "victory-vendor/d3-shape";
@@ -62,7 +63,7 @@ var CurveVueProps = {
62
63
  points: { type: Array },
63
64
  connectNulls: { type: Boolean },
64
65
  path: { type: String },
65
- class: { type: [String, Array] }
66
+ class: classProp
66
67
  };
67
68
  var Curve = /* @__PURE__ */ defineComponent({
68
69
  name: "Curve",
@@ -0,0 +1,19 @@
1
+ import { isNumber } from "../utils/validate.mjs";
2
+ import { createVNode, mergeProps } from "vue";
3
+ //#region src/shape/Polygon.tsx
4
+ function getPolygonPath(points) {
5
+ return points.reduce((path, point, i) => {
6
+ return `${path}${i === 0 ? "M" : "L"}${point.x},${point.y}`;
7
+ }, "") + "Z";
8
+ }
9
+ function Polygon(props) {
10
+ const { points = [], ...rest } = props;
11
+ if (!points || !points.length) return null;
12
+ if (!points.every((p) => isNumber(p.x) && isNumber(p.y))) return null;
13
+ return createVNode("path", mergeProps(rest, {
14
+ "class": "v-charts-polygon",
15
+ "d": getPolygonPath(points)
16
+ }), null);
17
+ }
18
+ //#endregion
19
+ export { Polygon };
@@ -4,10 +4,6 @@ import { createVNode, defineComponent, mergeProps } from "vue";
4
4
  * @fileOverview Rectangle
5
5
  */
6
6
  var RectangleVueProps = {
7
- className: {
8
- type: String,
9
- default: void 0
10
- },
11
7
  x: {
12
8
  type: Number,
13
9
  default: 0
@@ -1,3 +1,4 @@
1
+ import { classProp } from "../types/common.mjs";
1
2
  import { RADIAN, polarToCartesian } from "../utils/polar.mjs";
2
3
  import { getPercentValue, mathSign } from "../utils/data.mjs";
3
4
  import { createVNode, defineComponent, mergeProps } from "vue";
@@ -42,10 +43,7 @@ var SectorVueProps = {
42
43
  type: Boolean,
43
44
  default: false
44
45
  },
45
- className: {
46
- type: String,
47
- default: void 0
48
- }
46
+ class: classProp
49
47
  };
50
48
  function getDeltaAngle(startAngle, endAngle) {
51
49
  return mathSign(endAngle - startAngle) * Math.min(Math.abs(endAngle - startAngle), 359.999);
@@ -138,7 +136,7 @@ var Sector = /* @__PURE__ */ defineComponent({
138
136
  props: SectorVueProps,
139
137
  setup(props, { attrs }) {
140
138
  return () => {
141
- const { cx, cy, innerRadius, outerRadius, startAngle, endAngle, cornerRadius, forceCornerRadius, cornerIsExternal, className } = props;
139
+ const { cx, cy, innerRadius, outerRadius, startAngle, endAngle, cornerRadius, forceCornerRadius, cornerIsExternal } = props;
142
140
  if (outerRadius <= 0 || outerRadius < innerRadius || startAngle === endAngle) return null;
143
141
  const deltaRadius = outerRadius - innerRadius;
144
142
  const cr = getPercentValue(cornerRadius, deltaRadius, 0, true);
@@ -146,7 +144,7 @@ var Sector = /* @__PURE__ */ defineComponent({
146
144
  if (cr > 0 && Math.abs(startAngle - endAngle) < 360) path = getSectorWithCorner(cx, cy, innerRadius, outerRadius, Math.min(cr, deltaRadius / 2), forceCornerRadius, cornerIsExternal, startAngle, endAngle);
147
145
  else path = getSectorPath(cx, cy, innerRadius, outerRadius, startAngle, endAngle);
148
146
  return createVNode("path", mergeProps(attrs, {
149
- "class": ["v-charts-sector", className],
147
+ "class": ["v-charts-sector", props.class],
150
148
  "d": path
151
149
  }), null);
152
150
  };
@@ -32,7 +32,7 @@ var calculateAreaSize = (size, sizeType, type) => {
32
32
  }
33
33
  };
34
34
  function Symbols(props) {
35
- const { type = "circle", size = 64, sizeType = "area", cx, cy, className, ...rest } = props;
35
+ const { type = "circle", size = 64, sizeType = "area", cx, cy, class: className, ...rest } = props;
36
36
  let realType = "circle";
37
37
  if (typeof type === "string") realType = type;
38
38
  const getPath = () => {
@@ -1,10 +1,7 @@
1
+ import { classProp } from "../types/common.mjs";
1
2
  import { createVNode, defineComponent, mergeProps } from "vue";
2
3
  //#region src/shape/Trapezoid.tsx
3
4
  var TrapezoidVueProps = {
4
- className: {
5
- type: String,
6
- default: void 0
7
- },
8
5
  x: {
9
6
  type: Number,
10
7
  default: 0
@@ -24,7 +21,8 @@ var TrapezoidVueProps = {
24
21
  height: {
25
22
  type: Number,
26
23
  default: 0
27
- }
24
+ },
25
+ class: classProp
28
26
  };
29
27
  function getTrapezoidPath(x, y, upperWidth, lowerWidth, height) {
30
28
  const upperLeft = x;
@@ -39,10 +37,10 @@ var Trapezoid = /* @__PURE__ */ defineComponent({
39
37
  props: TrapezoidVueProps,
40
38
  setup(props, { attrs }) {
41
39
  return () => {
42
- const { x, y, upperWidth, lowerWidth, height, className } = props;
40
+ const { x, y, upperWidth, lowerWidth, height } = props;
43
41
  if (x !== +x || y !== +y || upperWidth !== +upperWidth || lowerWidth !== +lowerWidth || height !== +height || height === 0) return null;
44
42
  return createVNode("path", mergeProps(attrs, {
45
- "class": ["v-charts-trapezoid", className],
43
+ "class": ["v-charts-trapezoid", props.class],
46
44
  "d": getTrapezoidPath(x, y, upperWidth, lowerWidth, height)
47
45
  }), null);
48
46
  };
@@ -1,3 +1,4 @@
1
+ import { classProp } from "../types/common.mjs";
1
2
  import { useAppDispatch } from "./hooks.mjs";
2
3
  import { updateOptions } from "./rootPropsSlice.mjs";
3
4
  import { defineComponent, watchEffect } from "vue";
@@ -21,10 +22,7 @@ var ReportChartProps_default = /* @__PURE__ */ defineComponent({
21
22
  type: [String, Number],
22
23
  default: void 0
23
24
  },
24
- class: {
25
- type: String,
26
- default: void 0
27
- },
25
+ class: classProp,
28
26
  maxBarSize: {
29
27
  type: Number,
30
28
  default: void 0
@@ -1,6 +1,26 @@
1
+ import { selectActiveTooltipDataPoints } from "./selectors/tooltipSelectors.mjs";
1
2
  import { useDispatch, useSelector } from "@reduxjs/vue-redux";
2
3
  //#region src/state/hooks.ts
3
4
  var useAppDispatch = useDispatch.withTypes();
4
5
  var useAppSelector = useSelector.withTypes();
6
+ /**
7
+ * Returns the currently active data points being displayed in the Tooltip.
8
+ * Active means that it is currently visible; this hook will return `undefined` if there is no current interaction.
9
+ *
10
+ * This follows the `<Tooltip />` props, if the Tooltip element is present in the chart.
11
+ * If there is no `<Tooltip />` then this hook will follow the default Tooltip props.
12
+ *
13
+ * Data point is whatever you pass as an input to the chart using the `data={}` prop.
14
+ *
15
+ * This returns an array because a chart can have multiple graphical items in it (multiple Lines for example)
16
+ * and tooltip with `shared={true}` will display all items at the same time.
17
+ *
18
+ * Returns undefined when used outside a chart context.
19
+ *
20
+ * @returns Data points that are currently visible in a Tooltip
21
+ */
22
+ function useActiveTooltipDataPoints() {
23
+ return useAppSelector(selectActiveTooltipDataPoints);
24
+ }
5
25
  //#endregion
6
- export { useAppDispatch, useAppSelector };
26
+ export { useActiveTooltipDataPoints, useAppDispatch, useAppSelector };
@@ -33,4 +33,4 @@ var referenceElementsSlice = createSlice({
33
33
  var { addDot, removeDot, addArea, removeArea, addLine, removeLine } = referenceElementsSlice.actions;
34
34
  var referenceElementsReducer = referenceElementsSlice.reducer;
35
35
  //#endregion
36
- export { addArea, addLine, referenceElementsReducer, removeArea, removeLine };
36
+ export { addArea, addDot, addLine, referenceElementsReducer, removeArea, removeDot, removeLine };
@@ -13,6 +13,7 @@ import { pickAxisType } from "./pickAxisType.mjs";
13
13
  import { pickAxisId } from "./pickAxisId.mjs";
14
14
  import { checkDomainOfScale, getDomainOfStackGroups, getStackedData, getValueByDataKey } from "../../utils/chart.mjs";
15
15
  import { isWellFormedNumberDomain, numericalDomainSpecifiedWithoutRequiringData, parseNumericalUserDomain } from "../../utils/isDomainSpecifiedByUser.mjs";
16
+ import { combineInverseScaleFunction, createCategoricalInverse } from "../../utils/createCategoricalInverse.mjs";
16
17
  import { getNiceTickValues, getTickValuesFixedDomain } from "../../utils/scale/getNiceTickValues.mjs";
17
18
  import { createSelector } from "@reduxjs/toolkit";
18
19
  import { range, upperFirst } from "lodash-es";
@@ -601,6 +602,19 @@ var selectAxisScale = createSelector([
601
602
  selectAxisDomainIncludingNiceTicks,
602
603
  selectAxisRangeWithReverse
603
604
  ], combineScaleFunction);
605
+ function sortBy$1(a, b) {
606
+ const aNum = Number(a);
607
+ const bNum = Number(b);
608
+ if (Number.isNaN(aNum) && Number.isNaN(bNum)) return 0;
609
+ if (Number.isNaN(aNum)) return -1;
610
+ if (Number.isNaN(bNum)) return 1;
611
+ return aNum - bNum;
612
+ }
613
+ var selectSortedDataPoints = createSelector([selectAllAppliedValues], (appliedData) => {
614
+ return appliedData?.map((item) => item.value).sort(sortBy$1);
615
+ });
616
+ var selectAxisInverseScale = createSelector([selectAxisScale], combineInverseScaleFunction);
617
+ var selectAxisInverseDataSnapScale = createSelector([selectAxisScale, selectSortedDataPoints], createCategoricalInverse);
604
618
  createSelector(selectCartesianItemsSettings, pickAxisType, (items, axisType) => {
605
619
  return items.flatMap((item) => {
606
620
  return item.errorBars ?? [];
@@ -812,6 +826,21 @@ var selectTicksOfAxis = createSelector([
812
826
  selectCategoricalDomain,
813
827
  pickAxisType
814
828
  ], combineAxisTicks);
829
+ var selectAxisInverseTickSnapScale = createSelector([selectTicksOfAxis], (ticks) => {
830
+ if (!ticks || ticks.length === 0) return;
831
+ return (pixelValue) => {
832
+ let minDistance = Infinity;
833
+ let closestTick = ticks[0];
834
+ for (const tick of ticks) {
835
+ const distance = Math.abs(tick.coordinate - pixelValue);
836
+ if (distance < minDistance) {
837
+ minDistance = distance;
838
+ closestTick = tick;
839
+ }
840
+ }
841
+ return closestTick?.value;
842
+ };
843
+ });
815
844
  function combineGraphicalItemTicks(layout, axis, scale, axisRange, duplicateDomain, categoricalDomain, axisType) {
816
845
  if (axis == null || scale == null || axisRange == null || axisRange[0] === axisRange[1]) return null;
817
846
  const isCategorical = isCategoricalAxis(layout, axisType);
@@ -876,4 +905,4 @@ var selectChartDirection = createSelector([
876
905
  }
877
906
  });
878
907
  //#endregion
879
- export { combineAppliedNumericalValuesIncludingErrorValues, combineAppliedValues, combineAreasDomain, combineAxisDomain, combineAxisDomainWithNiceTicks, combineAxisTicks, combineCategoricalDomain, combineDisplayedData, combineDomainOfStackGroups, combineDotsDomain, combineDuplicateDomain, combineGraphicalItemTicks, combineGraphicalItemsData, combineGraphicalItemsSettings, combineLinesDomain, combineNiceTicks, combineNumericalDomain, combineRealScaleType, combineScaleFunction, combineStackGroups, filterGraphicalNotStackedItems, filterReferenceElements, getDomainDefinition, implicitXAxis, implicitYAxis, implicitZAxis, itemAxisPredicate, mergeDomains, selectAxisPropsNeededForCartesianGridTicksGenerator, selectAxisRange, selectAxisScale, selectAxisSettings, selectAxisWithScale, selectBaseAxis, selectCartesianAxisSize, selectChartDirection, selectDomainDefinition, selectDuplicateDomain, selectHasBar, selectRealScaleType, selectReferenceAreas, selectReferenceDots, selectReferenceLines, selectStackGroups, selectTicksOfAxis, selectTicksOfGraphicalItem, selectUnfilteredCartesianItems, selectXAxisPosition, selectXAxisSettings, selectXAxisSize, selectYAxisPosition, selectYAxisSettings, selectYAxisSize, selectZAxisWithScale };
908
+ export { combineAppliedNumericalValuesIncludingErrorValues, combineAppliedValues, combineAreasDomain, combineAxisDomain, combineAxisDomainWithNiceTicks, combineAxisTicks, combineCategoricalDomain, combineDisplayedData, combineDomainOfStackGroups, combineDotsDomain, combineDuplicateDomain, combineGraphicalItemTicks, combineGraphicalItemsData, combineGraphicalItemsSettings, combineLinesDomain, combineNiceTicks, combineNumericalDomain, combineRealScaleType, combineScaleFunction, combineStackGroups, filterGraphicalNotStackedItems, filterReferenceElements, getDomainDefinition, implicitXAxis, implicitYAxis, implicitZAxis, itemAxisPredicate, mergeDomains, selectAxisDomain, selectAxisInverseDataSnapScale, selectAxisInverseScale, selectAxisInverseTickSnapScale, selectAxisPropsNeededForCartesianGridTicksGenerator, selectAxisRange, selectAxisScale, selectAxisSettings, selectAxisWithScale, selectBaseAxis, selectCartesianAxisSize, selectChartDirection, selectDomainDefinition, selectDuplicateDomain, selectHasBar, selectRealScaleType, selectReferenceAreas, selectReferenceDots, selectReferenceLines, selectStackGroups, selectTicksOfAxis, selectTicksOfGraphicalItem, selectUnfilteredCartesianItems, selectXAxisPosition, selectXAxisSettings, selectXAxisSize, selectYAxisPosition, selectYAxisSettings, selectYAxisSize, selectZAxisWithScale };
@@ -252,7 +252,7 @@ var selectActiveTooltipCoordinate = createSelector([selectTooltipInteractionStat
252
252
  return tooltipInteractionState.coordinate ?? defaultIndexCoordinate;
253
253
  });
254
254
  var selectIsTooltipActive = createSelector([selectTooltipInteractionState], (tooltipInteractionState) => tooltipInteractionState.active);
255
- createSelector([createSelector([
255
+ var selectActiveTooltipDataPoints = createSelector([createSelector([
256
256
  selectTooltipPayloadConfigurations,
257
257
  selectActiveTooltipIndex,
258
258
  selectChartDataWithIndexes,
@@ -266,4 +266,4 @@ createSelector([createSelector([
266
266
  return Array.from(new Set(dataPoints));
267
267
  });
268
268
  //#endregion
269
- export { combineTooltipPayload, selectActiveLabel, selectActiveTooltipCoordinate, selectActiveTooltipDataKey, selectActiveTooltipIndex, selectIsTooltipActive, selectTooltipAxis, selectTooltipAxisDomain, selectTooltipAxisRangeWithReverse, selectTooltipAxisScale, selectTooltipAxisTicks, selectTooltipAxisType, selectTooltipDisplayedData };
269
+ export { combineTooltipPayload, selectActiveLabel, selectActiveTooltipCoordinate, selectActiveTooltipDataKey, selectActiveTooltipDataPoints, selectActiveTooltipIndex, selectIsTooltipActive, selectTooltipAxis, selectTooltipAxisDomain, selectTooltipAxisRangeWithReverse, selectTooltipAxisScale, selectTooltipAxisTicks, selectTooltipAxisType, selectTooltipDisplayedData };
@@ -0,0 +1,12 @@
1
+ //#region src/types/common.ts
2
+ /** Shared Vue prop definition for `class` — use in VueProps objects to avoid repetition */
3
+ var classProp = {
4
+ type: [
5
+ String,
6
+ Array,
7
+ Object
8
+ ],
9
+ default: void 0
10
+ };
11
+ //#endregion
12
+ export { classProp };
@@ -1,5 +1,5 @@
1
- import { FilteredElementKeyMap, SVGElementPropKeys } from "../cartesian/cartesian-grid/const.mjs";
2
1
  import { EventKeys } from "../types/event.mjs";
2
+ import { FilteredElementKeyMap, SVGElementPropKeys } from "../cartesian/cartesian-grid/const.mjs";
3
3
  //#region src/utils/VueUtils.ts
4
4
  /**
5
5
  * Checks if the property is valid to spread onto an SVG element or onto a specific component
@@ -0,0 +1,28 @@
1
+ import { Cell } from "../components/Cell.mjs";
2
+ import { Fragment } from "vue";
3
+ //#region src/utils/cell.ts
4
+ /**
5
+ * Extract Cell VNode props from a VNode tree.
6
+ * Handles Fragment wrapping from v-for.
7
+ */
8
+ function extractCellProps(vnodes) {
9
+ const result = [];
10
+ for (const vnode of vnodes) if (vnode.type === Cell) result.push(vnode.props ?? {});
11
+ else if (vnode.type === Fragment && Array.isArray(vnode.children)) result.push(...extractCellProps(vnode.children));
12
+ return result;
13
+ }
14
+ /**
15
+ * Filter out Cell VNodes from a VNode tree, preserving non-Cell siblings.
16
+ * Recursively descends Fragment children to preserve co-located content (e.g. LabelList).
17
+ */
18
+ function filterOutCells(vnodes) {
19
+ const result = [];
20
+ for (const vnode of vnodes) {
21
+ if (vnode.type === Cell) continue;
22
+ if (vnode.type === Fragment && Array.isArray(vnode.children)) result.push(...filterOutCells(vnode.children));
23
+ else result.push(vnode);
24
+ }
25
+ return result;
26
+ }
27
+ //#endregion
28
+ export { extractCellProps, filterOutCells };
@@ -0,0 +1,46 @@
1
+ //#region src/utils/createCategoricalInverse.ts
2
+ /**
3
+ * Binary search for sorted arrays (ascending or descending).
4
+ */
5
+ function bisect(haystack, needle) {
6
+ let lo = 0;
7
+ let hi = haystack.length;
8
+ const ascending = haystack[0] < haystack[haystack.length - 1];
9
+ while (lo < hi) {
10
+ const mid = Math.floor((lo + hi) / 2);
11
+ if (ascending ? haystack[mid] < needle : haystack[mid] > needle) lo = mid + 1;
12
+ else hi = mid;
13
+ }
14
+ return lo;
15
+ }
16
+ /**
17
+ * Creates an inverse scale function for categorical/ordinal scales.
18
+ * Uses bisect to find the closest domain value for a given pixel coordinate.
19
+ */
20
+ function createCategoricalInverse(scale, allDataPointsOnAxis) {
21
+ if (!scale) return;
22
+ const domain = allDataPointsOnAxis ?? scale.domain();
23
+ const pixelPositions = domain.map((d) => scale(d) ?? 0);
24
+ const range = scale.range();
25
+ if (domain.length === 0 || range.length < 2) return;
26
+ return (pixelValue) => {
27
+ const index = bisect(pixelPositions, pixelValue);
28
+ if (index <= 0) return domain[0];
29
+ if (index >= domain.length) return domain[domain.length - 1];
30
+ const leftPixel = pixelPositions[index - 1] ?? 0;
31
+ const rightPixel = pixelPositions[index] ?? 0;
32
+ if (Math.abs(pixelValue - leftPixel) <= Math.abs(pixelValue - rightPixel)) return domain[index - 1];
33
+ return domain[index];
34
+ };
35
+ }
36
+ /**
37
+ * Creates an inverse function: uses native `.invert` for numeric scales,
38
+ * falls back to categorical bisect for ordinal/band/point scales.
39
+ */
40
+ function combineInverseScaleFunction(scale) {
41
+ if (scale == null) return;
42
+ if ("invert" in scale && typeof scale.invert === "function") return scale.invert.bind(scale);
43
+ return createCategoricalInverse(scale, void 0);
44
+ }
45
+ //#endregion
46
+ export { combineInverseScaleFunction, createCategoricalInverse };