@primeui/vue-chart 0.0.1-alpha.1 → 1.0.0-beta.1

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 (176) hide show
  1. package/dist/CartesianRenderer.rich.spec.d.ts +1 -0
  2. package/dist/Chart.features.spec.d.ts +1 -0
  3. package/dist/Chart.interactions.spec.d.ts +1 -0
  4. package/dist/Chart.pointEvents.spec.d.ts +1 -0
  5. package/dist/Chart.vue.d.ts +5 -1
  6. package/dist/ChartCanvas.mjs +15 -14
  7. package/dist/ChartCanvas.pipeline.spec.d.ts +1 -0
  8. package/dist/ChartCanvas.vue.d.ts +8 -4
  9. package/dist/ChartGroup.sync.spec.d.ts +1 -0
  10. package/dist/ChartLegend.spec.d.ts +1 -0
  11. package/dist/ChartSvg.containers.spec.d.ts +1 -0
  12. package/dist/ChartSvg.declarative.spec.d.ts +1 -0
  13. package/dist/ChartSvg.export-menu.spec.d.ts +1 -0
  14. package/dist/ChartSvg.hover.spec.d.ts +1 -0
  15. package/dist/ChartSvg.mjs +15 -14
  16. package/dist/ChartSvg.renderers.spec.d.ts +1 -0
  17. package/dist/ChartSvg.vue.d.ts +8 -4
  18. package/dist/ColorLegendRenderer.branches.spec.d.ts +1 -0
  19. package/dist/ColorLegendRenderer.spec.d.ts +1 -0
  20. package/dist/LegendRenderer.spec.d.ts +1 -0
  21. package/dist/NavigatorRenderer.spec.d.ts +1 -0
  22. package/dist/RadialHeatmap.rich.spec.d.ts +1 -0
  23. package/dist/TooltipRenderer.spec.d.ts +1 -0
  24. package/dist/{chunk-6S4JMPKC.mjs → chunks/chunk-2NZ3PUWW.mjs} +2 -2
  25. package/dist/{chunk-RRHYGSK6.mjs → chunks/chunk-2TOEQNJ6.mjs} +2 -2
  26. package/dist/{chunk-GX2MK6VT.mjs → chunks/chunk-36DHPBYP.mjs} +25 -23
  27. package/dist/{chunk-RSTIA3KM.mjs → chunks/chunk-3DINEX6C.mjs} +2 -1
  28. package/dist/{chunk-PJVOZSPF.mjs → chunks/chunk-3JA5JAHF.mjs} +2 -2
  29. package/dist/{chunk-KOWFD2AE.mjs → chunks/chunk-3PJULFR5.mjs} +22 -21
  30. package/dist/chunks/chunk-3X27K5XC.mjs +236 -0
  31. package/dist/chunks/chunk-3XOLEGDL.mjs +182 -0
  32. package/dist/{chunk-PSSXPTLQ.mjs → chunks/chunk-4SLSYRNY.mjs} +6 -6
  33. package/dist/chunks/chunk-4VWFG6HM.mjs +86 -0
  34. package/dist/{chunk-44BAFHPK.mjs → chunks/chunk-5HLEKAY2.mjs} +10 -5
  35. package/dist/{chunk-4NJ2PSHV.mjs → chunks/chunk-5ZLVNQ2L.mjs} +7 -4
  36. package/dist/{chunk-O6L3PNFC.mjs → chunks/chunk-6Z4MZIJI.mjs} +2 -2
  37. package/dist/chunks/chunk-7EZEZMGG.mjs +22 -0
  38. package/dist/chunks/chunk-ADAGGXFG.mjs +166 -0
  39. package/dist/{chunk-YRKAI2R2.mjs → chunks/chunk-AKMQHU5T.mjs} +15 -14
  40. package/dist/{chunk-ZRCOVQQM.mjs → chunks/chunk-BSROML7P.mjs} +2 -2
  41. package/dist/{chunk-WYV2MHP6.mjs → chunks/chunk-CGFPDWB4.mjs} +1 -1
  42. package/dist/{chunk-4CRHCZV3.mjs → chunks/chunk-CMJXLIEY.mjs} +125 -9
  43. package/dist/{chunk-42J32DPD.mjs → chunks/chunk-CRIB3I3L.mjs} +1 -1
  44. package/dist/{chunk-WKSQR6L5.mjs → chunks/chunk-CW2KYVYO.mjs} +31 -8
  45. package/dist/{chunk-644ROAHU.mjs → chunks/chunk-DDRSIMLE.mjs} +33 -12
  46. package/dist/{chunk-32XIRBZ7.mjs → chunks/chunk-DXKAPWMO.mjs} +2 -2
  47. package/dist/{chunk-372K2BMN.mjs → chunks/chunk-EKGCPOZJ.mjs} +56 -15
  48. package/dist/{chunk-E2U4W5FW.mjs → chunks/chunk-F7EK5D6J.mjs} +11 -11
  49. package/dist/{chunk-ZHFL3RYO.mjs → chunks/chunk-GE2Y2FHS.mjs} +6 -6
  50. package/dist/{chunk-AAX7FOW3.mjs → chunks/chunk-GIDIMIWE.mjs} +11 -11
  51. package/dist/{chunk-NLXOJSKK.mjs → chunks/chunk-GLFXRR7N.mjs} +29 -5
  52. package/dist/{chunk-W5M3BR6N.mjs → chunks/chunk-GV3CY6CQ.mjs} +1 -1
  53. package/dist/{chunk-CDXF6ZTL.mjs → chunks/chunk-HH5FUUXX.mjs} +1 -1
  54. package/dist/{chunk-RQURY2H3.mjs → chunks/chunk-HHZFGQN2.mjs} +2 -2
  55. package/dist/{chunk-2D3PWFR2.mjs → chunks/chunk-HVLFOABV.mjs} +4 -4
  56. package/dist/chunks/chunk-I2BWSDNR.mjs +832 -0
  57. package/dist/{chunk-MDA22SIZ.mjs → chunks/chunk-IFZSHQDZ.mjs} +2 -2
  58. package/dist/chunks/chunk-IRGQNA5W.mjs +289 -0
  59. package/dist/{chunk-72KINEJ6.mjs → chunks/chunk-IUGMS7ND.mjs} +10 -5
  60. package/dist/{chunk-56NMBNNX.mjs → chunks/chunk-JPKNWLLP.mjs} +3 -3
  61. package/dist/{chunk-XBDNMPF7.mjs → chunks/chunk-JVH4MDKX.mjs} +2 -2
  62. package/dist/chunks/chunk-KNNYJD4D.mjs +14 -0
  63. package/dist/{chunk-AUI5R4DA.mjs → chunks/chunk-L73MEG22.mjs} +2 -2
  64. package/dist/{chunk-K326BBF7.mjs → chunks/chunk-L74BEYTD.mjs} +38 -17
  65. package/dist/{chunk-DYVFVVTO.mjs → chunks/chunk-LJZCE7LQ.mjs} +102 -6
  66. package/dist/{chunk-YGHWUR7K.mjs → chunks/chunk-LP2YESP6.mjs} +1 -1
  67. package/dist/{chunk-WA735Y26.mjs → chunks/chunk-MGUGO3RV.mjs} +1 -1
  68. package/dist/{chunk-DOOXGOOB.mjs → chunks/chunk-OJHEN5FG.mjs} +96 -5
  69. package/dist/{chunk-ZNINPVG7.mjs → chunks/chunk-ON2FAZTD.mjs} +1 -1
  70. package/dist/{chunk-DLUFOM5K.mjs → chunks/chunk-PCBF6FSQ.mjs} +11 -11
  71. package/dist/{chunk-FQTWLAVA.mjs → chunks/chunk-QJCMFAHB.mjs} +1 -1
  72. package/dist/{chunk-62NGBLQ7.mjs → chunks/chunk-QONZ3SCZ.mjs} +1 -1
  73. package/dist/{chunk-HANSF33Z.mjs → chunks/chunk-QOWKMWNO.mjs} +1 -1
  74. package/dist/{chunk-GA4VV5V4.mjs → chunks/chunk-R4AZOPXC.mjs} +1 -1
  75. package/dist/{chunk-5DWO3G33.mjs → chunks/chunk-SGLTVJUA.mjs} +35 -21
  76. package/dist/{chunk-5FTUGKPC.mjs → chunks/chunk-TRGN3ZMM.mjs} +5 -5
  77. package/dist/{chunk-RSAZ7V5Z.mjs → chunks/chunk-TZ23VBFU.mjs} +2 -2
  78. package/dist/{chunk-4UVPCLJ7.mjs → chunks/chunk-U6X3GVJ3.mjs} +1 -1
  79. package/dist/{chunk-J2P5JBHC.mjs → chunks/chunk-UOMQNZMT.mjs} +1 -1
  80. package/dist/{chunk-4THCGGER.mjs → chunks/chunk-UOZFNTVQ.mjs} +2 -2
  81. package/dist/{chunk-TIV2FI4S.mjs → chunks/chunk-WVNDZNMV.mjs} +2 -2
  82. package/dist/{chunk-GFC24374.mjs → chunks/chunk-X4NWFK7L.mjs} +5 -5
  83. package/dist/{chunk-FFBK7Q3W.mjs → chunks/chunk-YI3GLQYF.mjs} +67 -4
  84. package/dist/{chunk-HTZVV6VV.mjs → chunks/chunk-YZQS2YBK.mjs} +8 -6
  85. package/dist/{chunk-PQV55JYI.mjs → chunks/chunk-ZLD5VNMP.mjs} +2 -2
  86. package/dist/components/charts/ChartBar.mjs +13 -13
  87. package/dist/components/charts/ChartCandlestick.mjs +11 -11
  88. package/dist/components/charts/ChartHeatmap.mjs +11 -11
  89. package/dist/components/charts/ChartLine.mjs +12 -11
  90. package/dist/components/charts/ChartPie.mjs +12 -11
  91. package/dist/components/charts/ChartPolar.mjs +13 -11
  92. package/dist/components/charts/ChartRadar.mjs +13 -11
  93. package/dist/components/charts/ChartScatter.mjs +12 -11
  94. package/dist/components/charts/ChartTreemap.mjs +10 -10
  95. package/dist/components/containers/ChartDecimation.mjs +6 -6
  96. package/dist/components/containers/ChartGroup.mjs +4 -4
  97. package/dist/components/containers/ChartOverlap.mjs +5 -5
  98. package/dist/components/containers/ChartRange.mjs +6 -6
  99. package/dist/components/containers/ChartStacked.mjs +6 -6
  100. package/dist/components/containers/ChartWaterfall.mjs +5 -5
  101. package/dist/components/customizations/ChartAccessibility.mjs +9 -9
  102. package/dist/components/customizations/ChartAnnotation.mjs +5 -5
  103. package/dist/components/customizations/ChartAxisCategory.mjs +3 -3
  104. package/dist/components/customizations/ChartAxisGroup.mjs +3 -3
  105. package/dist/components/customizations/ChartBreadcrumb.mjs +6 -6
  106. package/dist/components/customizations/ChartCaption.mjs +9 -9
  107. package/dist/components/customizations/ChartColorLegend.mjs +9 -9
  108. package/dist/components/customizations/ChartDataLabels.mjs +9 -9
  109. package/dist/components/customizations/ChartExportMenu.mjs +9 -9
  110. package/dist/components/customizations/ChartHover.mjs +9 -9
  111. package/dist/components/customizations/ChartLegend.mjs +9 -9
  112. package/dist/components/customizations/ChartNavigator.mjs +10 -10
  113. package/dist/components/customizations/ChartReferenceBand.mjs +5 -5
  114. package/dist/components/customizations/ChartReferenceLine.mjs +5 -5
  115. package/dist/components/customizations/ChartResponsive.mjs +9 -9
  116. package/dist/components/customizations/ChartTitle.mjs +9 -9
  117. package/dist/components/customizations/ChartTooltip.mjs +9 -9
  118. package/dist/components/customizations/ChartXAxis.mjs +10 -10
  119. package/dist/components/customizations/ChartYAxis.mjs +10 -10
  120. package/dist/components/customizations/ChartZoom.mjs +9 -9
  121. package/dist/components/items/ChartItem.mjs +3 -3
  122. package/dist/components/items/ChartTreemapGroup.mjs +5 -5
  123. package/dist/components/renderers/CartesianRenderer.mjs +9 -9
  124. package/dist/components/renderers/CartesianRenderer.vue.d.ts +2 -0
  125. package/dist/components/renderers/ColorLegendRenderer.mjs +2 -2
  126. package/dist/components/renderers/LegendRenderer.mjs +3 -3
  127. package/dist/components/renderers/NavigatorRenderer.mjs +5 -5
  128. package/dist/components/renderers/RadialRenderer.mjs +9 -9
  129. package/dist/components/renderers/RadialRenderer.vue.d.ts +1 -1
  130. package/dist/components/renderers/RectRenderer.mjs +9 -9
  131. package/dist/components/renderers/RectRenderer.vue.d.ts +1 -1
  132. package/dist/components/renderers/TooltipRenderer.mjs +4 -4
  133. package/dist/components/renderers/layers/BarLayerCanvas.mjs +10 -10
  134. package/dist/components/renderers/layers/BarLayerSvg.mjs +10 -10
  135. package/dist/components/renderers/layers/CandlestickLayer.mjs +9 -9
  136. package/dist/components/renderers/layers/HeatmapLayer.mjs +9 -9
  137. package/dist/components/renderers/layers/LineLayer.mjs +10 -9
  138. package/dist/components/renderers/layers/PieLayer.mjs +7 -9
  139. package/dist/components/renderers/layers/PolarLayer.mjs +8 -9
  140. package/dist/components/renderers/layers/RadarLayer.mjs +8 -9
  141. package/dist/components/renderers/layers/ScatterLayer.mjs +10 -9
  142. package/dist/composables/index.d.ts +0 -8
  143. package/dist/composables/useAnimationProps.d.ts +2 -5
  144. package/dist/composables/useChartSync.spec.d.ts +1 -0
  145. package/dist/composables/useChartSyncCoordinator.spec.d.ts +1 -0
  146. package/dist/composables/useHeatmapRenderer.spec.d.ts +1 -0
  147. package/dist/composables/usePolarRenderer.spec.d.ts +1 -0
  148. package/dist/composables/useResponsiveConfig.d.ts +1 -1
  149. package/dist/composables/useResponsiveDimensions.spec.d.ts +1 -0
  150. package/dist/composables/useTreemapRenderer.spec.d.ts +1 -0
  151. package/dist/context/ChartContext.d.ts +1 -1
  152. package/dist/index.d.ts +2 -1
  153. package/dist/index.mjs +69 -66
  154. package/dist/namespace.mjs +69 -112
  155. package/dist/types/animation.types.d.ts +2 -0
  156. package/dist/types/bar.types.d.ts +2 -1
  157. package/dist/types/candlestick.types.d.ts +0 -1
  158. package/dist/types/heatmap.types.d.ts +0 -1
  159. package/dist/types/index.d.ts +1 -1
  160. package/dist/types/item.types.d.ts +0 -1
  161. package/dist/types/line.types.d.ts +4 -1
  162. package/dist/types/scatter.types.d.ts +3 -2
  163. package/dist/useChartContext.spec.d.ts +1 -0
  164. package/package.json +7 -7
  165. package/dist/chunk-54DLUFIA.mjs +0 -96
  166. package/dist/chunk-CQHNYT2V.mjs +0 -1692
  167. package/dist/chunk-JKK3D33U.mjs +0 -64
  168. package/dist/chunk-UO27BCRL.mjs +0 -86
  169. package/dist/chunk-VWABO23U.mjs +0 -143
  170. /package/dist/{chunk-FZ3PZ66C.mjs → chunks/chunk-4Q3QUNX6.mjs} +0 -0
  171. /package/dist/{chunk-5SRBQVU5.mjs → chunks/chunk-EHSDNH7K.mjs} +0 -0
  172. /package/dist/{chunk-LD57I4SY.mjs → chunks/chunk-H4HLHGUW.mjs} +0 -0
  173. /package/dist/{chunk-TEOO4OLV.mjs → chunks/chunk-L6N5IYAJ.mjs} +0 -0
  174. /package/dist/{chunk-E4ROAOPT.mjs → chunks/chunk-S4YR4YK7.mjs} +0 -0
  175. /package/dist/{chunk-7P6ASYW6.mjs → chunks/chunk-VIHIR2BE.mjs} +0 -0
  176. /package/dist/{chunk-J43KLCZF.mjs → chunks/chunk-ZH4A4L6W.mjs} +0 -0
