vccs 0.1.0 → 0.2.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 (215) hide show
  1. package/dist/cartesian/funnel/Funnel.d.ts +2 -0
  2. package/dist/cartesian/funnel/index.d.ts +2 -0
  3. package/dist/cartesian/funnel/type.d.ts +74 -5
  4. package/dist/cartesian/index.d.ts +1 -0
  5. package/dist/chart/FunnelChart.d.ts +1 -0
  6. package/dist/chart/index.d.ts +1 -0
  7. package/dist/es/animation/Animate.mjs +48 -22
  8. package/dist/es/cartesian/GraphicalItemClipPath.mjs +16 -15
  9. package/dist/es/cartesian/area/ActivePoints.mjs +44 -40
  10. package/dist/es/cartesian/area/Area.mjs +42 -31
  11. package/dist/es/cartesian/area/ClipRect.mjs +79 -58
  12. package/dist/es/cartesian/area/RenderArea.mjs +142 -108
  13. package/dist/es/cartesian/area/hooks/useArea.mjs +71 -47
  14. package/dist/es/cartesian/area/type.mjs +11 -11
  15. package/dist/es/cartesian/area/utils.mjs +69 -49
  16. package/dist/es/cartesian/axis/XAxis.mjs +87 -73
  17. package/dist/es/cartesian/axis/YAxis.mjs +67 -56
  18. package/dist/es/cartesian/bar/Bar.mjs +93 -71
  19. package/dist/es/cartesian/bar/components/BarBackground.mjs +22 -19
  20. package/dist/es/cartesian/bar/components/BarRectangles.mjs +117 -80
  21. package/dist/es/cartesian/bar/hooks/useBar.mjs +49 -37
  22. package/dist/es/cartesian/bar/type.mjs +9 -9
  23. package/dist/es/cartesian/bar/utils.mjs +97 -70
  24. package/dist/es/cartesian/cartesian-axis/CartesianAxis.mjs +165 -115
  25. package/dist/es/cartesian/cartesian-grid/Background.mjs +19 -16
  26. package/dist/es/cartesian/cartesian-grid/CartesianGrid.mjs +116 -97
  27. package/dist/es/cartesian/cartesian-grid/HorizontalGridLines.mjs +24 -23
  28. package/dist/es/cartesian/cartesian-grid/HorizontalStripes.mjs +24 -24
  29. package/dist/es/cartesian/cartesian-grid/VerticalGridLines.mjs +23 -22
  30. package/dist/es/cartesian/cartesian-grid/VerticalStripes.mjs +24 -24
  31. package/dist/es/cartesian/cartesian-grid/const.mjs +317 -10
  32. package/dist/es/cartesian/cartesian-grid/utils.mjs +18 -13
  33. package/dist/es/cartesian/error-bar/ErrorBar.mjs +111 -83
  34. package/dist/es/cartesian/error-bar/ErrorBarContext.mjs +13 -12
  35. package/dist/es/cartesian/funnel/Funnel.mjs +177 -0
  36. package/dist/es/cartesian/funnel/type.mjs +80 -0
  37. package/dist/es/cartesian/funnel/utils.mjs +102 -0
  38. package/dist/es/cartesian/line/ActivePoints.mjs +45 -41
  39. package/dist/es/cartesian/line/Line.mjs +41 -37
  40. package/dist/es/cartesian/line/StaticLine.mjs +191 -122
  41. package/dist/es/cartesian/line/hooks/useLine.mjs +60 -44
  42. package/dist/es/cartesian/line/type.mjs +11 -11
  43. package/dist/es/cartesian/line/utils.mjs +27 -26
  44. package/dist/es/cartesian/reference-area/ReferenceArea.mjs +86 -69
  45. package/dist/es/cartesian/reference-line/ReferenceLine.mjs +99 -77
  46. package/dist/es/cartesian/scatter/Scatter.mjs +168 -140
  47. package/dist/es/cartesian/scatter/hooks/useScatter.mjs +18 -14
  48. package/dist/es/cartesian/useNeedsClip.mjs +18 -9
  49. package/dist/es/cartesian/utils/get-ticks.mjs +103 -68
  50. package/dist/es/cartesian/z-axis/ZAxis.mjs +30 -28
  51. package/dist/es/chart/AreaChart.mjs +5 -5
  52. package/dist/es/chart/BarChart.mjs +5 -5
  53. package/dist/es/chart/ComposedChart.mjs +5 -5
  54. package/dist/es/chart/FunnelChart.mjs +11 -0
  55. package/dist/es/chart/LegendPortalContext.mjs +3 -3
  56. package/dist/es/chart/LineChart.mjs +5 -5
  57. package/dist/es/chart/PieChart.mjs +5 -5
  58. package/dist/es/chart/RadarChart.mjs +5 -5
  59. package/dist/es/chart/RadialBarChart.mjs +5 -5
  60. package/dist/es/chart/RechartsWrapper.mjs +111 -88
  61. package/dist/es/chart/ScatterChart.mjs +5 -5
  62. package/dist/es/chart/Surface.mjs +3 -3
  63. package/dist/es/chart/Surface.vue_vue_type_script_setup_true_lang.mjs +51 -45
  64. package/dist/es/chart/TooltipPortalContext.mjs +3 -3
  65. package/dist/es/chart/const.mjs +2 -2
  66. package/dist/es/chart/generateCategoricalChart.mjs +97 -88
  67. package/dist/es/chart/provideClipPathId.mjs +12 -7
  68. package/dist/es/components/Cell.mjs +16 -4
  69. package/dist/es/components/Text.mjs +3 -3
  70. package/dist/es/components/Text.vue_vue_type_script_setup_true_lang.mjs +106 -69
  71. package/dist/es/components/Tooltip.mjs +274 -199
  72. package/dist/es/components/label/Label.mjs +30 -26
  73. package/dist/es/components/label/LabelList.mjs +45 -39
  74. package/dist/es/components/label/types.mjs +8 -5
  75. package/dist/es/components/label/utils.mjs +194 -162
  76. package/dist/es/components/legend/Legend.mjs +82 -71
  77. package/dist/es/components/legend/LegendSymbol.mjs +40 -38
  78. package/dist/es/components/legend/hooks/useLegend.mjs +66 -46
  79. package/dist/es/components/legend/hooks/useLegendContent.mjs +52 -31
  80. package/dist/es/components/legend/type.mjs +2 -2
  81. package/dist/es/components/legend/utils.mjs +19 -11
  82. package/dist/es/components/utils.mjs +35 -22
  83. package/dist/es/container/ClipPath.mjs +14 -14
  84. package/dist/es/container/Layer.mjs +9 -7
  85. package/dist/es/container/ResponsiveContainer.mjs +3 -3
  86. package/dist/es/container/ResponsiveContainer.vue_vue_type_script_setup_true_lang.mjs +109 -77
  87. package/dist/es/container/Surface.mjs +23 -19
  88. package/dist/es/container/useSizeContext.mjs +3 -3
  89. package/dist/es/context/ChartDataContextProvider.mjs +19 -13
  90. package/dist/es/context/PanoramaContextProvider.mjs +15 -10
  91. package/dist/es/context/accessibilityContext.mjs +3 -3
  92. package/dist/es/context/cartesianLabelListContext.mjs +3 -3
  93. package/dist/es/context/chartLayoutContext.mjs +33 -30
  94. package/dist/es/context/cursorLayerContext.mjs +3 -3
  95. package/dist/es/context/graphicalLayerContext.mjs +3 -3
  96. package/dist/es/context/labelLayerContext.mjs +3 -3
  97. package/dist/es/context/polarLabelViewBoxContext.mjs +5 -5
  98. package/dist/es/context/useTooltipAxis.mjs +14 -12
  99. package/dist/es/events/useChartSynchronisation.mjs +91 -66
  100. package/dist/es/hooks/useIsAnimating.mjs +28 -0
  101. package/dist/es/hooks/useSetupGraphicalItem.mjs +52 -43
  102. package/dist/es/index.mjs +46 -42
  103. package/dist/es/polar/pie/Pie.mjs +131 -115
  104. package/dist/es/polar/pie/type.mjs +6 -6
  105. package/dist/es/polar/radar/PolarAngleAxis.mjs +103 -84
  106. package/dist/es/polar/radar/PolarGrid.mjs +72 -59
  107. package/dist/es/polar/radar/PolarRadiusAxis.mjs +90 -65
  108. package/dist/es/polar/radar/Radar.mjs +181 -145
  109. package/dist/es/polar/radial-bar/RadialBar.mjs +161 -140
  110. package/dist/es/polar/radial-bar/type.mjs +9 -9
  111. package/dist/es/shape/Cross.mjs +11 -10
  112. package/dist/es/shape/Curve.mjs +69 -43
  113. package/dist/es/shape/Dot.mjs +12 -11
  114. package/dist/es/shape/Rectangle.mjs +41 -26
  115. package/dist/es/shape/Sector.mjs +103 -75
  116. package/dist/es/shape/Symbols.mjs +45 -34
  117. package/dist/es/shape/Trapezoid.mjs +52 -0
  118. package/dist/es/state/ReportChartProps.mjs +21 -20
  119. package/dist/es/state/ReportMainChartProps.mjs +26 -21
  120. package/dist/es/state/ReportPolarOptions.mjs +23 -22
  121. package/dist/es/state/SetGraphicalItem.mjs +42 -27
  122. package/dist/es/state/SetLegendPayload.mjs +17 -13
  123. package/dist/es/state/SetTooltipEntrySettings.mjs +14 -12
  124. package/dist/es/state/brushSlice.mjs +12 -8
  125. package/dist/es/state/cartesianAxisSlice.mjs +23 -17
  126. package/dist/es/state/chartDataSlice.mjs +18 -13
  127. package/dist/es/state/externalEventsMiddleware.mjs +25 -15
  128. package/dist/es/state/graphicalItemsSlice.mjs +29 -25
  129. package/dist/es/state/hooks.mjs +4 -3
  130. package/dist/es/state/keyboardEventsMiddleware.mjs +50 -42
  131. package/dist/es/state/layoutSlice.mjs +18 -12
  132. package/dist/es/state/legendSlice.mjs +19 -14
  133. package/dist/es/state/mouseEventsMiddleware.mjs +31 -24
  134. package/dist/es/state/optionsSlice.mjs +14 -11
  135. package/dist/es/state/polarAxisSlice.mjs +15 -13
  136. package/dist/es/state/polarOptionsSlice.mjs +8 -6
  137. package/dist/es/state/reduxDevtoolsJsonStringifyReplacer.mjs +5 -3
  138. package/dist/es/state/referenceElementsSlice.mjs +21 -19
  139. package/dist/es/state/rootPropsSlice.mjs +20 -9
  140. package/dist/es/state/selectors/areaSelectors.mjs +65 -55
  141. package/dist/es/state/selectors/axisSelectors.mjs +755 -569
  142. package/dist/es/state/selectors/barSelectors.mjs +225 -162
  143. package/dist/es/state/selectors/brushSelectors.mjs +15 -14
  144. package/dist/es/state/selectors/combiners/combineActiveLabel.mjs +6 -5
  145. package/dist/es/state/selectors/combiners/combineActiveTooltipIndex.mjs +36 -27
  146. package/dist/es/state/selectors/combiners/combineAxisRangeWithReverse.mjs +5 -3
  147. package/dist/es/state/selectors/combiners/combineCoordinateForDefaultIndex.mjs +13 -11
  148. package/dist/es/state/selectors/combiners/combineTooltipInteractionState.mjs +26 -21
  149. package/dist/es/state/selectors/combiners/combineTooltipPayloadConfigurations.mjs +10 -6
  150. package/dist/es/state/selectors/common.mjs +2 -2
  151. package/dist/es/state/selectors/containerSelectors.mjs +5 -2
  152. package/dist/es/state/selectors/dataSelectors.mjs +28 -9
  153. package/dist/es/state/selectors/funnelSelectors.mjs +38 -0
  154. package/dist/es/state/selectors/legendSelectors.mjs +7 -6
  155. package/dist/es/state/selectors/lineSelectors.mjs +54 -47
  156. package/dist/es/state/selectors/pickAxisId.mjs +2 -2
  157. package/dist/es/state/selectors/pickAxisType.mjs +2 -2
  158. package/dist/es/state/selectors/pieSelectors.mjs +116 -81
  159. package/dist/es/state/selectors/polarAxisSelectors.mjs +113 -94
  160. package/dist/es/state/selectors/polarGridSelectors.mjs +13 -11
  161. package/dist/es/state/selectors/polarScaleSelectors.mjs +49 -46
  162. package/dist/es/state/selectors/polarSelectors.mjs +79 -62
  163. package/dist/es/state/selectors/radarSelectors.mjs +111 -91
  164. package/dist/es/state/selectors/radialBarSelectors.mjs +230 -183
  165. package/dist/es/state/selectors/rootPropsSelectors.mjs +11 -5
  166. package/dist/es/state/selectors/scatterSelectors.mjs +111 -95
  167. package/dist/es/state/selectors/selectActivePropsFromChartPointer.mjs +19 -17
  168. package/dist/es/state/selectors/selectAllAxes.mjs +8 -3
  169. package/dist/es/state/selectors/selectChartOffset.mjs +59 -50
  170. package/dist/es/state/selectors/selectChartOffsetInternal.mjs +55 -44
  171. package/dist/es/state/selectors/selectTooltipEventType.mjs +15 -14
  172. package/dist/es/state/selectors/selectTooltipPayloadSearcher.mjs +3 -3
  173. package/dist/es/state/selectors/selectTooltipSettings.mjs +2 -2
  174. package/dist/es/state/selectors/selectTooltipState.mjs +2 -2
  175. package/dist/es/state/selectors/selectors.mjs +94 -75
  176. package/dist/es/state/selectors/tooltipSelectors.mjs +253 -204
  177. package/dist/es/state/selectors/touchSelectors.mjs +17 -14
  178. package/dist/es/state/store.mjs +46 -46
  179. package/dist/es/state/tooltipSlice.mjs +64 -37
  180. package/dist/es/state/touchEventsMiddleware.mjs +35 -29
  181. package/dist/es/state/utils/useReportScale.mjs +16 -13
  182. package/dist/es/synchronisation/syncSelectors.mjs +3 -3
  183. package/dist/es/synchronisation/useChartSynchronisation.mjs +33 -19
  184. package/dist/es/types/event.mjs +164 -2
  185. package/dist/es/utils/ReduceCSSCalc.mjs +81 -49
  186. package/dist/es/utils/VueUtils.mjs +35 -14
  187. package/dist/es/utils/attrs.mjs +43 -26
  188. package/dist/es/utils/cartesian.mjs +47 -15
  189. package/dist/es/utils/chart.mjs +298 -197
  190. package/dist/es/utils/const.mjs +30 -2
  191. package/dist/es/utils/createContext.mjs +28 -9
  192. package/dist/es/utils/data-utils.mjs +9 -8
  193. package/dist/es/utils/data.mjs +35 -21
  194. package/dist/es/utils/events.mjs +5 -3
  195. package/dist/es/utils/getLinearRegression.mjs +28 -11
  196. package/dist/es/utils/grid.mjs +20 -5
  197. package/dist/es/utils/isDomainSpecifiedByUser.mjs +105 -54
  198. package/dist/es/utils/legend.mjs +13 -12
  199. package/dist/es/utils/log.mjs +10 -7
  200. package/dist/es/utils/payload/getUniqPayload.mjs +6 -4
  201. package/dist/es/utils/polar.mjs +37 -30
  202. package/dist/es/utils/props.mjs +16 -10
  203. package/dist/es/utils/resolveDefaultProps.mjs +23 -4
  204. package/dist/es/utils/scale/getNiceTickValues.mjs +127 -49
  205. package/dist/es/utils/scale/utils/arithmetic.mjs +49 -19
  206. package/dist/es/utils/scale/utils/utils.mjs +43 -24
  207. package/dist/es/utils/style.mjs +24 -13
  208. package/dist/es/utils/tick.mjs +34 -23
  209. package/dist/es/utils/tooltip/translate.mjs +63 -49
  210. package/dist/es/utils/validate.mjs +40 -29
  211. package/dist/hooks/useIsAnimating.d.ts +14 -0
  212. package/dist/shape/Trapezoid.d.ts +31 -0
  213. package/dist/shape/index.d.ts +1 -0
  214. package/dist/state/graphicalItemsSlice.d.ts +1 -1
  215. package/package.json +1 -1
