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,145 +1,161 @@
1
- import { selectChartOffset as e } from "../../state/selectors/selectChartOffset.mjs";
2
- import { polarToCartesian as t } from "../../utils/polar.mjs";
3
- import { mouseLeaveItem as n, setActiveMouseOverItemIndex as r } from "../../state/tooltipSlice.mjs";
4
- import { useAppDispatch as i, useAppSelector as a } from "../../state/hooks.mjs";
5
- import { Layer as o } from "../../container/Layer.mjs";
6
- import { Animate as s } from "../../animation/Animate.mjs";
7
- import { SetPolarGraphicalItem as c } from "../../state/SetGraphicalItem.mjs";
8
- import { SetLegendPayload as l } from "../../state/SetLegendPayload.mjs";
9
- import { SetTooltipEntrySettings as u } from "../../state/SetTooltipEntrySettings.mjs";
10
- import { Sector as d } from "../../shape/Sector.mjs";
11
- import { computePieSectors as f, selectDisplayedData as p, selectPieLegend as m, selectSynchronisedPieSettings as h } from "../../state/selectors/pieSelectors.mjs";
12
- import { PieVueProps as g } from "./type.mjs";
13
- import { computed as _, createVNode as v, defineComponent as y, mergeProps as b, ref as x, watch as S } from "vue";
1
+ import { selectChartOffset } from "../../state/selectors/selectChartOffset.mjs";
2
+ import { polarToCartesian } from "../../utils/polar.mjs";
3
+ import { mouseLeaveItem, setActiveMouseOverItemIndex } from "../../state/tooltipSlice.mjs";
4
+ import { useAppDispatch, useAppSelector } from "../../state/hooks.mjs";
5
+ import { Layer } from "../../container/Layer.mjs";
6
+ import { Animate } from "../../animation/Animate.mjs";
7
+ import { SetPolarGraphicalItem } from "../../state/SetGraphicalItem.mjs";
8
+ import { SetLegendPayload } from "../../state/SetLegendPayload.mjs";
9
+ import { SetTooltipEntrySettings } from "../../state/SetTooltipEntrySettings.mjs";
10
+ import { Sector } from "../../shape/Sector.mjs";
11
+ import { computePieSectors, selectDisplayedData, selectPieLegend, selectSynchronisedPieSettings } from "../../state/selectors/pieSelectors.mjs";
12
+ import { PieVueProps } from "./type.mjs";
13
+ import { computed, createVNode, defineComponent, mergeProps, ref, watch } from "vue";
14
14
  //#region src/polar/pie/Pie.tsx