@@ -1,1692 +0,0 @@
1
- import { STACKED_CONTEXT_KEY, RANGE_CONTEXT_KEY } from './chunk-TEOO4OLV.mjs';
2
- import { useCustomizationRegistration, useChartRefreshHook } from './chunk-PQV55JYI.mjs';
3
- import { normalizeDataLabelConfig } from './chunk-J43KLCZF.mjs';
4
- import { useChartMethods } from './chunk-HANSF33Z.mjs';
5
- import { SYNC_BUS_KEY } from './chunk-LD57I4SY.mjs';
6
- import { ITEM_COLLECTOR_KEY } from './chunk-FZ3PZ66C.mjs';
7
- import { getCurrentInstance, computed, ref, watch, onUnmounted, toValue, watchEffect, inject, shallowRef, onMounted, onScopeDispose, shallowReactive, provide, onBeforeUnmount, createVNode, h, unref } from 'vue';
8
- import { normalizeAnimationsMap, setupPropertyAnimations, createAnimationDriver, AnimationRegistry, buildStaticFrame, renderWithCompositor, driveCartesianUpdate, resolveHoverRepaintFrame, cancelDriverRafs, CartesianLayoutController, resolveSyncConfig, DatasetRegistrationController, DrilldownStateController, renderHeatmapAxesSvg, ItemCollector, buildPieSliceContentItems, getEasing, ChartSyncCoordinator, INACTIVE_STATE, KeyboardNavigationController, getResponsiveTier, getAdaptiveDefaults, evaluateResponsiveRules, ResponsiveDimensionsController, createInitialZoomState, configureCanvasHiDPI, renderCartesianOverlay, buildAnimatedFrame, renderTreemapGroupHoverOverlay, isZoomed, AxisRegistrationController, AxisTransitionState, ZoomPanController, normalizeSubConfig } from '@primeui/chart-core';
9
- import { createCandlestickRendererCanvas } from '@primeui/chart-core/series/candlestick/controller-canvas';
10
- import { createCandlestickRendererSvg } from '@primeui/chart-core/series/candlestick/controller-svg';
11
- import { createHeatmapRendererCanvas } from '@primeui/chart-core/series/heatmap/controller-canvas';
12
- import { createHeatmapRendererSvg } from '@primeui/chart-core/series/heatmap/controller-svg';
13
- import { createLineRendererCanvas } from '@primeui/chart-core/series/line/controller-canvas';
14
- import { createLineRendererSvg } from '@primeui/chart-core/series/line/controller-svg';
15
- import { createPieRendererCanvas } from '@primeui/chart-core/series/pie/controller-canvas';
16
- import { createPieRendererSvg } from '@primeui/chart-core/series/pie/controller-svg';
17
- import { createPolarRendererCanvas } from '@primeui/chart-core/series/polar/controller-canvas';
18
- import { createPolarRendererSvg } from '@primeui/chart-core/series/polar/controller-svg';
19
- import { createRadarRendererCanvas } from '@primeui/chart-core/series/radar/controller-canvas';
20
- import { createRadarRendererSvg } from '@primeui/chart-core/series/radar/controller-svg';
21
- import { createScatterRendererCanvas } from '@primeui/chart-core/series/scatter/controller-canvas';
22
- import { createScatterRendererSvg } from '@primeui/chart-core/series/scatter/controller-svg';
23
- import { createTreemapRendererCanvas } from '@primeui/chart-core/series/treemap/controller-canvas';
24
- import { createTreemapRendererSvg } from '@primeui/chart-core/series/treemap/controller-svg';
25
-
26
- function useAxisRegistration(axis, id, props) {
27
- const methods = useChartMethods();
28
- const controller = new AxisRegistrationController({
29
- id: id.value,
30
- axis,
31
- registerX: (cid, cprops) => methods.registerXAxis(cid, cprops),
32
- unregisterX: (cid) => methods.unregisterXAxis(cid),
33
- updateX: (cid, cprops) => methods.updateXAxis(cid, cprops),
34
- registerY: (cid, cprops) => methods.registerYAxis(cid, cprops),
35
- unregisterY: (cid) => methods.unregisterYAxis(cid),
36
- updateY: (cid, cprops) => methods.updateYAxis(cid, cprops)
37
- });
38
- watch(
39
- props,
40
- (newProps) => {
41
- controller.update(newProps);
42
- },
43
- { deep: false }
44
- );
45
- onMounted(() => {
46
- controller.mount(props.value);
47
- });
48
- useChartRefreshHook(() => {
49
- controller.forceRefresh(props.value);
50
- });
51
- onUnmounted(() => {
52
- controller.unmount();
53
- });
54
- }
55
-
56
- // src/composables/useAxisComponentBase.ts
57
- function useAxisComponentBase(axis, axisId, props, hasChildren) {
58
- const instance = getCurrentInstance();
59
- const vnodeProps = instance?.vnode.props || {};
60
- const axisProps = computed(() => {
61
- const boolOrUndef = (v, propName) => {
62
- const kebab = propName.replace(/([A-Z])/g, "-$1").toLowerCase();
63
- if (propName in vnodeProps || kebab in vnodeProps) return v;
64
- return void 0;
65
- };
66
- return {
67
- label: props.label,
68
- position: props.position,
69
- type: props.type,
70
- min: props.min,
71
- max: props.max,
72
- tickCount: props.tickCount,
73
- tickFormat: props.tickFormat,
74
- tickRotation: props.tickRotation,
75
- tickStyle: props.tickStyle,
76
- render: props.render,
77
- renderTick: props.renderTick,
78
- gridLines: boolOrUndef(props.gridLines, "gridLines"),
79
- color: props.color,
80
- gridColor: props.gridColor,
81
- gridStyle: props.gridStyle,
82
- gridStrokeWidth: props.gridStrokeWidth,
83
- gridOpacity: props.gridOpacity,
84
- gridShape: props.gridShape,
85
- category: props.category,
86
- tickInterval: props.tickInterval,
87
- minorGridLines: boolOrUndef(props.minorGridLines, "minorGridLines"),
88
- minorGridColor: props.minorGridColor,
89
- minorGridStrokeWidth: props.minorGridStrokeWidth,
90
- minorGridOpacity: props.minorGridOpacity,
91
- minorGridCount: props.minorGridCount,
92
- minorGridStyle: props.minorGridStyle,
93
- alternateGridColor: props.alternateGridColor,
94
- alternateGridOpacity: props.alternateGridOpacity,
95
- scale: props.scale,
96
- timezone: props.timezone,
97
- dateTimeFormats: props.dateTimeFormats,
98
- tickConfig: props.tickConfig,
99
- minUnit: props.minUnit,
100
- gapless: boolOrUndef(props.gapless, "gapless"),
101
- grouping: props.grouping,
102
- autoRotate: boolOrUndef(props.autoRotate, "autoRotate"),
103
- autoRotateAngle: props.autoRotateAngle,
104
- labelMinSpacing: props.labelMinSpacing,
105
- startFromZero: boolOrUndef(props.startFromZero, "startFromZero"),
106
- reversed: boolOrUndef(props.reversed, "reversed"),
107
- softMin: props.softMin,
108
- softMax: props.softMax,
109
- tickPosition: props.tickPosition,
110
- minorTicks: boolOrUndef(props.minorTicks, "minorTicks"),
111
- minorTickLength: props.minorTickLength,
112
- minorTickColor: props.minorTickColor,
113
- minorTickStrokeWidth: props.minorTickStrokeWidth,
114
- showFirstLabel: boolOrUndef(props.showFirstLabel, "showFirstLabel"),
115
- showLastLabel: boolOrUndef(props.showLastLabel, "showLastLabel"),
116
- showLine: boolOrUndef(props.showLine, "showLine"),
117
- showTicks: boolOrUndef(props.showTicks, "showTicks"),
118
- showLabels: boolOrUndef(props.showLabels, "showLabels"),
119
- autoSkip: boolOrUndef(props.autoSkip, "autoSkip"),
120
- visible: boolOrUndef(props.visible, "visible"),
121
- labelFontSize: props.labelFontSize,
122
- chartPaddingMin: props.chartPaddingMin,
123
- chartPaddingMax: props.chartPaddingMax,
124
- minGridDistance: props.minGridDistance
125
- };
126
- });
127
- useAxisRegistration(axis, axisId, axisProps);
128
- const methods = useChartMethods();
129
- const groups = ref([]);
130
- const groupCollector = {
131
- addGroup: (group) => {
132
- const existing = groups.value.findIndex((g) => g.label === group.label);
133
- if (existing >= 0) {
134
- const next = [...groups.value];
135
- next[existing] = group;
136
- groups.value = next;
137
- } else {
138
- groups.value = [...groups.value, group];
139
- }
140
- },
141
- removeGroup: (label) => {
142
- groups.value = groups.value.filter((g) => g.label !== label);
143
- }
144
- };
145
- if (hasChildren) {
146
- const featureKey = `axisGroup:${axis}:${axisId.value}`;
147
- watch(groups, (newGroups) => {
148
- if (newGroups.length > 0) {
149
- methods.registerCustomization(featureKey, { groups: [...newGroups], axis });
150
- }
151
- });
152
- onUnmounted(() => {
153
- methods.unregisterCustomization(featureKey);
154
- });
155
- }
156
- return { collectorValue: groupCollector, hasChildren: hasChildren ?? false };
157
- }
158
- function useDatasetAnimationRegistration(datasetId, animations) {
159
- const payload = computed(() => {
160
- const id2 = toValue(datasetId);
161
- const map = toValue(animations);
162
- if (!id2) return {};
163
- const configs = normalizeAnimationsMap(map, { datasetId: id2 });
164
- return { propertyAnimations: configs.length ? configs : void 0 };
165
- });
166
- const id = toValue(datasetId);
167
- const featureKey = id ? `animation:${id}` : "animation:__unscoped__";
168
- useCustomizationRegistration(featureKey, payload);
169
- }
170
- function useCandlestickRenderer(options) {
171
- const { chartArea, renderer, canvasEl, datasets, datasetVisibility, features, hover, hoverConfig, chartId, width, height, categoryScale, valueScales, firstValueAxisId, layoutData, compositor, theme } = options;
172
- const groupRef = ref(null);
173
- const controller = renderer === "canvas" ? createCandlestickRendererCanvas() : createCandlestickRendererSvg();
174
- const hasCandlestickData = computed(() => {
175
- for (const [, ds] of datasets.value) {
176
- if (ds.type === "candlestick") return true;
177
- }
178
- return false;
179
- });
180
- watch(
181
- [datasets, datasetVisibility, chartArea, categoryScale, valueScales, firstValueAxisId, layoutData, hoverConfig, width, height, groupRef, theme],
182
- () => {
183
- controller.update({
184
- datasets: datasets.value,
185
- datasetVisibility: datasetVisibility.value,
186
- chartArea: chartArea.value,
187
- features: features.value,
188
- chartId,
189
- width: width.value,
190
- height: height.value,
191
- renderer,
192
- categoryScale: categoryScale.value,
193
- valueScales: valueScales.value,
194
- firstValueAxisId: firstValueAxisId.value,
195
- layoutData: layoutData.value,
196
- hover: hover.value,
197
- hoverConfig: hoverConfig.value,
198
- compositor,
199
- canvasEl: canvasEl.value,
200
- svgGroup: groupRef.value,
201
- theme: theme.value
202
- });
203
- },
204
- { immediate: true, flush: "post" }
205
- );
206
- watch(hover, () => {
207
- controller.applyHover(hover.value);
208
- });
209
- onUnmounted(() => {
210
- controller.destroy();
211
- });
212
- function hitTest(x, y) {
213
- return controller.hitTest(x, y);
214
- }
215
- function findAllNearest(x, y) {
216
- return controller.findAllNearest(x, y);
217
- }
218
- function applyPropertyAnimations(store) {
219
- controller.applyPropertyAnimations(store);
220
- }
221
- function renderFrameCycle() {
222
- controller.renderFrameCycle();
223
- }
224
- return {
225
- groupRef,
226
- hitTest,
227
- findAllNearest,
228
- hasCandlestickData,
229
- applyPropertyAnimations,
230
- renderFrameCycle,
231
- get candlestickLayouts() {
232
- return controller.layouts;
233
- }
234
- };
235
- }
236
- function usePropertyAnimations(configs, registry, store, onPropertyComplete) {
237
- watchEffect((onCleanup) => {
238
- const resolved = toValue(configs);
239
- if (!resolved?.length || !registry || !store) return;
240
- onCleanup(setupPropertyAnimations(resolved, registry, store, onPropertyComplete));
241
- });
242
- }
243
- function useAxisTransition() {
244
- return new AxisTransitionState();
245
- }
246
-
247
- // src/composables/useCartesianAnimation.ts
248
- function useCartesianAnimation(options) {
249
- const {
250
- layoutData,
251
- renderer,
252
- canvasEl,
253
- overlayCanvasEl,
254
- markerOverlays,
255
- groupRef,
256
- gridGroupRef,
257
- hover,
258
- features,
259
- width,
260
- height,
261
- renderFrame: renderFrameParam,
262
- compositor,
263
- dir,
264
- globalFont,
265
- locale,
266
- theme,
267
- customTickOverlayRefs,
268
- skipHoverRepaint,
269
- isZoomed,
270
- propertyAnimations,
271
- animStoreRef,
272
- onAnimFrame,
273
- onPropertyComplete
274
- } = options;
275
- const driver = createAnimationDriver();
276
- const axisTransition = useAxisTransition();
277
- const canvasRegistry = new AnimationRegistry();
278
- function paintOverlay(axisLayouts, cartesianArea) {
279
- const overlay = overlayCanvasEl?.value;
280
- if (!overlay) return;
281
- configureCanvasHiDPI(overlay, width.value, height.value);
282
- renderCartesianOverlay({
283
- canvas: overlay,
284
- axisLayouts,
285
- hover: hover.value,
286
- registry: canvasRegistry,
287
- cartesianArea,
288
- markerOverlays: markerOverlays?.value
289
- });
290
- }
291
- canvasRegistry.setRepaintCallback(() => {
292
- if (renderer === "svg") {
293
- onAnimFrame?.();
294
- return;
295
- }
296
- if (!driver.cachedLayout) return;
297
- if (overlayCanvasEl?.value) {
298
- paintOverlay(axisTransition.apply(driver.cachedLayout.axisLayouts), driver.cachedLayout.cartesianArea);
299
- } else if (!onAnimFrame) {
300
- renderFrame(buildStatic());
301
- }
302
- onAnimFrame?.();
303
- });
304
- usePropertyAnimations(propertyAnimations, canvasRegistry, animStoreRef?.value ?? null, onPropertyComplete);
305
- const stopOverlayCanvasWatch = overlayCanvasEl ? watch(overlayCanvasEl, (el) => {
306
- if (!el || !driver.cachedLayout) return;
307
- paintOverlay(axisTransition.apply(driver.cachedLayout.axisLayouts), driver.cachedLayout.cartesianArea);
308
- }) : null;
309
- const stopMarkerOverlaysWatch = markerOverlays && overlayCanvasEl ? watch(markerOverlays, () => {
310
- if (!driver.cachedLayout || !overlayCanvasEl.value) return;
311
- paintOverlay(axisTransition.apply(driver.cachedLayout.axisLayouts), driver.cachedLayout.cartesianArea);
312
- }) : null;
313
- function getFrameCtx() {
314
- return {
315
- renderer,
316
- theme: theme(),
317
- group: groupRef.value,
318
- gridGroup: gridGroupRef.value,
319
- canvas: canvasEl.value,
320
- customTickOverlayRefs,
321
- isZoomed: isZoomed?.value,
322
- rtl: dir?.value === "rtl",
323
- globalFont
324
- };
325
- }
326
- function buildStatic() {
327
- return buildStaticFrame(getFrameCtx(), driver.cachedLayout, axisTransition);
328
- }
329
- function buildAnimated(valueScales, valueDomains, axisLayouts, categoryScale, valueXScales) {
330
- return buildAnimatedFrame(getFrameCtx(), driver.cachedLayout, axisTransition, { axisLayouts, valueScales, valueDomains, categoryScale, valueXScales });
331
- }
332
- function renderFrame(frameParams) {
333
- driver.lastFrame = frameParams;
334
- renderWithCompositor(frameParams, renderFrameParam, {
335
- renderer,
336
- canvas: canvasEl.value,
337
- compositor,
338
- overlayCanvas: overlayCanvasEl?.value,
339
- registry: canvasRegistry,
340
- hover: hover.value,
341
- markerOverlays: markerOverlays?.value
342
- });
343
- }
344
- watch(
345
- [layoutData, groupRef, gridGroupRef],
346
- () => {
347
- const layout = layoutData.value;
348
- if (!layout) return;
349
- if (renderer === "svg" && !groupRef.value) return;
350
- const animFeature = features.value.get("animation")?.props;
351
- driveCartesianUpdate(layout, driver, axisTransition, animFeature, renderFrame, buildStatic, buildAnimated, globalFont, locale);
352
- },
353
- { immediate: true, flush: "post" }
354
- );
355
- watch(hover, () => {
356
- if (!driver.cachedLayout) return;
357
- if (skipHoverRepaint?.value) return;
358
- const frame = resolveHoverRepaintFrame(driver, getFrameCtx(), buildStatic);
359
- renderFrame(frame);
360
- });
361
- if (isZoomed) {
362
- watch(isZoomed, () => {
363
- if (!driver.cachedLayout) return;
364
- renderFrame(buildStatic());
365
- });
366
- }
367
- onUnmounted(() => {
368
- cancelDriverRafs(driver);
369
- canvasRegistry.destroy();
370
- if (animStoreRef) {
371
- animStoreRef.value?.destroy();
372
- animStoreRef.value = null;
373
- }
374
- stopOverlayCanvasWatch?.();
375
- stopMarkerOverlaysWatch?.();
376
- });
377
- }
378
- function useCartesianLayout(options) {
379
- const { cartesianArea, datasets, axes, features, datasetVisibility, hoverConfig, chartId, renderer, width, height, zoomState, globalFont } = options;
380
- const controller = new CartesianLayoutController();
381
- onUnmounted(() => controller.destroy());
382
- return computed(() => {
383
- const area = cartesianArea.value;
384
- if (!area) return null;
385
- return controller.compute({
386
- cartesianArea: area,
387
- datasets: datasets.value,
388
- axes: axes.value,
389
- features: features.value,
390
- datasetVisibility: datasetVisibility.value,
391
- hoverConfig: hoverConfig.value,
392
- chartId,
393
- renderer,
394
- dimensions: { width: width.value, height: height.value },
395
- zoomState: zoomState?.value ?? void 0,
396
- dir: options.dir?.value ?? "ltr",
397
- font: globalFont,
398
- locale: options.locale?.value,
399
- theme: options.theme.value
400
- });
401
- });
402
- }
403
- function useChartSync(options) {
404
- const syncBus = inject(SYNC_BUS_KEY, null);
405
- const initialSync = toValue(options.sync);
406
- if (!syncBus || initialSync === false) {
407
- return { syncInfo: null };
408
- }
409
- const resolvedConfig = resolveSyncConfig(initialSync);
410
- syncBus.register(options.chartId, resolvedConfig);
411
- watch(
412
- () => toValue(options.sync),
413
- (next) => {
414
- if (next === false) return;
415
- syncBus.updateConfig(options.chartId, resolveSyncConfig(next));
416
- },
417
- { deep: true }
418
- );
419
- onUnmounted(() => {
420
- syncBus.unregister(options.chartId);
421
- });
422
- return {
423
- syncInfo: {
424
- bus: syncBus,
425
- chartId: options.chartId,
426
- config: resolvedConfig
427
- }
428
- };
429
- }
430
- function useDatasetRegistration({ id, type, props, typeResolver }) {
431
- const methods = useChartMethods();
432
- const stackedContext = inject(STACKED_CONTEXT_KEY, null);
433
- const rangeContext = inject(RANGE_CONTEXT_KEY, null);
434
- let autoOrder = void 0;
435
- if (stackedContext && props.value.order === void 0) {
436
- autoOrder = stackedContext.getNextOrder();
437
- }
438
- const controller = new DatasetRegistrationController({
439
- id: id.value,
440
- type,
441
- typeResolver,
442
- register: (cid, ctype, cprops) => methods.registerDataset(cid, ctype, cprops),
443
- unregister: (cid) => methods.unregisterDataset(cid),
444
- update: (cid, cprops) => methods.updateDataset(cid, cprops)
445
- });
446
- const getExtras = () => ({
447
- stackId: stackedContext?.stackId,
448
- rangeId: rangeContext?.rangeId,
449
- order: props.value.order ?? autoOrder
450
- });
451
- const stableProps = shallowRef(props.value);
452
- watch(
453
- props,
454
- (newProps) => {
455
- controller.update(newProps, getExtras());
456
- stableProps.value = newProps;
457
- },
458
- { deep: false }
459
- );
460
- onMounted(() => {
461
- controller.mount(props.value, getExtras());
462
- });
463
- useChartRefreshHook(() => {
464
- controller.forceRefresh(props.value, getExtras());
465
- });
466
- onUnmounted(() => {
467
- controller.unmount();
468
- });
469
- }
470
- function useDrilldownState(datasets) {
471
- const controller = new DrilldownStateController();
472
- const snapshot = shallowRef(controller.getSnapshot());
473
- const unsubscribe = controller.subscribe(() => {
474
- snapshot.value = controller.getSnapshot();
475
- });
476
- onScopeDispose(unsubscribe);
477
- watch(datasets, (next) => controller.setDatasets(next), { immediate: true });
478
- return {
479
- currentParentId: computed(() => snapshot.value.currentParentId),
480
- path: computed(() => snapshot.value.path),
481
- isActive: computed(() => snapshot.value.isActive),
482
- enabled: computed(() => snapshot.value.enabled),
483
- drillInto: controller.drillInto,
484
- drillToLevel: controller.drillToLevel
485
- };
486
- }
487
- var FAMILY_RENDERERS_KEY = /* @__PURE__ */ Symbol.for("primeui-chart-family-renderers");
488
- function provideFamilyRenderers() {
489
- const registry = shallowReactive({ cartesian: void 0, radial: void 0, rect: void 0 });
490
- provide(FAMILY_RENDERERS_KEY, registry);
491
- return registry;
492
- }
493
- function registerFamilyRenderer(family, component) {
494
- const registry = inject(FAMILY_RENDERERS_KEY, null);
495
- if (registry && !registry[family]) registry[family] = component;
496
- }
497
- var NAVIGATOR_RENDERER_KEY = /* @__PURE__ */ Symbol.for("primeui-chart-navigator-renderer");
498
- function registerNavigatorRenderer(component) {
499
- const slot = inject(NAVIGATOR_RENDERER_KEY, null);
500
- if (slot && !slot.value) slot.value = component;
501
- }
502
- var ZOOM_CONTROLLER_KEY = /* @__PURE__ */ Symbol.for("primeui-chart-zoom-controller");
503
- function registerZoomController(ctor) {
504
- const slot = inject(ZOOM_CONTROLLER_KEY, null);
505
- if (slot && !slot.value) slot.value = ctor;
506
- }
507
- var KEYBOARD_CONTROLLER_KEY = /* @__PURE__ */ Symbol.for("primeui-chart-keyboard-controller");
508
- function registerKeyboardController(ctor) {
509
- const slot = inject(KEYBOARD_CONTROLLER_KEY, null);
510
- if (slot && !slot.value) slot.value = ctor;
511
- }
512
- var CHART_LAYERS_KEY = /* @__PURE__ */ Symbol.for("primeui-chart-layers");
513
- function provideChartLayers() {
514
- const registry = shallowReactive(/* @__PURE__ */ new Map());
515
- provide(CHART_LAYERS_KEY, registry);
516
- return registry;
517
- }
518
- function registerChartLayer(type, entry) {
519
- const registry = inject(CHART_LAYERS_KEY, null);
520
- if (registry && !registry.has(type)) registry.set(type, entry);
521
- }
522
- function useChartLayers() {
523
- return inject(CHART_LAYERS_KEY, null);
524
- }
525
- var RADIAL_FRAME_KEY = /* @__PURE__ */ Symbol.for("primeui-chart-radial-frame");
526
- function provideRadialFrame() {
527
- const handles = shallowReactive(/* @__PURE__ */ new Map());
528
- const frame = {
529
- handles,
530
- register: (h2) => handles.set(h2.type, h2),
531
- unregister: (type) => handles.delete(type)
532
- };
533
- provide(RADIAL_FRAME_KEY, frame);
534
- return frame;
535
- }
536
- function useRadialFrameRegistration(handle) {
537
- const frame = inject(RADIAL_FRAME_KEY, null);
538
- if (!frame) return;
539
- frame.register(handle);
540
- onBeforeUnmount(() => frame.unregister(handle.type));
541
- }
542
- var CARTESIAN_FRAME_KEY = /* @__PURE__ */ Symbol.for("primeui-chart-cartesian-frame");
543
- function provideCartesianFrame(shared) {
544
- const handles = shallowReactive(/* @__PURE__ */ new Map());
545
- const frame = {
546
- ...shared,
547
- handles,
548
- register: (h2) => handles.set(h2.type, h2),
549
- unregister: (type) => handles.delete(type)
550
- };
551
- provide(CARTESIAN_FRAME_KEY, frame);
552
- return frame;
553
- }
554
- function useCartesianFrame() {
555
- return inject(CARTESIAN_FRAME_KEY, null);
556
- }
557
- function useCartesianFrameRegistration(handle) {
558
- const frame = inject(CARTESIAN_FRAME_KEY, null);
559
- if (!frame) return;
560
- frame.register(handle);
561
- onBeforeUnmount(() => frame.unregister(handle.type));
562
- }
563
- function useHeatmapRenderer(options) {
564
- const { chartArea, renderer, canvasEl, datasets, axes, datasetVisibility, hover, hoverConfig, chartId, width, height, features, compositor, globalFont, theme } = options;
565
- const groupRef = ref(null);
566
- const gridGroupRef = ref(null);
567
- const axisGroupRef = ref(null);
568
- const controller = renderer === "canvas" ? createHeatmapRendererCanvas() : createHeatmapRendererSvg();
569
- const versionRef = ref(0);
570
- controller.onFrame = () => {
571
- versionRef.value++;
572
- };
573
- const hasHeatmapData = computed(() => {
574
- for (const [, ds] of datasets.value) {
575
- if (ds.type === "heatmap") return true;
576
- }
577
- return false;
578
- });
579
- const scaleResult = computed(() => {
580
- void versionRef.value;
581
- return controller.scaleResult;
582
- });
583
- const axisLayoutsComputed = computed(() => {
584
- void versionRef.value;
585
- return controller.axisLayouts;
586
- });
587
- watch(
588
- [datasets, datasetVisibility, chartArea, axes, features, width, height, groupRef, gridGroupRef, axisGroupRef, options.locale, theme],
589
- () => {
590
- controller.update({
591
- datasets: datasets.value,
592
- datasetVisibility: datasetVisibility.value,
593
- chartArea: chartArea.value,
594
- chartId,
595
- width: width.value,
596
- height: height.value,
597
- renderer,
598
- axes: axes.value,
599
- features: features.value,
600
- hover: hover.value,
601
- hoverConfig: hoverConfig.value,
602
- compositor,
603
- canvasEl: canvasEl.value,
604
- svgGroup: groupRef.value,
605
- globalFont,
606
- locale: options.locale?.value,
607
- theme: theme.value,
608
- resolveDatasetProps: (dsId) => {
609
- const dsReg = datasets.value.get(dsId);
610
- return dsReg?.props;
611
- }
612
- });
613
- if (renderer === "svg") {
614
- renderHeatmapAxesSvg(gridGroupRef.value, axisGroupRef.value, controller.axisLayouts, theme.value);
615
- }
616
- },
617
- { immediate: true, flush: "post" }
618
- );
619
- watch(hover, () => {
620
- controller.applyHover(hover.value);
621
- });
622
- onUnmounted(() => {
623
- controller.destroy();
624
- });
625
- function hitTest(x, y) {
626
- return controller.hitTest(x, y);
627
- }
628
- function getPointPosition(datasetId, index) {
629
- const lr = controller.layoutResult;
630
- if (!lr) return null;
631
- const hmLayout = lr.layouts.get(datasetId);
632
- const cell = hmLayout?.cells.find((c) => c.index === index && !c.isEmpty);
633
- if (!cell) return null;
634
- return { x: cell.x, y: cell.y, width: cell.width, height: cell.height, shape: "rect" };
635
- }
636
- function getColorScaleInfo() {
637
- return controller.getColorScaleInfo();
638
- }
639
- function applyPropertyAnimations(store) {
640
- controller.applyPropertyAnimations(store);
641
- }
642
- function renderFrameCycle() {
643
- controller.renderFrameCycle();
644
- }
645
- const svgContent = computed(() => {
646
- if (renderer !== "svg") return [];
647
- void versionRef.value;
648
- const lr = controller.layoutResult;
649
- if (!lr) return [];
650
- const elements = [];
651
- for (const [datasetId, hmLayout] of lr.layouts) {
652
- const dsReg = datasets.value.get(datasetId);
653
- const hmProps = dsReg?.props;
654
- const renderFn = hmProps?.renderContent;
655
- const data = hmProps?.data;
656
- if (!renderFn || !data) continue;
657
- for (const cell of hmLayout.cells) {
658
- if (cell.isEmpty) continue;
659
- const dataItem = data[cell.index];
660
- if (!dataItem) continue;
661
- const result = renderFn({
662
- data: dataItem,
663
- index: cell.index,
664
- value: cell.value,
665
- xLabel: cell.xLabel,
666
- yLabel: cell.yLabel,
667
- color: cell.color,
668
- x: cell.x,
669
- y: cell.y,
670
- width: cell.width,
671
- height: cell.height,
672
- row: cell.row,
673
- col: cell.col,
674
- isEmpty: cell.isEmpty
675
- });
676
- if (result != null) {
677
- const clipId = `hm-clip-${datasetId}-${cell.index}`;
678
- elements.push(
679
- createVNode("g", { key: `${datasetId}-${cell.index}`, "clip-path": `url(#${clipId})` }, [
680
- createVNode("defs", null, [createVNode("clipPath", { id: clipId }, [createVNode("rect", { x: cell.x, y: cell.y, width: cell.width, height: cell.height })])]),
681
- result
682
- ])
683
- );
684
- }
685
- }
686
- }
687
- return elements;
688
- });
689
- return {
690
- groupRef,
691
- gridGroupRef,
692
- axisGroupRef,
693
- hitTest,
694
- getPointPosition,
695
- hasHeatmapData,
696
- axisLayouts: axisLayoutsComputed,
697
- plotArea: chartArea,
698
- getColorScaleInfo,
699
- scaleResult,
700
- svgContent,
701
- applyPropertyAnimations,
702
- renderFrameCycle
703
- };
704
- }
705
- function useItemCollector() {
706
- const collector = new ItemCollector();
707
- provide(ITEM_COLLECTOR_KEY, {
708
- registerItem: (index, props) => collector.registerItem(index, props),
709
- unregisterItem: (index) => collector.unregisterItem(index),
710
- getNextIndex: () => collector.getNextIndex()
711
- });
712
- return { getItems: () => collector.getItems() };
713
- }
714
- function useControllerLifecycle(controller) {
715
- onUnmounted(() => {
716
- controller.destroy();
717
- });
718
- return {
719
- applyPropertyAnimations: (store) => controller.applyPropertyAnimations(store),
720
- renderFrameCycle: () => controller.renderFrameCycle()
721
- };
722
- }
723
- function useLineRenderer(options) {
724
- const {
725
- chartArea,
726
- renderer,
727
- canvasEl,
728
- datasets,
729
- datasetVisibility,
730
- hover,
731
- hoverConfig,
732
- chartId,
733
- width,
734
- height,
735
- categoryScale,
736
- valueScales,
737
- firstValueAxisId,
738
- axisIdProp,
739
- lineStackBasesMap,
740
- lineTransformedValues,
741
- rangeGroups,
742
- features,
743
- compositor,
744
- layoutData,
745
- dir,
746
- theme
747
- } = options;
748
- const groupRef = ref(null);
749
- const controller = renderer === "canvas" ? createLineRendererCanvas() : createLineRendererSvg();
750
- const layoutCacheRef = shallowRef(/* @__PURE__ */ new Map());
751
- const renderPropsCacheRef = shallowRef(/* @__PURE__ */ new Map());
752
- const markerOverlaysRef = ref([]);
753
- controller.onFrame = () => {
754
- markerOverlaysRef.value = controller.markerOverlays;
755
- };
756
- watch(
757
- [datasets, datasetVisibility, chartArea, categoryScale, valueScales, firstValueAxisId, axisIdProp, lineStackBasesMap, lineTransformedValues, rangeGroups, features, groupRef, width, height, dir, theme],
758
- () => {
759
- if (renderer === "svg" && !groupRef.value) return;
760
- controller.update({
761
- datasets: datasets.value,
762
- datasetVisibility: datasetVisibility.value,
763
- chartArea: chartArea.value,
764
- chartId,
765
- width: width.value,
766
- height: height.value,
767
- renderer,
768
- categoryScale: categoryScale.value,
769
- valueScales: valueScales.value,
770
- firstValueAxisId: firstValueAxisId.value,
771
- axisIdProp: axisIdProp.value,
772
- lineStackBasesMap: lineStackBasesMap.value,
773
- lineTransformedValues: lineTransformedValues.value,
774
- groupedDataOverride: layoutData?.value?.groupedDataOverride,
775
- layoutData: layoutData?.value ?? null,
776
- rangeGroups: rangeGroups.value,
777
- features: features.value,
778
- hover: hover.value,
779
- hoverConfig: hoverConfig.value,
780
- compositor,
781
- canvasEl: canvasEl.value,
782
- svgGroup: groupRef.value,
783
- labelConfig: options.labelConfig?.value,
784
- dir: dir.value,
785
- theme: theme.value
786
- });
787
- layoutCacheRef.value = controller.layouts;
788
- renderPropsCacheRef.value = controller.renderProps;
789
- markerOverlaysRef.value = controller.markerOverlays;
790
- },
791
- { immediate: true, flush: "post" }
792
- );
793
- watch(hover, () => {
794
- controller.applyHover(hover.value);
795
- });
796
- const { applyPropertyAnimations, renderFrameCycle } = useControllerLifecycle(controller);
797
- function hitTest(x, y) {
798
- return controller.hitTest(x, y);
799
- }
800
- function findAllNearest(x, y) {
801
- return controller.findAllNearest(x, y);
802
- }
803
- const hasLineData = computed(() => {
804
- for (const [, ds] of datasets.value) {
805
- if (ds.type === "line") return true;
806
- }
807
- return false;
808
- });
809
- function syncWithAnimatedScale(categoryScale2, valueScales2) {
810
- controller.syncWithAnimatedScale(categoryScale2, valueScales2);
811
- markerOverlaysRef.value = controller.markerOverlays;
812
- }
813
- return {
814
- groupRef,
815
- hitTest,
816
- findAllNearest,
817
- hasLineData,
818
- lineLayouts: layoutCacheRef,
819
- lineRenderProps: renderPropsCacheRef,
820
- subscribeTipPositions: (cb) => controller.subscribeTipPositions(cb),
821
- markerOverlays: markerOverlaysRef,
822
- syncWithAnimatedScale,
823
- applyPropertyAnimations,
824
- renderFrameCycle
825
- };
826
- }
827
- function usePieRenderer(options) {
828
- const { renderer, chartId, globalFont, adaptiveDataLabelFontSize, theme, dir } = options;
829
- const groupRef = ref(null);
830
- const labelGroupRef = ref(null);
831
- const centerRef = ref(null);
832
- const versionRef = ref(0);
833
- const controller = renderer === "canvas" ? createPieRendererCanvas() : createPieRendererSvg();
834
- controller.onFrame = () => {
835
- versionRef.value++;
836
- centerRef.value = controller.center;
837
- };
838
- watch(
839
- [options.datasets, options.chartArea, options.datasetVisibility, options.hiddenItems, options.features, options.width, options.height, groupRef, dir, theme],
840
- () => {
841
- if (options.datasets.value.size === 0) return;
842
- if (renderer === "svg" && !groupRef.value) return;
843
- const hoverConfig = options.features.value.get("hover")?.props;
844
- controller.update({
845
- datasets: options.datasets.value,
846
- datasetVisibility: options.datasetVisibility.value,
847
- hiddenItems: options.hiddenItems.value,
848
- chartArea: options.chartArea.value,
849
- renderer,
850
- width: options.width.value,
851
- height: options.height.value,
852
- chartId,
853
- features: options.features.value,
854
- hover: options.hover.value,
855
- hoverConfig,
856
- globalFont,
857
- adaptiveDataLabelFontSize: adaptiveDataLabelFontSize?.value,
858
- svgGroup: groupRef.value ?? void 0,
859
- canvasEl: options.canvasEl.value ?? void 0,
860
- dir: dir.value,
861
- theme: theme.value
862
- });
863
- controller.registerLabelGroup(labelGroupRef.value);
864
- centerRef.value = controller.center;
865
- },
866
- { immediate: true, flush: "post" }
867
- );
868
- watch([options.hover, () => options.features.value.get("hover")?.props], () => {
869
- controller.applyHover(options.hover.value);
870
- });
871
- const { applyPropertyAnimations, renderFrameCycle } = useControllerLifecycle(controller);
872
- const svgContent = computed(() => {
873
- if (renderer !== "svg") return [];
874
- void versionRef.value;
875
- const content = [];
876
- for (const item of buildPieSliceContentItems(controller.entries, controller.lastRenderedSlices, controller.ringRadii, controller.animationLayout, options.hiddenItems.value, options.globalFont?.family, theme.value)) {
877
- const result = item.renderFn(item.context);
878
- if (result != null) {
879
- content.push(
880
- h(
881
- "g",
882
- {
883
- key: item.datasetKey,
884
- class: "slice-custom-content",
885
- "data-dataset": item.datasetId,
886
- "data-index": item.index,
887
- transform: `translate(${item.contentX}, ${item.contentY})`,
888
- onVnodeMounted: (vnode) => controller.registerCustomContent(item.key, vnode.el),
889
- onVnodeUnmounted: () => controller.registerCustomContent(item.key, null)
890
- },
891
- [result]
892
- )
893
- );
894
- }
895
- }
896
- return content;
897
- });
898
- function hitTest(x, y) {
899
- const hit = controller.hitTest(x, y);
900
- if (!hit) return null;
901
- return { datasetId: hit.datasetId, index: hit.index, label: hit.label, value: hit.value, percentage: hit.percentage, color: hit.color };
902
- }
903
- function getSlicePosition(datasetId, index) {
904
- return controller.getSlicePosition(datasetId, index);
905
- }
906
- return {
907
- groupRef,
908
- labelGroupRef,
909
- hitTest,
910
- getSlicePosition,
911
- center: centerRef,
912
- svgContent,
913
- applyPropertyAnimations,
914
- renderFrameCycle
915
- };
916
- }
917
- function usePolarRenderer(options) {
918
- const { chartArea, renderer, datasets, features, hover, datasetVisibility, globalFont, adaptiveDataLabelFontSize, chartId, width, height, sharedContext, requestRedraw, dir, xAxes, yAxes, theme } = options;
919
- const groupRef = ref(null);
920
- const layoutRef = ref(null);
921
- const controller = renderer === "canvas" ? createPolarRendererCanvas() : createPolarRendererSvg();
922
- controller.onFrame = () => {
923
- layoutRef.value = controller.layout;
924
- };
925
- const active = computed(() => controller.hasData);
926
- function getLabelConfig() {
927
- const dlProps = features.value.get("dataLabels")?.props;
928
- return normalizeDataLabelConfig(dlProps, adaptiveDataLabelFontSize?.value, void 0, globalFont);
929
- }
930
- watch(
931
- [datasets, chartArea, datasetVisibility, features, groupRef, xAxes, yAxes, dir, theme],
932
- () => {
933
- const area = chartArea.value;
934
- if (!area) {
935
- layoutRef.value = null;
936
- return;
937
- }
938
- const hc = features.value.get("hover")?.props;
939
- controller.update({
940
- datasets: datasets.value,
941
- datasetVisibility: datasetVisibility.value,
942
- chartArea: area,
943
- width: width.value,
944
- height: height.value,
945
- chartId,
946
- renderer,
947
- features: features.value,
948
- hover: hover.value,
949
- hoverConfig: hc,
950
- globalFont,
951
- adaptiveDataLabelFontSize: adaptiveDataLabelFontSize?.value,
952
- sharedContext: sharedContext?.value,
953
- svgGroup: groupRef.value,
954
- requestRedraw,
955
- labelConfig: getLabelConfig(),
956
- dir: dir.value,
957
- xAxes: xAxes?.value,
958
- yAxes: yAxes?.value,
959
- theme: theme.value
960
- });
961
- layoutRef.value = controller.layout;
962
- },
963
- { immediate: true, flush: "post" }
964
- );
965
- watch([hover, () => features.value.get("hover")?.props], () => {
966
- controller.applyHover(hover.value);
967
- });
968
- const { applyPropertyAnimations, renderFrameCycle } = useControllerLifecycle(controller);
969
- function hitTest(x, y) {
970
- const hit = controller.hitTest(x, y);
971
- if (!hit) return null;
972
- return { datasetId: hit.datasetId, index: hit.index, label: hit.label, value: hit.value, color: hit.color };
973
- }
974
- function getPointPosition(datasetId, index) {
975
- const layout = layoutRef.value;
976
- const bar = layout?.bars.find((b) => b.datasetId === datasetId && b.dataIndex === index);
977
- if (!layout || !bar) return null;
978
- const midAngle = (bar.startAngle + bar.endAngle) / 2;
979
- const midRadius = (bar.innerRadius + bar.outerRadius) / 2;
980
- const rad = midAngle * Math.PI / 180;
981
- const cx = layout.center.x + Math.cos(rad) * midRadius;
982
- const cy = layout.center.y + Math.sin(rad) * midRadius;
983
- const r = 6;
984
- return { x: cx - r, y: cy - r, width: r * 2, height: r * 2, shape: "circle" };
985
- }
986
- function findAllNearest(x, y) {
987
- const result = controller.findAllNearest(x, y);
988
- if (!result) return null;
989
- const { primary, allSeries } = result;
990
- return {
991
- primary: { datasetId: primary.datasetId, index: primary.index, label: primary.label, value: primary.value, color: primary.color },
992
- allSeries
993
- };
994
- }
995
- function renderCanvasContent(ctx, _canvas) {
996
- controller.renderCanvasContent(ctx);
997
- }
998
- return {
999
- groupRef,
1000
- hitTest,
1001
- getPointPosition,
1002
- findAllNearest,
1003
- active,
1004
- get center() {
1005
- return controller.center;
1006
- },
1007
- layout: layoutRef,
1008
- renderCanvasContent,
1009
- applyPropertyAnimations,
1010
- renderFrameCycle
1011
- };
1012
- }
1013
- function useRadarRenderer(options) {
1014
- const { chartArea, renderer, datasets, features, hover, datasetVisibility, globalFont, adaptiveDataLabelFontSize, chartId, width, height, sharedContext, requestRedraw, dir, xAxes, yAxes, theme } = options;
1015
- const groupRef = ref(null);
1016
- const layoutRef = ref(null);
1017
- const markerData = ref(null);
1018
- const controller = renderer === "canvas" ? createRadarRendererCanvas() : createRadarRendererSvg();
1019
- controller.onMarkerDataChange = (data) => {
1020
- markerData.value = data;
1021
- };
1022
- controller.onFrame = () => {
1023
- layoutRef.value = controller.layout;
1024
- };
1025
- const active = computed(() => controller.hasData);
1026
- function getLabelConfig() {
1027
- const dlProps = features.value.get("dataLabels")?.props;
1028
- return normalizeDataLabelConfig(dlProps, adaptiveDataLabelFontSize?.value, void 0, globalFont);
1029
- }
1030
- watch(
1031
- [datasets, chartArea, datasetVisibility, features, groupRef, xAxes, yAxes, dir, theme],
1032
- () => {
1033
- const area = chartArea.value;
1034
- if (!area) {
1035
- layoutRef.value = null;
1036
- return;
1037
- }
1038
- const hc = features.value.get("hover")?.props;
1039
- controller.update({
1040
- datasets: datasets.value,
1041
- datasetVisibility: datasetVisibility.value,
1042
- chartArea: area,
1043
- width: width.value,
1044
- height: height.value,
1045
- renderer,
1046
- features: features.value,
1047
- hover: hover.value,
1048
- hoverConfig: hc,
1049
- globalFont,
1050
- adaptiveDataLabelFontSize: adaptiveDataLabelFontSize?.value,
1051
- chartId,
1052
- sharedContext: sharedContext?.value,
1053
- svgGroup: groupRef.value,
1054
- requestRedraw,
1055
- labelConfig: getLabelConfig(),
1056
- dir: dir.value,
1057
- xAxes: xAxes?.value,
1058
- yAxes: yAxes?.value,
1059
- theme: theme.value
1060
- });
1061
- layoutRef.value = controller.layout;
1062
- },
1063
- { immediate: true, flush: "post" }
1064
- );
1065
- watch([hover, () => features.value.get("hover")?.props], () => {
1066
- controller.applyHover(hover.value);
1067
- });
1068
- const { applyPropertyAnimations, renderFrameCycle } = useControllerLifecycle(controller);
1069
- function hitTest(x, y) {
1070
- const hit = controller.hitTest(x, y);
1071
- if (!hit) return null;
1072
- return { datasetId: hit.datasetId, index: hit.index, label: hit.label, value: hit.value, color: hit.color };
1073
- }
1074
- function findAllNearest(x, y) {
1075
- const result = controller.findAllNearest(x, y);
1076
- if (!result) return null;
1077
- const { primary, allSeries } = result;
1078
- return {
1079
- primary: { datasetId: primary.datasetId, index: primary.index, label: primary.label, value: primary.value, color: primary.color },
1080
- allSeries
1081
- };
1082
- }
1083
- function renderCanvasContent(ctx, _canvas) {
1084
- controller.renderCanvasContent(ctx);
1085
- }
1086
- return {
1087
- groupRef,
1088
- hitTest,
1089
- findAllNearest,
1090
- active,
1091
- markerData,
1092
- layout: layoutRef,
1093
- renderCanvasContent,
1094
- applyPropertyAnimations,
1095
- renderFrameCycle
1096
- };
1097
- }
1098
- function useScatterRenderer(options) {
1099
- const {
1100
- chartArea,
1101
- renderer,
1102
- canvasEl,
1103
- datasets,
1104
- datasetVisibility,
1105
- hover,
1106
- hoverConfig,
1107
- chartId,
1108
- width,
1109
- height,
1110
- scatterXScales,
1111
- valueScales,
1112
- firstCategoryAxisId,
1113
- firstValueAxisId,
1114
- scatterStackBasesMap,
1115
- compositor,
1116
- decimationConfig,
1117
- zoomState,
1118
- orientation,
1119
- labelConfig,
1120
- features,
1121
- dir,
1122
- theme
1123
- } = options;
1124
- const groupRef = ref(null);
1125
- const markerOverlaysRef = ref([]);
1126
- const controller = renderer === "canvas" ? createScatterRendererCanvas() : createScatterRendererSvg();
1127
- const hasScatterData = computed(() => {
1128
- for (const [, ds] of datasets.value) {
1129
- if (ds.type === "scatter") return true;
1130
- }
1131
- return false;
1132
- });
1133
- watch(
1134
- [datasets, datasetVisibility, chartArea, scatterXScales, valueScales, firstCategoryAxisId, firstValueAxisId, scatterStackBasesMap, hoverConfig, width, height, groupRef, features, dir, theme],
1135
- () => {
1136
- controller.update({
1137
- datasets: datasets.value,
1138
- datasetVisibility: datasetVisibility.value,
1139
- chartArea: chartArea.value,
1140
- chartId,
1141
- width: width.value,
1142
- height: height.value,
1143
- renderer,
1144
- scatterXScales: scatterXScales.value,
1145
- valueScales: valueScales.value,
1146
- firstCategoryAxisId: firstCategoryAxisId.value,
1147
- firstValueAxisId: firstValueAxisId.value,
1148
- scatterStackBasesMap: scatterStackBasesMap.value,
1149
- hover: hover.value,
1150
- hoverConfig: hoverConfig.value,
1151
- compositor,
1152
- canvasEl: canvasEl.value,
1153
- svgGroup: groupRef.value,
1154
- decimationConfig: decimationConfig?.value,
1155
- zoomState: zoomState?.value,
1156
- orientation: orientation?.value,
1157
- labelConfig: labelConfig?.value,
1158
- dir: dir.value,
1159
- features: features.value,
1160
- theme: theme.value
1161
- });
1162
- markerOverlaysRef.value = controller.markerOverlays;
1163
- },
1164
- { immediate: true, flush: "post" }
1165
- );
1166
- watch(hover, () => {
1167
- controller.applyHover(hover.value);
1168
- });
1169
- const { applyPropertyAnimations, renderFrameCycle } = useControllerLifecycle(controller);
1170
- function hitTest(x, y) {
1171
- return controller.hitTest(x, y);
1172
- }
1173
- return {
1174
- groupRef,
1175
- hitTest,
1176
- hasScatterData,
1177
- boostActive: computed(() => controller.boostActive),
1178
- markerOverlays: markerOverlaysRef,
1179
- applyPropertyAnimations,
1180
- renderFrameCycle,
1181
- syncWithAnimatedScale: (categoryScale, valueScales2, valueXScales) => {
1182
- controller.syncWithAnimatedScale(categoryScale, valueScales2, valueXScales);
1183
- markerOverlaysRef.value = controller.markerOverlays;
1184
- },
1185
- get scatterLayouts() {
1186
- return controller.layouts;
1187
- }
1188
- };
1189
- }
1190
- function useTreemapRenderer(options) {
1191
- const { chartArea, renderer, canvasEl, datasets, features, datasetVisibility, width, height, chartId, drilldownState, globalFont, hover, theme } = options;
1192
- const wrapperRef = ref(null);
1193
- const groupRef = ref(null);
1194
- const overlayRef = ref(null);
1195
- const controller = renderer === "canvas" ? createTreemapRendererCanvas() : createTreemapRendererSvg();
1196
- const versionRef = ref(0);
1197
- controller.onFrame = () => {
1198
- versionRef.value++;
1199
- };
1200
- controller.onImageLoad = () => {
1201
- if (renderer !== "canvas") return;
1202
- controller.update({
1203
- datasets: datasets.value,
1204
- datasetVisibility: datasetVisibility.value,
1205
- chartArea: chartArea.value,
1206
- renderer,
1207
- width: width.value,
1208
- height: height.value,
1209
- chartId,
1210
- features: features.value,
1211
- hover: { datasetId: null, index: null },
1212
- canvasEl: canvasEl.value,
1213
- svgGroup: groupRef.value,
1214
- svgWrapper: wrapperRef.value,
1215
- globalFont,
1216
- drilldownParentId: drilldownState.currentParentId.value,
1217
- drilldownEnabled: drilldownState.enabled.value,
1218
- theme: theme.value
1219
- });
1220
- };
1221
- watch(
1222
- [datasets, datasetVisibility, chartArea, features, width, height, groupRef, () => drilldownState.currentParentId.value, () => drilldownState.enabled.value, theme],
1223
- () => {
1224
- controller.update({
1225
- datasets: datasets.value,
1226
- datasetVisibility: datasetVisibility.value,
1227
- chartArea: chartArea.value,
1228
- renderer,
1229
- width: width.value,
1230
- height: height.value,
1231
- chartId,
1232
- features: features.value,
1233
- hover: { datasetId: null, index: null },
1234
- canvasEl: canvasEl.value,
1235
- svgGroup: groupRef.value,
1236
- svgWrapper: wrapperRef.value,
1237
- globalFont,
1238
- drilldownParentId: drilldownState.currentParentId.value,
1239
- drilldownEnabled: drilldownState.enabled.value,
1240
- theme: theme.value
1241
- });
1242
- versionRef.value++;
1243
- },
1244
- { immediate: true, flush: "post" }
1245
- );
1246
- watch(hover, () => {
1247
- controller.applyHover(hover.value);
1248
- });
1249
- onUnmounted(() => {
1250
- controller.destroy();
1251
- });
1252
- function handleDrilldownClick(hit) {
1253
- if (!drilldownState.enabled.value) return false;
1254
- const result = controller.buildDrillInto(hit, drilldownState.currentParentId.value);
1255
- if (!result) return false;
1256
- drilldownState.drillInto(result.nodeId, result.label, result.ancestors);
1257
- return true;
1258
- }
1259
- function prepareDrillOut() {
1260
- controller.prepareDrillOut(chartArea.value);
1261
- }
1262
- function hitTest(x, y) {
1263
- return controller.hitTest(x, y);
1264
- }
1265
- function getPointPosition(datasetId, index) {
1266
- const entry = controller.layouts.get(datasetId);
1267
- const cell = entry?.layout.cells.find((c) => c.index === index);
1268
- if (!cell) return null;
1269
- return { x: cell.x, y: cell.y, width: cell.width, height: cell.height, shape: "rect" };
1270
- }
1271
- function updateHoverOverlay(hit) {
1272
- if (renderer === "canvas") {
1273
- controller.updateHoverOverlayCanvas(hit);
1274
- return;
1275
- }
1276
- const groupNodeId = hit?.isGroupHit ? hit.nodeId ?? null : null;
1277
- const overlay = overlayRef.value;
1278
- if (!overlay) return;
1279
- renderTreemapGroupHoverOverlay(overlay, controller.layouts, groupNodeId);
1280
- }
1281
- const svgContent = computed(() => {
1282
- if (renderer !== "svg") return [];
1283
- void versionRef.value;
1284
- const elements = [];
1285
- for (const [datasetId, { props, layout }] of controller.layouts) {
1286
- const renderFn = props.renderContent;
1287
- if (!renderFn || !props.data) continue;
1288
- for (const cell of layout.cells) {
1289
- const dataItem = props.data[cell.index];
1290
- if (!dataItem) continue;
1291
- const result = renderFn({
1292
- data: dataItem,
1293
- index: cell.index,
1294
- label: cell.label,
1295
- secondaryLabel: cell.secondaryLabel,
1296
- value: cell.value,
1297
- color: cell.color,
1298
- x: cell.x,
1299
- y: cell.y,
1300
- width: cell.width,
1301
- height: cell.height,
1302
- nodeId: cell.nodeId,
1303
- parentId: cell.parentId,
1304
- hasChildren: cell.hasChildren,
1305
- depth: cell.depth,
1306
- drilldownParentId: props.drilldownParentId ?? null
1307
- });
1308
- if (result != null) {
1309
- const clipId = `tm-clip-${datasetId}-${cell.index}`;
1310
- elements.push(
1311
- createVNode("g", { key: `${datasetId}-${cell.index}` }, [
1312
- createVNode("clipPath", { id: clipId }, [createVNode("rect", { x: cell.x, y: cell.y, width: cell.width, height: cell.height })]),
1313
- createVNode("g", { "clip-path": `url(#${clipId})` }, [result])
1314
- ])
1315
- );
1316
- }
1317
- }
1318
- }
1319
- return elements;
1320
- });
1321
- function getColorScaleInfo() {
1322
- return controller.getColorScaleInfo();
1323
- }
1324
- function applyPropertyAnimations(store) {
1325
- controller.applyPropertyAnimations(store);
1326
- }
1327
- function renderFrameCycle() {
1328
- controller.renderFrameCycle();
1329
- }
1330
- return { wrapperRef, groupRef, overlayRef, svgContent, hitTest, getPointPosition, handleDrilldownClick, prepareDrillOut, updateHoverOverlay, getColorScaleInfo, applyPropertyAnimations, renderFrameCycle };
1331
- }
1332
- function useAnimationProps(props, methods) {
1333
- const registration = computed(() => {
1334
- const p = toValue(props);
1335
- const animation = p.animation;
1336
- const rawEasing = animation ? animation.easing : void 0;
1337
- const resolvedEasing = typeof rawEasing === "function" ? rawEasing : rawEasing ? getEasing(rawEasing) : void 0;
1338
- const flattened = normalizeAnimationsMap(p.animations);
1339
- const propertyAnimations = flattened.length ? flattened : void 0;
1340
- return {
1341
- enabled: animation === false ? false : void 0,
1342
- duration: animation ? animation.duration : void 0,
1343
- easing: resolvedEasing,
1344
- limit: animation ? animation.limit : void 0,
1345
- propertyAnimations,
1346
- transitions: p.transitions
1347
- };
1348
- });
1349
- useCustomizationRegistration("animation", registration, methods);
1350
- }
1351
- function useChartContext(options) {
1352
- const { coreCtx, width, height, dir, theme, rendererDelegate, drilldownEnabled, onClickCb, onLegendClickCb, syncInfo, containerRef } = options;
1353
- const { coreChart, emitHandlerRef, setHover } = coreCtx;
1354
- const tooltip = shallowRef(null);
1355
- function handleCoreEmit(event, ...args) {
1356
- switch (event) {
1357
- case "tooltip-change": {
1358
- const val = args[0];
1359
- tooltip.value = val;
1360
- coreChart.$setState({ tooltip: val });
1361
- break;
1362
- }
1363
- case "hover-change": {
1364
- const hover = args[0];
1365
- hover.datasetId;
1366
- hover.index;
1367
- coreChart.$setState({ lastHover: { datasetId: hover.datasetId, index: hover.index } });
1368
- setHover(hover.datasetId, hover.index, hover.axisIdx, hover.axisX);
1369
- break;
1370
- }
1371
- case "cursor-change": {
1372
- const cursor = args[0];
1373
- coreChart.$setState({ cursor });
1374
- if (containerRef.value) containerRef.value.style.cursor = cursor;
1375
- break;
1376
- }
1377
- case "sync-broadcast": {
1378
- if (!syncInfo) break;
1379
- const broadcasts = args[0];
1380
- for (const b of broadcasts) {
1381
- syncInfo.bus.broadcastHighlight({
1382
- sourceId: syncInfo.chartId,
1383
- axis: b.axis,
1384
- normalized: b.normalized,
1385
- categoryIndex: b.categoryIndex,
1386
- sourceType: b.sourceType
1387
- });
1388
- }
1389
- break;
1390
- }
1391
- case "rect-hover-update": {
1392
- rendererDelegate.value?.updateHoverOverlay(null);
1393
- break;
1394
- }
1395
- case "click-callback": {
1396
- onClickCb.value?.(args[0]);
1397
- break;
1398
- }
1399
- case "dataset-toggle": {
1400
- coreChart.toggleDatasetVisibility(args[0]);
1401
- setHover(null, null);
1402
- break;
1403
- }
1404
- case "item-toggle": {
1405
- const { datasetId, index } = args[0];
1406
- coreChart.toggleItemVisibility(datasetId, index);
1407
- setHover(null, null);
1408
- break;
1409
- }
1410
- case "items-toggle": {
1411
- const { datasetId, indices } = args[0];
1412
- for (const i of indices) coreChart.toggleItemVisibility(datasetId, i);
1413
- setHover(null, null);
1414
- break;
1415
- }
1416
- case "legend-callback": {
1417
- onLegendClickCb.value?.(args[0]);
1418
- break;
1419
- }
1420
- case "legend-hover": {
1421
- const hover = args[0];
1422
- setHover(hover.datasetId, hover.index);
1423
- break;
1424
- }
1425
- }
1426
- }
1427
- emitHandlerRef.current = handleCoreEmit;
1428
- const stopPropsSync = watchEffect(() => {
1429
- coreChart.$setProps({
1430
- width: width.value,
1431
- height: height.value,
1432
- dir: dir.value,
1433
- theme: theme.value,
1434
- rendererDelegate: rendererDelegate.value,
1435
- drilldownEnabled: drilldownEnabled.value,
1436
- onClickCb: onClickCb.value,
1437
- onLegendClickCb: onLegendClickCb.value,
1438
- syncInfo
1439
- });
1440
- });
1441
- onBeforeUnmount(() => {
1442
- stopPropsSync();
1443
- });
1444
- const onMouseMove = (x, y) => coreChart.onMouseMove(x, y);
1445
- const onMouseLeave = () => coreChart.onMouseLeave();
1446
- const onClick = (x, y) => coreChart.onClick(x, y);
1447
- const onLegendClick = (item) => coreChart.onLegendClick(item);
1448
- const onLegendHover = (item) => coreChart.onLegendHover(item);
1449
- const onSyncedResult = (result) => coreChart.onSyncedResult(result);
1450
- return {
1451
- tooltip,
1452
- onMouseMove,
1453
- onMouseLeave,
1454
- onClick,
1455
- onLegendClick,
1456
- onLegendHover,
1457
- onSyncedResult
1458
- };
1459
- }
1460
- function useChartSyncCoordinator({
1461
- syncInfo,
1462
- datasets,
1463
- datasetVisibility,
1464
- theme,
1465
- zoomState,
1466
- hasCrosshair,
1467
- isSharedMode,
1468
- isCartesian,
1469
- isRect,
1470
- width,
1471
- height,
1472
- getZoomState,
1473
- rendererDelegate,
1474
- updateZoom,
1475
- setDatasetVisibility,
1476
- toggleItemVisibility,
1477
- onSyncedResult
1478
- }) {
1479
- if (!syncInfo) return;
1480
- const coordinator = new ChartSyncCoordinator(syncInfo);
1481
- watch([datasets, theme], () => coordinator.updateDatasets(datasets.value, theme.value), { immediate: true });
1482
- watch(zoomState, (zs) => coordinator.onZoomChange(zs));
1483
- watch(datasetVisibility, (vis) => coordinator.onVisibilityChange(vis));
1484
- const cleanup = coordinator.start({
1485
- getZoomState,
1486
- getRendererDelegate: () => rendererDelegate.value,
1487
- getIsCartesian: () => isCartesian.value,
1488
- getIsRect: () => isRect.value,
1489
- getHasCrosshair: () => hasCrosshair.value,
1490
- getIsSharedMode: () => isSharedMode.value,
1491
- getDatasets: () => datasets.value,
1492
- getDimensions: () => ({ width: width.value, height: height.value }),
1493
- applyZoom: updateZoom,
1494
- applyVisibility: setDatasetVisibility,
1495
- applyItemToggle: (seriesId, itemLabel) => toggleItemVisibility(seriesId, itemLabel),
1496
- applyHighlight: onSyncedResult
1497
- });
1498
- onBeforeUnmount(cleanup);
1499
- }
1500
- function useKeyboardNavigation(options) {
1501
- const { enabled, config, datasets, datasetVisibility, setHover, rendererDelegate, emitFocusMove, emitFocusLeave } = options;
1502
- const state = ref({ ...INACTIVE_STATE });
1503
- const announcement = ref("");
1504
- const controller = new KeyboardNavigationController();
1505
- controller.onNavigate = (datasetId, index, ann) => {
1506
- state.value = { active: true, focusedDatasetId: datasetId, focusedIndex: index, focusedSection: "series" };
1507
- announcement.value = ann;
1508
- const pos = emitFocusMove ? rendererDelegate.value?.getPointPosition(datasetId, index) ?? null : null;
1509
- if (emitFocusMove && pos) {
1510
- emitFocusMove(pos.x + pos.width / 2, pos.y + pos.height / 2);
1511
- } else {
1512
- setHover(datasetId, index);
1513
- }
1514
- };
1515
- function resetState() {
1516
- state.value = { ...INACTIVE_STATE };
1517
- announcement.value = "";
1518
- if (emitFocusLeave) {
1519
- emitFocusLeave();
1520
- } else {
1521
- setHover(null, null);
1522
- }
1523
- }
1524
- controller.onReset = resetState;
1525
- let pointerFocus = false;
1526
- function notifyPointerDown() {
1527
- pointerFocus = true;
1528
- }
1529
- const focusPosition = computed(() => {
1530
- const s = state.value;
1531
- if (!s.active || !s.focusedDatasetId || s.focusedIndex === null) return null;
1532
- return rendererDelegate.value?.getPointPosition(s.focusedDatasetId, s.focusedIndex) ?? null;
1533
- });
1534
- function onKeyDown(e) {
1535
- if (!enabled.value) return;
1536
- const handled = controller.handleKeyDown(e.key, datasets.value, datasetVisibility.value, config.value);
1537
- if (handled) e.preventDefault();
1538
- }
1539
- function onMouseMove() {
1540
- controller.handleMouseMove();
1541
- }
1542
- function onFocus() {
1543
- if (!enabled.value) return;
1544
- if (pointerFocus) {
1545
- pointerFocus = false;
1546
- return;
1547
- }
1548
- controller.activate(datasets.value, datasetVisibility.value, config.value);
1549
- }
1550
- function onBlur() {
1551
- pointerFocus = false;
1552
- controller.reset();
1553
- resetState();
1554
- }
1555
- watch(enabled, (val) => {
1556
- if (!val) {
1557
- controller.reset();
1558
- resetState();
1559
- }
1560
- });
1561
- onUnmounted(() => {
1562
- controller.destroy();
1563
- });
1564
- return { state, focusPosition, announcement, onKeyDown, onMouseMove, onFocus, onBlur, notifyPointerDown };
1565
- }
1566
- function useResponsiveConfig(width, height, responsiveFeature, globalFont) {
1567
- const config = computed(() => {
1568
- const tier = getResponsiveTier(width.value, responsiveFeature.value?.breakpoints);
1569
- const defaults = responsiveFeature.value?.disableAutoAdaptive ? getAdaptiveDefaults("lg", globalFont) : getAdaptiveDefaults(tier, globalFont);
1570
- const ruleOverrides = responsiveFeature.value?.rules ? evaluateResponsiveRules(responsiveFeature.value.rules, width.value, height.value) : {};
1571
- return { tier, defaults, ruleOverrides };
1572
- });
1573
- return {
1574
- defaults: computed(() => config.value.defaults),
1575
- ruleOverrides: computed(() => config.value.ruleOverrides)
1576
- };
1577
- }
1578
- function useResponsiveDimensions(options) {
1579
- const containerRef = ref(null);
1580
- const width = ref(unref(options.width) ?? 400);
1581
- const height = ref(unref(options.height) ?? 400);
1582
- const controller = new ResponsiveDimensionsController();
1583
- onMounted(() => {
1584
- if (!containerRef.value) return;
1585
- if (unref(options.responsive)) {
1586
- controller.onDimensionsChange = (w, h2) => {
1587
- if (width.value !== w || height.value !== h2) {
1588
- width.value = w;
1589
- height.value = h2;
1590
- options.onResize?.(w, h2);
1591
- }
1592
- };
1593
- controller.attach(containerRef.value, {
1594
- debounceWithRAF: options.debounceWithRAF ?? true,
1595
- debounceDelay: unref(options.debounceDelay),
1596
- aspectRatio: unref(options.aspectRatio),
1597
- maxDimensions: unref(options.maxDimensions),
1598
- maxWidth: unref(options.width),
1599
- maxHeight: unref(options.height)
1600
- });
1601
- } else if (!unref(options.width) && !unref(options.height)) {
1602
- const w = containerRef.value.offsetWidth;
1603
- const h2 = containerRef.value.offsetHeight;
1604
- if (w > 0) width.value = w;
1605
- if (h2 > 0) height.value = h2;
1606
- options.onResize?.(width.value, height.value);
1607
- }
1608
- });
1609
- watch([() => unref(options.width), () => unref(options.height)], ([newW, newH]) => {
1610
- if (!unref(options.responsive)) {
1611
- if (newW !== void 0 && width.value !== newW) width.value = newW;
1612
- if (newH !== void 0 && height.value !== newH) height.value = newH;
1613
- }
1614
- });
1615
- onUnmounted(() => {
1616
- controller.destroy();
1617
- });
1618
- return { containerRef, width, height };
1619
- }
1620
- function useZoomPan(options) {
1621
- const { zoomConfig, containerRef, getPlotArea, getScales, getOriginalDomains, isCartesian } = options;
1622
- const zoomState = shallowRef(createInitialZoomState());
1623
- const selectionRect = ref(null);
1624
- const isDragging = ref(false);
1625
- const isZoomedRef = ref(false);
1626
- const getConfig = () => {
1627
- const cfg = zoomConfig.value;
1628
- return {
1629
- mode: cfg?.mode ?? "x",
1630
- wheelCfg: normalizeSubConfig(cfg?.wheel, { enabled: true, speed: 0.1 }),
1631
- dragCfg: normalizeSubConfig(cfg?.drag, { enabled: true }),
1632
- panCfg: normalizeSubConfig(cfg?.pan, { enabled: true, modifierKey: "shift" }),
1633
- pinchCfg: normalizeSubConfig(cfg?.pinch, { enabled: true }),
1634
- limits: cfg?.limits
1635
- };
1636
- };
1637
- let controller = null;
1638
- const buildDeps = () => ({
1639
- getPlotArea,
1640
- getScales,
1641
- getOriginalDomains,
1642
- getConfig,
1643
- getZoomState: () => controller.getZoomState(),
1644
- getCurrentWindow: (axis) => controller.getCurrentWindow(axis)
1645
- });
1646
- function ensureController() {
1647
- if (controller) return controller;
1648
- controller = new ZoomPanController(buildDeps());
1649
- controller.onSettle = (state) => {
1650
- zoomState.value = state;
1651
- isZoomedRef.value = isZoomed(state);
1652
- zoomConfig.value?.onZoomChange?.(state);
1653
- };
1654
- return controller;
1655
- }
1656
- let cleanup = null;
1657
- const attachListeners = () => {
1658
- cleanup?.();
1659
- cleanup = null;
1660
- const enabled = !!zoomConfig.value && isCartesian.value;
1661
- if (!enabled) return;
1662
- const container = containerRef.value;
1663
- if (!container) return;
1664
- const ctrl = ensureController();
1665
- if (!ctrl) return;
1666
- ctrl.updateDeps(buildDeps());
1667
- cleanup = ctrl.attach(container, {
1668
- onDragging: (v) => isDragging.value = v,
1669
- onSelectionRect: (r) => selectionRect.value = r
1670
- });
1671
- };
1672
- watch([zoomConfig, containerRef, isCartesian], attachListeners, { flush: "post", immediate: true });
1673
- watch(zoomConfig, (cfg) => {
1674
- if (!cfg && controller && isZoomed(controller.getZoomState())) controller.resetZoom();
1675
- });
1676
- onBeforeUnmount(() => {
1677
- cleanup?.();
1678
- cleanup = null;
1679
- controller?.destroyZoomState();
1680
- });
1681
- return {
1682
- zoomState,
1683
- resetZoom: () => controller?.resetZoom(),
1684
- updateZoom: (s) => controller?.updateZoom(s),
1685
- getZoomState: () => controller?.getZoomState() ?? zoomState.value,
1686
- isZoomed: isZoomedRef,
1687
- isDragging,
1688
- selectionRect
1689
- };
1690
- }
1691
-
1692
- export { provideCartesianFrame, provideChartLayers, provideFamilyRenderers, provideRadialFrame, registerChartLayer, registerFamilyRenderer, registerKeyboardController, registerNavigatorRenderer, registerZoomController, useAnimationProps, useAxisComponentBase, useCandlestickRenderer, useCartesianAnimation, useCartesianFrame, useCartesianFrameRegistration, useCartesianLayout, useChartContext, useChartLayers, useChartSync, useChartSyncCoordinator, useDatasetAnimationRegistration, useDatasetRegistration, useDrilldownState, useHeatmapRenderer, useItemCollector, useKeyboardNavigation, useLineRenderer, usePieRenderer, usePolarRenderer, usePropertyAnimations, useRadarRenderer, useRadialFrameRegistration, useResponsiveConfig, useResponsiveDimensions, useScatterRenderer, useTreemapRenderer, useZoomPan };