@@ -1,29 +1,31 @@
1
- import { Curve as e } from "../../shape/Curve.mjs";
2
- import { getTooltipNameProp as t, getValueByDataKey as n } from "../../utils/chart.mjs";
3
- import { mouseLeaveChart as r, setActiveMouseOverItemIndex as i, setMouseOverAxisIndex as a } from "../../state/tooltipSlice.mjs";
4
- import { selectActiveTooltipDataKey as o, selectActiveTooltipIndex as s } from "../../state/selectors/tooltipSelectors.mjs";
5
- import { useAppDispatch as c, useAppSelector as l } from "../../state/hooks.mjs";
6
- import { Layer as u } from "../../container/Layer.mjs";
7
- import { LabelList as d } from "../../components/label/LabelList.mjs";
8
- import { Animate as f } from "../../animation/Animate.mjs";
9
- import { SetTooltipEntrySettings as p } from "../../state/SetTooltipEntrySettings.mjs";
10
- import { useSetupGraphicalItem as m } from "../../hooks/useSetupGraphicalItem.mjs";
11
- import { useGraphicalLayerRef as h } from "../../context/graphicalLayerContext.mjs";
12
- import { createErrorBarRegistry as g, provideErrorBarContext as _, provideErrorBarRegistry as v } from "../error-bar/ErrorBarContext.mjs";
13
- import { useScatter as y } from "./hooks/useScatter.mjs";
14
- import { Symbols as b } from "../../shape/Symbols.mjs";
15
- import { getLinearRegression as x } from "../../utils/getLinearRegression.mjs";
16
- import { Fragment as S, Teleport as C, computed as w, createVNode as T, defineComponent as E, isVNode as D, mergeProps as O, useAttrs as k } from "vue";
1
+ import { Curve } from "../../shape/Curve.mjs";
2
+ import { getTooltipNameProp, getValueByDataKey } from "../../utils/chart.mjs";
3
+ import { mouseLeaveChart, setActiveMouseOverItemIndex, setMouseOverAxisIndex } from "../../state/tooltipSlice.mjs";
4
+ import { selectActiveTooltipDataKey, selectActiveTooltipIndex } from "../../state/selectors/tooltipSelectors.mjs";
5
+ import { useAppDispatch, useAppSelector } from "../../state/hooks.mjs";
6
+ import { Layer } from "../../container/Layer.mjs";
7
+ import { LabelList } from "../../components/label/LabelList.mjs";
8
+ import { Animate } from "../../animation/Animate.mjs";
9
+ import { SetTooltipEntrySettings } from "../../state/SetTooltipEntrySettings.mjs";
10
+ import { useSetupGraphicalItem } from "../../hooks/useSetupGraphicalItem.mjs";
11
+ import { useGraphicalLayerRef } from "../../context/graphicalLayerContext.mjs";
12
+ import { createErrorBarRegistry, provideErrorBarContext, provideErrorBarRegistry } from "../error-bar/ErrorBarContext.mjs";
13
+ import { useScatter } from "./hooks/useScatter.mjs";
14
+ import { Symbols } from "../../shape/Symbols.mjs";
15
+ import { getLinearRegression } from "../../utils/getLinearRegression.mjs";
16
+ import { Fragment, Teleport, computed, createVNode, defineComponent, isVNode, mergeProps, useAttrs } from "vue";
17
17
  //#region src/cartesian/scatter/Scatter.tsx