15
- var C = 20, w = /* @__PURE__ */ y({
15
+ var LABEL_OFFSET = 20;
16
+ var Pie = /* @__PURE__ */ defineComponent({
16
17
  name: "Pie",
17
- props: g,
18
- inheritAttrs: !1,
18
+ props: PieVueProps,
19
+ inheritAttrs: false,
19
20
  slots: Object,
20
- setup(g, { attrs: y, slots: w }) {
21
- let T = i(), E = _(() => g.activeIndex !== -1), D = x(g.activeIndex);
22
- S(() => g.activeIndex, (e) => {
23
- D.value = e;
21
+ setup(props, { attrs, slots }) {
22
+ const dispatch = useAppDispatch();
23
+ const isControlled = computed(() => props.activeIndex !== -1);
24
+ const activeIndex = ref(props.activeIndex);
25
+ watch(() => props.activeIndex, (val) => {
26
+ activeIndex.value = val;
24
27
  });
25
- let O = _(() => ({
26
- data: g.data,
27
- dataKey: g.dataKey,
28
- nameKey: g.nameKey,
29
- cx: g.cx,
30
- cy: g.cy,
31
- innerRadius: g.innerRadius,
32
- outerRadius: g.outerRadius,
33
- startAngle: g.startAngle,
34
- endAngle: g.endAngle,
35
- paddingAngle: g.paddingAngle,
36
- minAngle: g.minAngle,
37
- fill: g.fill,
38
- legendType: g.legendType,
39
- tooltipType: g.tooltipType,
28
+ const pieSettings = computed(() => ({
29
+ data: props.data,
30
+ dataKey: props.dataKey,
31
+ nameKey: props.nameKey,
32
+ cx: props.cx,
33
+ cy: props.cy,
34
+ innerRadius: props.innerRadius,
35
+ outerRadius: props.outerRadius,
36
+ startAngle: props.startAngle,
37
+ endAngle: props.endAngle,
38
+ paddingAngle: props.paddingAngle,
39
+ minAngle: props.minAngle,
40
+ fill: props.fill,
41
+ legendType: props.legendType,
42
+ tooltipType: props.tooltipType,
40
43
  presentationProps: {}
41
44
  }));
42
- c(_(() => ({
45
+ SetPolarGraphicalItem(computed(() => ({
43
46
  type: "pie",
44
- data: g.data ?? [],
45
- dataKey: g.dataKey,
46
- hide: g.hide,
47
+ data: props.data ?? [],
48
+ dataKey: props.dataKey,
49
+ hide: props.hide,
47
50
  angleAxisId: 0,
48
51
  radiusAxisId: 0
49
52
  })));
50
- let k = a((e) => p(e, O.value)), A = a((e) => h(e, O.value)), j = a((t) => e(t)), M = a((e) => m(e, O.value));
51
- l(_(() => M.value ?? []));
52
- let N = _(() => {
53
- if (!(A.value == null || k.value == null)) return f({
54
- offset: j.value,
55
- pieSettings: O.value,
56
- displayedData: k.value
53
+ const displayedData = useAppSelector((state) => selectDisplayedData(state, pieSettings.value));
54
+ const synchronisedSettings = useAppSelector((state) => selectSynchronisedPieSettings(state, pieSettings.value));
55
+ const offset = useAppSelector((state) => selectChartOffset(state));
56
+ const legendPayload = useAppSelector((state) => selectPieLegend(state, pieSettings.value));
57
+ SetLegendPayload(computed(() => legendPayload.value ?? []));
58
+ const sectors = computed(() => {
59
+ if (synchronisedSettings.value == null || displayedData.value == null) return;
60
+ return computePieSectors({
61
+ offset: offset.value,
62
+ pieSettings: pieSettings.value,
63
+ displayedData: displayedData.value
57
64
  });
58
65
  });
59
- u({
60
- fn: (e) => e,
61
- args: _(() => ({
62
- dataDefinedOnItem: k.value ?? [],
63
- positions: N.value?.map((e) => e.tooltipPosition),
66
+ SetTooltipEntrySettings({
67
+ fn: (v) => v,
68
+ args: computed(() => ({
69
+ dataDefinedOnItem: displayedData.value ?? [],
70
+ positions: sectors.value?.map((s) => s.tooltipPosition),
64
71
  settings: {
65
- dataKey: g.dataKey,
66
- nameKey: g.nameKey,
67
- name: String(g.dataKey ?? ""),
68
- hide: g.hide,
69
- type: g.tooltipType,
70
- color: g.fill,
71
- fill: g.fill,
72
- stroke: g.stroke,
72
+ dataKey: props.dataKey,
73
+ nameKey: props.nameKey,
74
+ name: String(props.dataKey ?? ""),
75
+ hide: props.hide,
76
+ type: props.tooltipType,
77
+ color: props.fill,
78
+ fill: props.fill,
79
+ stroke: props.stroke,
73
80
  unit: ""
74
81
  }
75
82
  }))
76
83
  });
77
- function P(e, t) {
78
- E.value || (D.value = t), T(r({
79
- activeIndex: String(t),
80
- activeDataKey: g.dataKey,
81
- activeCoordinate: e.tooltipPosition
84
+ function handleSectorEnter(sector, index) {
85
+ if (!isControlled.value) activeIndex.value = index;
86
+ dispatch(setActiveMouseOverItemIndex({
87
+ activeIndex: String(index),
88
+ activeDataKey: props.dataKey,
89
+ activeCoordinate: sector.tooltipPosition
82
90
  }));
83
91
  }
84
- function F() {
85
- E.value || (D.value = -1), T(n());
92
+ function handleSectorLeave() {
93
+ if (!isControlled.value) activeIndex.value = -1;
94
+ dispatch(mouseLeaveItem());
86
95
  }
87
- function I(e, n) {
88
- let r = t(e.cx, e.cy, e.outerRadius, e.midAngle), i = t(e.cx, e.cy, e.outerRadius + C, e.midAngle), a = i.x > e.cx ? "start" : i.x < e.cx ? "end" : "middle";
89
- return v("g", { key: `label-${n}` }, [v("line", {
90
- x1: r.x,
91
- y1: r.y,
92
- x2: i.x,
93
- y2: i.y,
94
- stroke: e.fill,
95
- fill: "none"
96
- }, null), v("text", {
97
- x: i.x,
98
- y: i.y,
99
- "text-anchor": a,
96
+ function renderLabel(sector, index) {
97
+ const edgePoint = polarToCartesian(sector.cx, sector.cy, sector.outerRadius, sector.midAngle);
98
+ const pos = polarToCartesian(sector.cx, sector.cy, sector.outerRadius + LABEL_OFFSET, sector.midAngle);
99
+ const anchor = pos.x > sector.cx ? "start" : pos.x < sector.cx ? "end" : "middle";
100
+ return createVNode("g", { "key": `label-${index}` }, [createVNode("line", {
101
+ "x1": edgePoint.x,
102
+ "y1": edgePoint.y,
103
+ "x2": pos.x,
104
+ "y2": pos.y,
105
+ "stroke": sector.fill,
106
+ "fill": "none"
107
+ }, null), createVNode("text", {
108
+ "x": pos.x,
109
+ "y": pos.y,
110
+ "text-anchor": anchor,
100
111
  "dominant-baseline": "middle",
101
- fill: e.fill
102
- }, [String(e.value)])]);
112
+ "fill": sector.fill
113
+ }, [String(sector.value)])]);
103
114
  }
104
115
  return () => {
105
- let e = N.value;
106
- if (!e || e.length === 0) return null;
107
- let t = y.stroke ?? g.stroke;
108
- return v(o, { class: ["v-charts-pie", g.className] }, { default: () => [v(s, {
109
- isActive: g.isAnimationActive,
110
- from: 0,
111
- to: 1,
112
- transition: { duration: 1.5 }
113
- }, { default: (n) => {
114
- let r = e[0]?.startAngle ?? 0, i = e.map((e, i) => {
115
- let a = i > 0 ? e.paddingAngle : 0, o = (e.endAngle - e.startAngle) * n, s = r + a, c = r + o + a;
116
- r = c;
117
- let l = w.shape ? w.shape({
118
- ...e,
119
- startAngle: s,
120
- endAngle: c,
121
- stroke: t,
122
- isActive: D.value === i
123
- }) : v(d, b(y, {
124
- cx: e.cx,
125
- cy: e.cy,
126
- innerRadius: e.innerRadius,
127
- outerRadius: e.outerRadius,
128
- startAngle: s,
129
- endAngle: c,
130
- fill: e.fill,
131
- stroke: t
116
+ const sectorList = sectors.value;
117
+ if (!sectorList || sectorList.length === 0) return null;
118
+ const stroke = attrs.stroke ?? props.stroke;
119
+ return createVNode(Layer, { "class": ["v-charts-pie", props.className] }, { default: () => [createVNode(Animate, {
120
+ "isActive": props.isAnimationActive,
121
+ "from": 0,
122
+ "to": 1,
123
+ "transition": { duration: 1.5 }
124
+ }, { default: (progress) => {
125
+ let curAngle = sectorList[0]?.startAngle ?? 0;
126
+ const sectorNodes = sectorList.map((sector, i) => {
127
+ const paddingAngle = i > 0 ? sector.paddingAngle : 0;
128
+ const deltaAngle = (sector.endAngle - sector.startAngle) * progress;
129
+ const animatedStartAngle = curAngle + paddingAngle;
130
+ const animatedEndAngle = curAngle + deltaAngle + paddingAngle;
131
+ curAngle = animatedEndAngle;
132
+ const content = slots.shape ? slots.shape({
133
+ ...sector,
134
+ startAngle: animatedStartAngle,
135
+ endAngle: animatedEndAngle,
136
+ stroke,
137
+ isActive: activeIndex.value === i
138
+ }) : createVNode(Sector, mergeProps(attrs, {
139
+ "cx": sector.cx,
140
+ "cy": sector.cy,
141
+ "innerRadius": sector.innerRadius,
142
+ "outerRadius": sector.outerRadius,
143
+ "startAngle": animatedStartAngle,
144
+ "endAngle": animatedEndAngle,
145
+ "fill": sector.fill,
146
+ "stroke": stroke
132
147
  }), null);
133
- return v("g", {
134
- key: `sector-${i}`,
135
- onMouseenter: () => P(e, i),
136
- onMouseleave: F
137
- }, [l]);
148
+ return createVNode("g", {
149
+ "key": `sector-${i}`,
150
+ "onMouseenter": () => handleSectorEnter(sector, i),
151
+ "onMouseleave": handleSectorLeave
152
+ }, [content]);
138
153
  });
139
- return n >= 1 && g.label && i.push(...e.map(I)), i;
154
+ if (progress >= 1 && props.label) sectorNodes.push(...sectorList.map(renderLabel));
155
+ return sectorNodes;
140
156
  } })] });
141
157
  };
142
158
  }
143
159
  });
144
160
  //#endregion
145
- export { w as Pie };
161
+ export { Pie };
@@ -1,5 +1,5 @@
1
1
  //#region src/polar/pie/type.ts
2
- var e = {
2
+ var PieVueProps = {
3
3
  data: {
4
4
  type: Array,
5
5
  default: void 0
@@ -10,7 +10,7 @@ var e = {
10
10
  Number,
11
11
  Function
12
12
  ],
13
- required: !0
13
+ required: true
14
14
  },
15
15
  nameKey: {
16
16
  type: [
@@ -74,7 +74,7 @@ var e = {
74
74
  },
75
75
  hide: {
76
76
  type: Boolean,
77
- default: !1
77
+ default: false
78
78
  },
79
79
  activeIndex: {
80
80
  type: Number,
@@ -82,11 +82,11 @@ var e = {
82
82
  },
83
83
  isAnimationActive: {
84
84
  type: Boolean,
85
- default: !0
85
+ default: true
86
86
  },
87
87
  label: {
88
88
  type: Boolean,
89
- default: !1
89
+ default: false
90
90
  },
91
91
  className: {
92
92
  type: String,
@@ -94,4 +94,4 @@ var e = {
94
94
  }
95
95
  };
96
96
  //#endregion
97
- export { e as PieVueProps };
97
+ export { PieVueProps };
@@ -1,21 +1,26 @@
1
- import { RADIAN as e, polarToCartesian as t } from "../../utils/polar.mjs";
2
- import { selectPolarViewBox as n } from "../../state/selectors/polarAxisSelectors.mjs";
3
- import { useAppDispatch as r, useAppSelector as i } from "../../state/hooks.mjs";
4
- import a from "../../components/Text.mjs";
5
- import { addAngleAxis as o, removeAngleAxis as s } from "../../state/polarAxisSlice.mjs";
6
- import { selectPolarAxisTicks as c } from "../../state/selectors/polarScaleSelectors.mjs";
7
- import { createVNode as l, defineComponent as u, onUnmounted as d, watchEffect as f } from "vue";
1
+ import { RADIAN, polarToCartesian } from "../../utils/polar.mjs";
2
+ import { selectPolarViewBox } from "../../state/selectors/polarAxisSelectors.mjs";
3
+ import { useAppDispatch, useAppSelector } from "../../state/hooks.mjs";
4
+ import Text_default from "../../components/Text.mjs";
5
+ import { addAngleAxis, removeAngleAxis } from "../../state/polarAxisSlice.mjs";
6
+ import { selectPolarAxisTicks } from "../../state/selectors/polarScaleSelectors.mjs";
7
+ import { createVNode, defineComponent, onUnmounted, watchEffect } from "vue";
8
8
  //#region src/polar/radar/PolarAngleAxis.tsx
9
- var p = 1e-5, m = Math.cos(45 * e);
10
- function h(t, n) {
11
- let r = Math.cos(-t * e);
12
- return r > p ? n === "outer" ? "start" : "end" : r < -p ? n === "outer" ? "end" : "start" : "middle";
9
+ var eps = 1e-5;
10
+ var COS_45 = Math.cos(45 * RADIAN);
11
+ function getTickTextAnchor(coordinate, orientation) {
12
+ const cos = Math.cos(-coordinate * RADIAN);
13
+ if (cos > eps) return orientation === "outer" ? "start" : "end";
14
+ if (cos < -eps) return orientation === "outer" ? "end" : "start";
15
+ return "middle";
13
16
  }
14
- function g(t) {
15
- let n = Math.cos(-t * e), r = Math.sin(-t * e);
16
- return Math.abs(n) <= m ? r > 0 ? "start" : "end" : "middle";
17
+ function getTickVerticalAnchor(coordinate) {
18
+ const cos = Math.cos(-coordinate * RADIAN);
19
+ const sin = Math.sin(-coordinate * RADIAN);
20
+ if (Math.abs(cos) <= COS_45) return sin > 0 ? "start" : "end";
21
+ return "middle";
17
22
  }
18
- var _ = /* @__PURE__ */ u({
23
+ var PolarAngleAxis = /* @__PURE__ */ defineComponent({
19
24
  name: "PolarAngleAxis",
20
25
  props: {
21
26
  angleAxisId: {
@@ -32,11 +37,11 @@ var _ = /* @__PURE__ */ u({
32
37
  },
33
38
  tick: {
34
39
  type: Boolean,
35
- default: !0
40
+ default: true
36
41
  },
37
42
  tickLine: {
38
43
  type: Boolean,
39
- default: !0
44
+ default: true
40
45
  },
41
46
  tickSize: {
42
47
  type: Number,
@@ -44,7 +49,7 @@ var _ = /* @__PURE__ */ u({
44
49
  },
45
50
  axisLine: {
46
51
  type: Boolean,
47
- default: !0
52
+ default: true
48
53
  },
49
54
  axisLineType: {
50
55
  type: String,
@@ -80,82 +85,96 @@ var _ = /* @__PURE__ */ u({
80
85
  }
81
86
  },
82
87
  slots: Object,
83
- setup(e, { slots: u }) {
84
- let p = r(), m = null;
85
- f(() => {
86
- let t = {
87
- id: e.angleAxisId,
88
- type: e.type,
89
- dataKey: e.dataKey,
88
+ setup(props, { slots }) {
89
+ const dispatch = useAppDispatch();
90
+ let prevSettings = null;
91
+ watchEffect(() => {
92
+ const settings = {
93
+ id: props.angleAxisId,
94
+ type: props.type,
95
+ dataKey: props.dataKey,
90
96
  scale: "auto",
91
- allowDuplicatedCategory: !0,
92
- allowDataOverflow: !1,
93
- reversed: !1,
94
- includeHidden: !1,
95
- domain: e.domain,
97
+ allowDuplicatedCategory: true,
98
+ allowDataOverflow: false,
99
+ reversed: false,
100
+ includeHidden: false,
101
+ domain: props.domain,
96
102
  unit: void 0,
97
103
  name: void 0,
98
- allowDecimals: !1,
99
- tickCount: e.tickCount,
100
- ticks: e.ticks,
101
- tick: e.tick
104
+ allowDecimals: false,
105
+ tickCount: props.tickCount,
106
+ ticks: props.ticks,
107
+ tick: props.tick
102
108
  };
103
- p(o(t)), m = t;
104
- }), d(() => {
105
- m &&= (p(s(m)), null);
109
+ dispatch(addAngleAxis(settings));
110
+ prevSettings = settings;
106
111
  });
107
- let _ = i((e) => n(e)), v = i((t) => c(t, "angleAxis", e.angleAxisId, !1));
112
+ onUnmounted(() => {
113
+ if (prevSettings) {
114
+ dispatch(removeAngleAxis(prevSettings));
115
+ prevSettings = null;
116
+ }
117
+ });
118
+ const polarViewBox = useAppSelector((state) => selectPolarViewBox(state));
119
+ const ticks = useAppSelector((state) => selectPolarAxisTicks(state, "angleAxis", props.angleAxisId, false));
108
120
  return () => {
109
- let n = _.value, r = v.value;
110
- if (n == null || r == null || r.length === 0) return null;
111
- let { cx: i, cy: o, outerRadius: s, startAngle: c, endAngle: d } = n, { orientation: f, tickSize: p, axisLine: m, axisLineType: y, tickLine: b, tick: x, tickFormatter: S, stroke: C } = e, w = Math.abs((d ?? 0) - (c ?? 0)) === 360 && r.length > 1 && Math.abs(r[r.length - 1].coordinate - r[0].coordinate) % 360 == 0 ? r.slice(0, -1) : r;
112
- return l("g", { class: "v-charts-polar-angle-axis" }, [m && (y === "circle" ? l("circle", {
113
- cx: i,
114
- cy: o,
115
- r: s,
116
- fill: "none",
117
- stroke: C
118
- }, null) : l("polygon", {
119
- points: w.map((e) => {
120
- let n = t(i, o, s, e.coordinate);
121
- return `${n.x},${n.y}`;
121
+ const viewBox = polarViewBox.value;
122
+ const tickItems = ticks.value;
123
+ if (viewBox == null || tickItems == null || tickItems.length === 0) return null;
124
+ const { cx, cy, outerRadius: radius, startAngle: vbStart, endAngle: vbEnd } = viewBox;
125
+ const { orientation, tickSize, axisLine, axisLineType, tickLine, tick, tickFormatter, stroke } = props;
126
+ const filteredTicks = Math.abs((vbEnd ?? 0) - (vbStart ?? 0)) === 360 && tickItems.length > 1 && Math.abs(tickItems[tickItems.length - 1].coordinate - tickItems[0].coordinate) % 360 === 0 ? tickItems.slice(0, -1) : tickItems;
127
+ return createVNode("g", { "class": "v-charts-polar-angle-axis" }, [axisLine && (axisLineType === "circle" ? createVNode("circle", {
128
+ "cx": cx,
129
+ "cy": cy,
130
+ "r": radius,
131
+ "fill": "none",
132
+ "stroke": stroke
133
+ }, null) : createVNode("polygon", {
134
+ "points": filteredTicks.map((t) => {
135
+ const p = polarToCartesian(cx, cy, radius, t.coordinate);
136
+ return `${p.x},${p.y}`;
122
137
  }).join(" "),
123
- fill: "none",
124
- stroke: C
125
- }, null)), l("g", { class: "v-charts-polar-angle-axis-ticks" }, [w.map((e, n) => {
126
- let r = t(i, o, s, e.coordinate), c = t(i, o, s + (f === "inner" ? -1 : 1) * p, e.coordinate), d = h(e.coordinate, f), m = g(e.coordinate), _ = S ? S(e.value, n) : e.value;
127
- return l("g", {
128
- key: `tick-${e.coordinate}`,
129
- class: "v-charts-polar-angle-axis-tick"
130
- }, [b && l("line", {
131
- class: "v-charts-polar-angle-axis-tick-line",
132
- x1: r.x,
133
- y1: r.y,
134
- x2: c.x,
135
- y2: c.y,
136
- stroke: C,
137
- fill: "none"
138
- }, null), x && (u.tick ? u.tick({
139
- x: c.x,
140
- y: c.y,
141
- value: _,
142
- index: n,
143
- textAnchor: d,
144
- payload: e,
145
- cx: i,
146
- cy: o
147
- }) : l(a, {
148
- class: "v-charts-polar-angle-axis-tick-value",
149
- x: c.x,
150
- y: c.y,
151
- textAnchor: d,
152
- verticalAnchor: m,
153
- fill: C,
154
- value: String(_)
138
+ "fill": "none",
139
+ "stroke": stroke
140
+ }, null)), createVNode("g", { "class": "v-charts-polar-angle-axis-ticks" }, [filteredTicks.map((entry, i) => {
141
+ const p1 = polarToCartesian(cx, cy, radius, entry.coordinate);
142
+ const p2 = polarToCartesian(cx, cy, radius + (orientation === "inner" ? -1 : 1) * tickSize, entry.coordinate);
143
+ const textAnchor = getTickTextAnchor(entry.coordinate, orientation);
144
+ const verticalAnchor = getTickVerticalAnchor(entry.coordinate);
145
+ const value = tickFormatter ? tickFormatter(entry.value, i) : entry.value;
146
+ return createVNode("g", {
147
+ "key": `tick-${entry.coordinate}`,
148
+ "class": "v-charts-polar-angle-axis-tick"
149
+ }, [tickLine && createVNode("line", {
150
+ "class": "v-charts-polar-angle-axis-tick-line",
151
+ "x1": p1.x,
152
+ "y1": p1.y,
153
+ "x2": p2.x,
154
+ "y2": p2.y,
155
+ "stroke": stroke,
156
+ "fill": "none"
157
+ }, null), tick && (slots.tick ? slots.tick({
158
+ x: p2.x,
159
+ y: p2.y,
160
+ value,
161
+ index: i,
162
+ textAnchor,
163
+ payload: entry,
164
+ cx,
165
+ cy
166
+ }) : createVNode(Text_default, {
167
+ "class": "v-charts-polar-angle-axis-tick-value",
168
+ "x": p2.x,
169
+ "y": p2.y,
170
+ "textAnchor": textAnchor,
171
+ "verticalAnchor": verticalAnchor,
172
+ "fill": stroke,
173
+ "value": String(value)
155
174
  }, null))]);
156
175
  })])]);
157
176
  };
158
177
  }
159
178
  });
160
179
  //#endregion
161
- export { _ as PolarAngleAxis };
180
+ export { PolarAngleAxis };