18
- function A(e) {
19
- return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !D(e);
18
+ function _isSlot(s) {
19
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
20
20
  }
21
- var j = (e, t) => (n) => e + (t - e) * n, M = (e, t, r) => ({
22
- x: e.cx,
23
- y: e.cy,
24
- value: r === "x" ? Number(e.node.x) : Number(e.node.y),
25
- errorVal: n(e.payload, t)
26
- }), N = /* @__PURE__ */ E({
21
+ var interpolateNumber = (from, to) => (t) => from + (to - from) * t;
22
+ var errorBarDataPointFormatter = (dataPoint, dataKey, direction) => ({
23
+ x: dataPoint.cx,
24
+ y: dataPoint.cy,
25
+ value: direction === "x" ? Number(dataPoint.node.x) : Number(dataPoint.node.y),
26
+ errorVal: getValueByDataKey(dataPoint.payload, dataKey)
27
+ });
28
+ var Scatter = /* @__PURE__ */ defineComponent({
27
29
  name: "Scatter",
28
30
  props: {
29
31
  xAxisId: {
@@ -56,7 +58,7 @@ var j = (e, t) => (n) => e + (t - e) * n, M = (e, t, r) => ({
56
58
  },
57
59
  hide: {
58
60
  type: Boolean,
59
- default: !1
61
+ default: false
60
62
  },
61
63
  fill: {
62
64
  type: String,
@@ -68,11 +70,11 @@ var j = (e, t) => (n) => e + (t - e) * n, M = (e, t, r) => ({
68
70
  },
69
71
  isAnimationActive: {
70
72
  type: Boolean,
71
- default: !0
73
+ default: true
72
74
  },
73
75
  line: {
74
76
  type: [Boolean, Object],
75
- default: !1
77
+ default: false
76
78
  },
77
79
  lineType: {
78
80
  type: String,
@@ -84,7 +86,7 @@ var j = (e, t) => (n) => e + (t - e) * n, M = (e, t, r) => ({
84
86
  },
85
87
  label: {
86
88
  type: [Boolean, Object],
87
- default: !1
89
+ default: false
88
90
  },
89
91
  legendType: {
90
92
  type: String,
@@ -99,154 +101,180 @@ var j = (e, t) => (n) => e + (t - e) * n, M = (e, t, r) => ({
99
101
  default: void 0
100
102
  }
101
103
  },
102
- inheritAttrs: !1,
104
+ inheritAttrs: false,
103
105
  slots: Object,
104
- setup(n, { attrs: E, slots: D }) {
105
- let N = g();
106
- v(N), m(n, "scatter", {
107
- skipTooltip: !0,
108
- errorBars: N.errorBars
106
+ setup(props, { attrs, slots }) {
107
+ const errorBarRegistry = createErrorBarRegistry();
108
+ provideErrorBarRegistry(errorBarRegistry);
109
+ useSetupGraphicalItem(props, "scatter", {
110
+ skipTooltip: true,
111
+ errorBars: errorBarRegistry.errorBars
109
112
  });
110
- let { shouldRender: P, points: F } = y(n), I = h(), L = k(), R = c(), z = l(s), B = l(o);
111
- p({
112
- fn: (e) => ({
113
- dataDefinedOnItem: e.points?.map((e) => e.tooltipPayload),
113
+ const { shouldRender, points } = useScatter(props);
114
+ const graphicalLayerRef = useGraphicalLayerRef();
115
+ const svgAttrs = useAttrs();
116
+ const dispatch = useAppDispatch();
117
+ const activeIndex = useAppSelector(selectActiveTooltipIndex);
118
+ const activeDataKey = useAppSelector(selectActiveTooltipDataKey);
119
+ SetTooltipEntrySettings({
120
+ fn: (input) => ({
121
+ dataDefinedOnItem: input.points?.map((p) => p.tooltipPayload),
114
122
  positions: void 0,
115
123
  settings: {
116
- stroke: e.stroke,
117
- strokeWidth: e.strokeWidth,
118
- fill: e.fill,
119
- dataKey: e.dataKey,
124
+ stroke: input.stroke,
125
+ strokeWidth: input.strokeWidth,
126
+ fill: input.fill,
127
+ dataKey: input.dataKey,
120
128
  nameKey: void 0,
121
- name: t(e.name, e.dataKey),
122
- hide: e.hide,
123
- type: e.tooltipType,
124
- color: e.fill,
129
+ name: getTooltipNameProp(input.name, input.dataKey),
130
+ hide: input.hide,
131
+ type: input.tooltipType,
132
+ color: input.fill,
125
133
  unit: ""
126
134
  }
127
135
  }),
128
- args: w(() => ({
129
- points: F.value,
130
- fill: L.fill ?? n.fill,
131
- stroke: L.stroke,
132
- strokeWidth: L["stroke-width"],
133
- name: n.name,
134
- dataKey: n.dataKey,
135
- hide: n.hide,
136
- tooltipType: n.tooltipType
136
+ args: computed(() => ({
137
+ points: points.value,
138
+ fill: svgAttrs.fill ?? props.fill,
139
+ stroke: svgAttrs.stroke,
140
+ strokeWidth: svgAttrs["stroke-width"],
141
+ name: props.name,
142
+ dataKey: props.dataKey,
143
+ hide: props.hide,
144
+ tooltipType: props.tooltipType
137
145
  }))
138
- }), _({
139
- data: F,
140
- xAxisId: n.xAxisId,
141
- yAxisId: n.yAxisId,
142
- dataPointFormatter: M,
143
- errorBarOffset: w(() => 0)
144
146
  });
145
- let V = null, H = 0, U = (e, t) => {
146
- let r = {
147
- activeDataKey: n.dataKey,
148
- activeIndex: String(t),
149
- activeCoordinate: e.tooltipPosition
147
+ provideErrorBarContext({
148
+ data: points,
149
+ xAxisId: props.xAxisId,
150
+ yAxisId: props.yAxisId,
151
+ dataPointFormatter: errorBarDataPointFormatter,
152
+ errorBarOffset: computed(() => 0)
153
+ });
154
+ let previousPoints = null;
155
+ let animationId = 0;
156
+ const dispatchScatterHover = (point, index) => {
157
+ const payload = {
158
+ activeDataKey: props.dataKey,
159
+ activeIndex: String(index),
160
+ activeCoordinate: point.tooltipPosition
150
161
  };
151
- R(a(r)), R(i(r));
152
- }, W = () => {
153
- R(r());
154
- }, G = (e, t) => {
155
- let r = z.value, i = B.value;
156
- return e.map((e, a) => {
157
- if (e.cx == null || e.cy == null) return null;
158
- let o = r === String(a) && i === n.dataKey, s = {
159
- ...t,
160
- ...n.fill == null ? {} : { fill: n.fill },
161
- cx: e.cx,
162
- cy: e.cy,
163
- size: o ? (e.size ?? 64) * 1.6 : e.size,
164
- type: n.shape,
165
- ...o ? {
162
+ dispatch(setMouseOverAxisIndex(payload));
163
+ dispatch(setActiveMouseOverItemIndex(payload));
164
+ };
165
+ const onMouseLeaveSymbol = () => {
166
+ dispatch(mouseLeaveChart());
167
+ };
168
+ const renderSymbols = (data, svgAttrs) => {
169
+ const currentActiveIndex = activeIndex.value;
170
+ const currentActiveDataKey = activeDataKey.value;
171
+ return data.map((point, i) => {
172
+ if (point.cx == null || point.cy == null) return null;
173
+ const isActive = currentActiveIndex === String(i) && currentActiveDataKey === props.dataKey;
174
+ const symbolProps = {
175
+ ...svgAttrs,
176
+ ...props.fill != null ? { fill: props.fill } : {},
177
+ cx: point.cx,
178
+ cy: point.cy,
179
+ size: isActive ? (point.size ?? 64) * 1.6 : point.size,
180
+ type: props.shape,
181
+ ...isActive ? {
166
182
  stroke: "#fff",
167
183
  "stroke-width": 2
168
184
  } : {}
169
185
  };
170
- return T("g", {
171
- class: "v-charts-scatter-symbol",
172
- onMouseenter: () => U(e, a),
173
- onMousemove: (t) => {
174
- t.stopPropagation(), U(e, a);
186
+ return createVNode("g", {
187
+ "class": "v-charts-scatter-symbol",
188
+ "onMouseenter": () => dispatchScatterHover(point, i),
189
+ "onMousemove": (e) => {
190
+ e.stopPropagation();
191
+ dispatchScatterHover(point, i);
175
192
  },
176
- onMouseleave: W
177
- }, [b(s)]);
193
+ "onMouseleave": onMouseLeaveSymbol
194
+ }, [Symbols(symbolProps)]);
178
195
  });
179
- }, K = (t, r) => {
180
- if (!n.line) return null;
181
- let i;
182
- if (n.lineType === "joint") i = t.map((e) => ({
183
- x: e.cx ?? 0,
184
- y: e.cy ?? 0
196
+ };
197
+ const renderLine = (data, svgAttrs) => {
198
+ if (!props.line) return null;
199
+ let linePoints;
200
+ if (props.lineType === "joint") linePoints = data.map((p) => ({
201
+ x: p.cx ?? 0,
202
+ y: p.cy ?? 0
185
203
  }));
186
204
  else {
187
- let { xmin: e, xmax: n, a: r, b: a } = x(t);
188
- i = [{
189
- x: e,
190
- y: r * e + a
205
+ const { xmin, xmax, a, b } = getLinearRegression(data);
206
+ linePoints = [{
207
+ x: xmin,
208
+ y: a * xmin + b
191
209
  }, {
192
- x: n,
193
- y: r * n + a
210
+ x: xmax,
211
+ y: a * xmax + b
194
212
  }];
195
213
  }
196
- let a = {
214
+ const lineProps = {
197
215
  fill: "none",
198
- stroke: r.stroke ?? n.fill,
199
- ...typeof n.line == "object" ? n.line : {},
200
- points: i
216
+ stroke: svgAttrs.stroke ?? props.fill,
217
+ ...typeof props.line === "object" ? props.line : {},
218
+ points: linePoints
201
219
  };
202
- return T(u, {
203
- class: "v-charts-scatter-line",
204
- style: { pointerEvents: "none" }
205
- }, { default: () => [T(e, O(a, { type: n.lineJointType }), null)] });
220
+ return createVNode(Layer, {
221
+ "class": "v-charts-scatter-line",
222
+ "style": { pointerEvents: "none" }
223
+ }, { default: () => [createVNode(Curve, mergeProps(lineProps, { "type": props.lineJointType }), null)] });
206
224
  };
207
225
  return () => {
208
- if (!P.value) return null;
209
- let e = E, t = F.value, r = n.isAnimationActive, i;
210
- if (r && V !== t) {
211
- let a = V;
212
- H++, i = T(f, {
213
- key: H,
214
- transition: n.transition,
215
- isActive: r
216
- }, { default: (n) => {
217
- let r = n === 1 ? t : t.map((e, t) => {
218
- let r = a && a[t];
219
- return r ? {
220
- ...e,
221
- cx: e.cx == null ? void 0 : j(r.cx ?? 0, e.cx)(n),
222
- cy: e.cy == null ? void 0 : j(r.cy ?? 0, e.cy)(n),
223
- size: j(r.size ?? 0, e.size ?? 0)(n)
224
- } : {
225
- ...e,
226
- size: j(0, e.size ?? 0)(n)
226
+ if (!shouldRender.value) return null;
227
+ const svgAttrs = attrs;
228
+ const data = points.value;
229
+ const isAnimationActive = props.isAnimationActive;
230
+ let symbolsContent;
231
+ if (isAnimationActive && previousPoints !== data) {
232
+ const prevData = previousPoints;
233
+ animationId++;
234
+ symbolsContent = createVNode(Animate, {
235
+ "key": animationId,
236
+ "transition": props.transition,
237
+ "isActive": isAnimationActive
238
+ }, { default: (t) => {
239
+ const stepData = t === 1 ? data : data.map((entry, index) => {
240
+ const prev = prevData && prevData[index];
241
+ if (prev) return {
242
+ ...entry,
243
+ cx: entry.cx == null ? void 0 : interpolateNumber(prev.cx ?? 0, entry.cx)(t),
244
+ cy: entry.cy == null ? void 0 : interpolateNumber(prev.cy ?? 0, entry.cy)(t),
245
+ size: interpolateNumber(prev.size ?? 0, entry.size ?? 0)(t)
246
+ };
247
+ return {
248
+ ...entry,
249
+ size: interpolateNumber(0, entry.size ?? 0)(t)
227
250
  };
228
251
  });
229
- return n > 0 && (V = r), T(S, null, [K(r, e), G(r, e)]);
252
+ if (t > 0) previousPoints = stepData;
253
+ return createVNode(Fragment, null, [renderLine(stepData, svgAttrs), renderSymbols(stepData, svgAttrs)]);
230
254
  } });
231
- } else V = t, i = T(S, null, [K(t, e), G(t, e)]);
232
- let a = T(u, { class: "v-charts-scatter" }, { default: () => [
233
- D.default?.(),
234
- i,
235
- n.label && (() => {
236
- let e = t.map((e) => ({
237
- x: e.cx ?? 0,
238
- y: e.cy ?? 0,
255
+ } else {
256
+ previousPoints = data;
257
+ symbolsContent = createVNode(Fragment, null, [renderLine(data, svgAttrs), renderSymbols(data, svgAttrs)]);
258
+ }
259
+ const content = createVNode(Layer, { "class": "v-charts-scatter" }, { default: () => [
260
+ slots.default?.(),
261
+ symbolsContent,
262
+ props.label && (() => {
263
+ const labelData = data.map((point) => ({
264
+ x: point.cx ?? 0,
265
+ y: point.cy ?? 0,
239
266
  width: 0,
240
267
  height: 0,
241
268
  value: void 0,
242
- payload: e.payload
269
+ payload: point.payload
243
270
  }));
244
- return T(d, O(typeof n.label == "object" ? n.label : {}, { data: e }), null);
271
+ return createVNode(LabelList, mergeProps(typeof props.label === "object" ? props.label : {}, { "data": labelData }), null);
245
272
  })()
246
273
  ] });
247
- return I?.value ? T(C, { to: I.value }, A(a) ? a : { default: () => [a] }) : a;
274
+ if (graphicalLayerRef?.value) return createVNode(Teleport, { "to": graphicalLayerRef.value }, _isSlot(content) ? content : { default: () => [content] });
275
+ return content;
248
276
  };
249
277
  }
250
278
  });
251
279
  //#endregion
252
- export { N as Scatter };
280
+ export { Scatter };
@@ -1,19 +1,23 @@
1
- import { useIsPanorama as e } from "../../../context/PanoramaContextProvider.mjs";
2
- import { useAppSelector as t } from "../../../state/hooks.mjs";
3
- import { selectScatterPoints as n } from "../../../state/selectors/scatterSelectors.mjs";
4
- import { computed as r } from "vue";
1
+ import { useIsPanorama } from "../../../context/PanoramaContextProvider.mjs";
2
+ import { useAppSelector } from "../../../state/hooks.mjs";
3
+ import { selectScatterPoints } from "../../../state/selectors/scatterSelectors.mjs";
4
+ import { computed } from "vue";
5
5
  //#region src/cartesian/scatter/hooks/useScatter.ts
6
- function i(i) {
7
- let a = e(), o = r(() => ({
8
- data: i.data,
9
- dataKey: i.dataKey,
10
- tooltipType: i.tooltipType,
11
- name: i.name ?? String(i.dataKey ?? "")
12
- })), s = t((e) => n(e, i.xAxisId ?? 0, i.yAxisId ?? 0, i.zAxisId ?? 0, o.value, a));
6
+ function useScatter(props) {
7
+ const isPanorama = useIsPanorama();
8
+ const scatterSettings = computed(() => ({
9
+ data: props.data,
10
+ dataKey: props.dataKey,
11
+ tooltipType: props.tooltipType,
12
+ name: props.name ?? String(props.dataKey ?? "")
13
+ }));
14
+ const points = useAppSelector((state) => selectScatterPoints(state, props.xAxisId ?? 0, props.yAxisId ?? 0, props.zAxisId ?? 0, scatterSettings.value, isPanorama));
13
15
  return {
14
- shouldRender: r(() => !i.hide && s.value != null && s.value.length > 0),
15
- points: s
16
+ shouldRender: computed(() => {
17
+ return !props.hide && points.value != null && points.value.length > 0;
18
+ }),
19
+ points
16
20
  };
17
21
  }
18
22
  //#endregion
19
- export { i as useScatter };
23
+ export { useScatter };
@@ -1,14 +1,23 @@
1
- import { selectXAxisSettings as e, selectYAxisSettings as t } from "../state/selectors/axisSelectors.mjs";
2
- import { useAppSelector as n } from "../state/hooks.mjs";
3
- import { computed as r } from "vue";
1
+ import { selectXAxisSettings, selectYAxisSettings } from "../state/selectors/axisSelectors.mjs";
2
+ import { useAppSelector } from "../state/hooks.mjs";
3
+ import { computed } from "vue";
4
4
  //#region src/cartesian/useNeedsClip.ts
5
- function i(i, a) {
6
- let o = n((t) => e(t, i)), s = n((e) => t(e, a)), c = r(() => o.value && o.value.allowDataOverflow), l = r(() => s.value && s.value.allowDataOverflow);
5
+ function useNeedsClip(xAxisId, yAxisId) {
6
+ const xAxis = useAppSelector((state) => selectXAxisSettings(state, xAxisId));
7
+ const yAxis = useAppSelector((state) => selectYAxisSettings(state, yAxisId));
8
+ const needClipX = computed(() => {
9
+ return xAxis.value && xAxis.value.allowDataOverflow;
10
+ });
11
+ const needClipY = computed(() => {
12
+ return yAxis.value && yAxis.value.allowDataOverflow;
13
+ });
7
14
  return {
8
- needClip: r(() => c.value || l.value),
9
- needClipX: c,
10
- needClipY: l
15
+ needClip: computed(() => {
16
+ return needClipX.value || needClipY.value;
17
+ }),
18
+ needClipX,
19
+ needClipY
11
20
  };
12
21
  }
13
22
  //#endregion
14
- export { i as useNeedsClip };
23
+ export { useNeedsClip };
@@ -1,83 +1,118 @@
1
- import { isNumber as e, isSsr as t, isVisible as n } from "../../utils/validate.mjs";
2
- import { mathSign as r } from "../../utils/data.mjs";
3
- import { getStringSize as i } from "../../utils/attrs.mjs";
4
- import { getAngledTickWidth as a, getNumberIntervalTicks as o, getTickBoundaries as s } from "../../utils/tick.mjs";
5
- import { getEquidistantTicks as c } from "../../utils/cartesian.mjs";
1
+ import { isNumber, isSsr, isVisible } from "../../utils/validate.mjs";
2
+ import { mathSign } from "../../utils/data.mjs";
3
+ import { getStringSize } from "../../utils/attrs.mjs";
4
+ import { getAngledTickWidth, getNumberIntervalTicks, getTickBoundaries } from "../../utils/tick.mjs";
5
+ import { getEquidistantTicks } from "../../utils/cartesian.mjs";
6
6
  //#region src/cartesian/utils/get-ticks.ts
7
- function l(e, t, r, i, a) {
8
- let o = (i || []).slice(), s = o.length, { start: c } = t, { end: l } = t;
9
- for (let t = s - 1; t >= 0; t--) {
10
- let i = o[t], u, d = () => (u === void 0 && (u = r(i, t)), u);
11
- if (t === s - 1) {
12
- let n = e * (i.coordinate + e * d() / 2 - l);
13
- o[t] = i = {
14
- ...i,
15
- tickCoord: n > 0 ? i.coordinate - n * e : i.coordinate
7
+ function getTicksEnd(sign, boundaries, getTickSize, ticks, minTickGap) {
8
+ const result = (ticks || []).slice();
9
+ const len = result.length;
10
+ const { start } = boundaries;
11
+ let { end } = boundaries;
12
+ for (let i = len - 1; i >= 0; i--) {
13
+ let entry = result[i];
14
+ let size;
15
+ const getSize = () => {
16
+ if (size === void 0) size = getTickSize(entry, i);
17
+ return size;
18
+ };
19
+ if (i === len - 1) {
20
+ const gap = sign * (entry.coordinate + sign * getSize() / 2 - end);
21
+ result[i] = entry = {
22
+ ...entry,
23
+ tickCoord: gap > 0 ? entry.coordinate - gap * sign : entry.coordinate
16
24
  };
17
- } else o[t] = i = {
18
- ...i,
19
- tickCoord: i.coordinate
25
+ } else result[i] = entry = {
26
+ ...entry,
27
+ tickCoord: entry.coordinate
20
28
  };
21
- n(e, i.tickCoord, d, c, l) && (l = i.tickCoord - e * (d() / 2 + a), o[t] = {
22
- ...i,
23
- isShow: !0
24
- });
29
+ if (isVisible(sign, entry.tickCoord, getSize, start, end)) {
30
+ end = entry.tickCoord - sign * (getSize() / 2 + minTickGap);
31
+ result[i] = {
32
+ ...entry,
33
+ isShow: true
34
+ };
35
+ }
25
36
  }
26
- return o;
37
+ return result;
27
38
  }
28
- function u(e, t, r, i, a, o) {
29
- let s = (i || []).slice(), c = s.length, { start: l, end: u } = t;
30
- if (o) {
31
- let t = i[c - 1], o = r(t, c - 1), d = e * (t.coordinate + e * o / 2 - u);
32
- s[c - 1] = t = {
33
- ...t,
34
- tickCoord: d > 0 ? t.coordinate - d * e : t.coordinate
35
- }, n(e, t.tickCoord, () => o, l, u) && (u = t.tickCoord - e * (o / 2 + a), s[c - 1] = {
36
- ...t,
37
- isShow: !0
38
- });
39
+ function getTicksStart(sign, boundaries, getTickSize, ticks, minTickGap, preserveEnd) {
40
+ const result = (ticks || []).slice();
41
+ const len = result.length;
42
+ let { start, end } = boundaries;
43
+ if (preserveEnd) {
44
+ let tail = ticks[len - 1];
45
+ const tailSize = getTickSize(tail, len - 1);
46
+ const tailGap = sign * (tail.coordinate + sign * tailSize / 2 - end);
47
+ result[len - 1] = tail = {
48
+ ...tail,
49
+ tickCoord: tailGap > 0 ? tail.coordinate - tailGap * sign : tail.coordinate
50
+ };
51
+ if (isVisible(sign, tail.tickCoord, () => tailSize, start, end)) {
52
+ end = tail.tickCoord - sign * (tailSize / 2 + minTickGap);
53
+ result[len - 1] = {
54
+ ...tail,
55
+ isShow: true
56
+ };
57
+ }
39
58
  }
40
- let d = o ? c - 1 : c;
41
- for (let t = 0; t < d; t++) {
42
- let i = s[t], o, c = () => (o === void 0 && (o = r(i, t)), o);
43
- if (t === 0) {
44
- let n = e * (i.coordinate - e * c() / 2 - l);
45
- s[t] = i = {
46
- ...i,
47
- tickCoord: n < 0 ? i.coordinate - n * e : i.coordinate
59
+ const count = preserveEnd ? len - 1 : len;
60
+ for (let i = 0; i < count; i++) {
61
+ let entry = result[i];
62
+ let size;
63
+ const getSize = () => {
64
+ if (size === void 0) size = getTickSize(entry, i);
65
+ return size;
66
+ };
67
+ if (i === 0) {
68
+ const gap = sign * (entry.coordinate - sign * getSize() / 2 - start);
69
+ result[i] = entry = {
70
+ ...entry,
71
+ tickCoord: gap < 0 ? entry.coordinate - gap * sign : entry.coordinate
48
72
  };
49
- } else s[t] = i = {
50
- ...i,
51
- tickCoord: i.coordinate
73
+ } else result[i] = entry = {
74
+ ...entry,
75
+ tickCoord: entry.coordinate
52
76
  };
53
- n(e, i.tickCoord, c, l, u) && (l = i.tickCoord + e * (c() / 2 + a), s[t] = {
54
- ...i,
55
- isShow: !0
56
- });
77
+ if (isVisible(sign, entry.tickCoord, getSize, start, end)) {
78
+ start = entry.tickCoord + sign * (getSize() / 2 + minTickGap);
79
+ result[i] = {
80
+ ...entry,
81
+ isShow: true
82
+ };
83
+ }
57
84
  }
58
- return s;
85
+ return result;
59
86
  }
60
- function d(n, d, f) {
61
- let { tick: p, ticks: m, viewBox: h, minTickGap: g, orientation: _, interval: v, tickFormatter: y, unit: b, angle: x } = n;
62
- if (!m || !m.length || !p) return [];
63
- if (e(v) || t) return o(m, e(v) ? v : 0) ?? [];
64
- let S = [], C = _ === "top" || _ === "bottom" ? "width" : "height", w = b && C === "width" ? i(b, {
65
- fontSize: d,
66
- letterSpacing: f
87
+ function getTicks(props, fontSize, letterSpacing) {
88
+ const { tick, ticks, viewBox, minTickGap, orientation, interval, tickFormatter, unit, angle } = props;
89
+ if (!ticks || !ticks.length || !tick) return [];
90
+ if (isNumber(interval) || isSsr) return getNumberIntervalTicks(ticks, isNumber(interval) ? interval : 0) ?? [];
91
+ let candidates = [];
92
+ const sizeKey = orientation === "top" || orientation === "bottom" ? "width" : "height";
93
+ const unitSize = unit && sizeKey === "width" ? getStringSize(unit, {
94
+ fontSize,
95
+ letterSpacing
67
96
  }) : {
68
97
  width: 0,
69
98
  height: 0
70
- }, T = (e, t) => {
71
- let n = typeof y == "function" ? y(e.value, t) : e.value;
72
- return C === "width" ? a(i(n, {
73
- fontSize: d,
74
- letterSpacing: f
75
- }), w, x) : i(n, {
76
- fontSize: d,
77
- letterSpacing: f
78
- })[C];
79
- }, E = m.length >= 2 ? r(m[1].coordinate - m[0].coordinate) : 1, D = s(h, E, C);
80
- return v === "equidistantPreserveStart" ? c(E, D, T, m, g) : (S = v === "preserveStart" || v === "preserveStartEnd" ? u(E, D, T, m, g, v === "preserveStartEnd") : l(E, D, T, m, g), S.filter((e) => e.isShow));
99
+ };
100
+ const getTickSize = (content, index) => {
101
+ const value = typeof tickFormatter === "function" ? tickFormatter(content.value, index) : content.value;
102
+ return sizeKey === "width" ? getAngledTickWidth(getStringSize(value, {
103
+ fontSize,
104
+ letterSpacing
105
+ }), unitSize, angle) : getStringSize(value, {
106
+ fontSize,
107
+ letterSpacing
108
+ })[sizeKey];
109
+ };
110
+ const sign = ticks.length >= 2 ? mathSign(ticks[1].coordinate - ticks[0].coordinate) : 1;
111
+ const boundaries = getTickBoundaries(viewBox, sign, sizeKey);
112
+ if (interval === "equidistantPreserveStart") return getEquidistantTicks(sign, boundaries, getTickSize, ticks, minTickGap);
113
+ if (interval === "preserveStart" || interval === "preserveStartEnd") candidates = getTicksStart(sign, boundaries, getTickSize, ticks, minTickGap, interval === "preserveStartEnd");
114
+ else candidates = getTicksEnd(sign, boundaries, getTickSize, ticks, minTickGap);
115
+ return candidates.filter((entry) => entry.isShow);
81
116
  }
82
117
  //#endregion
83
- export { d as getTicks };
118
+ export { getTicks };