@primeui/vue-chart 0.0.1-alpha.1 → 1.0.0-rc.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.
- package/LICENSE.md +35 -0
- package/README.md +64 -0
- package/dist/CartesianRenderer.rich.spec.d.ts +1 -0
- package/dist/Chart.features.spec.d.ts +1 -0
- package/dist/Chart.interactions.spec.d.ts +1 -0
- package/dist/Chart.pointEvents.spec.d.ts +1 -0
- package/dist/Chart.vue.d.ts +5 -1
- package/dist/ChartCanvas.mjs +15 -14
- package/dist/ChartCanvas.pipeline.spec.d.ts +1 -0
- package/dist/ChartCanvas.vue.d.ts +8 -4
- package/dist/ChartGroup.sync.spec.d.ts +1 -0
- package/dist/ChartLegend.spec.d.ts +1 -0
- package/dist/ChartSvg.containers.spec.d.ts +1 -0
- package/dist/ChartSvg.declarative.spec.d.ts +1 -0
- package/dist/ChartSvg.export-menu.spec.d.ts +1 -0
- package/dist/ChartSvg.hover.spec.d.ts +1 -0
- package/dist/ChartSvg.mjs +15 -14
- package/dist/ChartSvg.renderers.spec.d.ts +1 -0
- package/dist/ChartSvg.vue.d.ts +8 -4
- package/dist/ColorLegendRenderer.branches.spec.d.ts +1 -0
- package/dist/ColorLegendRenderer.spec.d.ts +1 -0
- package/dist/LegendRenderer.spec.d.ts +1 -0
- package/dist/NavigatorRenderer.spec.d.ts +1 -0
- package/dist/RadialHeatmap.rich.spec.d.ts +1 -0
- package/dist/TooltipRenderer.spec.d.ts +1 -0
- package/dist/{chunk-6S4JMPKC.mjs → chunks/chunk-2NZ3PUWW.mjs} +2 -2
- package/dist/{chunk-RRHYGSK6.mjs → chunks/chunk-2TOEQNJ6.mjs} +2 -2
- package/dist/{chunk-GX2MK6VT.mjs → chunks/chunk-36DHPBYP.mjs} +25 -23
- package/dist/{chunk-RSTIA3KM.mjs → chunks/chunk-3DINEX6C.mjs} +2 -1
- package/dist/{chunk-PJVOZSPF.mjs → chunks/chunk-3JA5JAHF.mjs} +2 -2
- package/dist/{chunk-KOWFD2AE.mjs → chunks/chunk-3PJULFR5.mjs} +22 -21
- package/dist/chunks/chunk-3X27K5XC.mjs +236 -0
- package/dist/chunks/chunk-3XOLEGDL.mjs +182 -0
- package/dist/{chunk-372K2BMN.mjs → chunks/chunk-4EU72IBK.mjs} +71 -23
- package/dist/{chunk-PSSXPTLQ.mjs → chunks/chunk-4SLSYRNY.mjs} +6 -6
- package/dist/{chunk-4NJ2PSHV.mjs → chunks/chunk-5ZLVNQ2L.mjs} +7 -4
- package/dist/{chunk-O6L3PNFC.mjs → chunks/chunk-6Z4MZIJI.mjs} +2 -2
- package/dist/chunks/chunk-7EZEZMGG.mjs +22 -0
- package/dist/chunks/chunk-ADAGGXFG.mjs +166 -0
- package/dist/{chunk-YRKAI2R2.mjs → chunks/chunk-AKMQHU5T.mjs} +15 -14
- package/dist/{chunk-ZRCOVQQM.mjs → chunks/chunk-BSROML7P.mjs} +2 -2
- package/dist/{chunk-WYV2MHP6.mjs → chunks/chunk-CGFPDWB4.mjs} +1 -1
- package/dist/{chunk-4CRHCZV3.mjs → chunks/chunk-CMJXLIEY.mjs} +125 -9
- package/dist/{chunk-42J32DPD.mjs → chunks/chunk-CRIB3I3L.mjs} +1 -1
- package/dist/{chunk-WKSQR6L5.mjs → chunks/chunk-CW2KYVYO.mjs} +31 -8
- package/dist/{chunk-644ROAHU.mjs → chunks/chunk-DDRSIMLE.mjs} +33 -12
- package/dist/{chunk-32XIRBZ7.mjs → chunks/chunk-DXKAPWMO.mjs} +2 -2
- package/dist/{chunk-44BAFHPK.mjs → chunks/chunk-EWDMF46D.mjs} +10 -5
- package/dist/{chunk-E2U4W5FW.mjs → chunks/chunk-F7EK5D6J.mjs} +11 -11
- package/dist/{chunk-ZHFL3RYO.mjs → chunks/chunk-GE2Y2FHS.mjs} +6 -6
- package/dist/{chunk-AAX7FOW3.mjs → chunks/chunk-GIDIMIWE.mjs} +11 -11
- package/dist/{chunk-NLXOJSKK.mjs → chunks/chunk-GLFXRR7N.mjs} +29 -5
- package/dist/{chunk-W5M3BR6N.mjs → chunks/chunk-GV3CY6CQ.mjs} +1 -1
- package/dist/{chunk-CDXF6ZTL.mjs → chunks/chunk-HH5FUUXX.mjs} +1 -1
- package/dist/{chunk-RQURY2H3.mjs → chunks/chunk-HHZFGQN2.mjs} +2 -2
- package/dist/{chunk-2D3PWFR2.mjs → chunks/chunk-HVLFOABV.mjs} +4 -4
- package/dist/chunks/chunk-I2BWSDNR.mjs +832 -0
- package/dist/{chunk-MDA22SIZ.mjs → chunks/chunk-IFZSHQDZ.mjs} +2 -2
- package/dist/chunks/chunk-IRGQNA5W.mjs +289 -0
- package/dist/chunks/chunk-JBWL3G7O.mjs +86 -0
- package/dist/{chunk-56NMBNNX.mjs → chunks/chunk-JPKNWLLP.mjs} +3 -3
- package/dist/{chunk-XBDNMPF7.mjs → chunks/chunk-JVH4MDKX.mjs} +2 -2
- package/dist/chunks/chunk-KNNYJD4D.mjs +14 -0
- package/dist/{chunk-AUI5R4DA.mjs → chunks/chunk-L73MEG22.mjs} +2 -2
- package/dist/{chunk-K326BBF7.mjs → chunks/chunk-L74BEYTD.mjs} +38 -17
- package/dist/{chunk-DYVFVVTO.mjs → chunks/chunk-LJZCE7LQ.mjs} +102 -6
- package/dist/{chunk-YGHWUR7K.mjs → chunks/chunk-LP2YESP6.mjs} +1 -1
- package/dist/{chunk-WA735Y26.mjs → chunks/chunk-MGUGO3RV.mjs} +1 -1
- package/dist/{chunk-DOOXGOOB.mjs → chunks/chunk-OJHEN5FG.mjs} +96 -5
- package/dist/{chunk-ZNINPVG7.mjs → chunks/chunk-ON2FAZTD.mjs} +1 -1
- package/dist/{chunk-DLUFOM5K.mjs → chunks/chunk-PCBF6FSQ.mjs} +11 -11
- package/dist/{chunk-72KINEJ6.mjs → chunks/chunk-PR6MTWPJ.mjs} +10 -5
- package/dist/{chunk-FQTWLAVA.mjs → chunks/chunk-QJCMFAHB.mjs} +1 -1
- package/dist/{chunk-62NGBLQ7.mjs → chunks/chunk-QONZ3SCZ.mjs} +1 -1
- package/dist/{chunk-HANSF33Z.mjs → chunks/chunk-QOWKMWNO.mjs} +1 -1
- package/dist/{chunk-GA4VV5V4.mjs → chunks/chunk-R4AZOPXC.mjs} +1 -1
- package/dist/{chunk-5DWO3G33.mjs → chunks/chunk-SGLTVJUA.mjs} +35 -21
- package/dist/{chunk-5FTUGKPC.mjs → chunks/chunk-TRGN3ZMM.mjs} +5 -5
- package/dist/{chunk-RSAZ7V5Z.mjs → chunks/chunk-TZ23VBFU.mjs} +2 -2
- package/dist/{chunk-4UVPCLJ7.mjs → chunks/chunk-U6X3GVJ3.mjs} +1 -1
- package/dist/{chunk-J2P5JBHC.mjs → chunks/chunk-UOMQNZMT.mjs} +1 -1
- package/dist/{chunk-4THCGGER.mjs → chunks/chunk-UOZFNTVQ.mjs} +2 -2
- package/dist/{chunk-TIV2FI4S.mjs → chunks/chunk-WVNDZNMV.mjs} +2 -2
- package/dist/{chunk-GFC24374.mjs → chunks/chunk-X4NWFK7L.mjs} +5 -5
- package/dist/{chunk-FFBK7Q3W.mjs → chunks/chunk-YI3GLQYF.mjs} +67 -4
- package/dist/{chunk-HTZVV6VV.mjs → chunks/chunk-YZQS2YBK.mjs} +8 -6
- package/dist/{chunk-PQV55JYI.mjs → chunks/chunk-ZLD5VNMP.mjs} +2 -2
- package/dist/components/charts/ChartBar.mjs +13 -13
- package/dist/components/charts/ChartCandlestick.mjs +11 -11
- package/dist/components/charts/ChartHeatmap.mjs +11 -11
- package/dist/components/charts/ChartLine.mjs +12 -11
- package/dist/components/charts/ChartPie.mjs +12 -11
- package/dist/components/charts/ChartPolar.mjs +13 -11
- package/dist/components/charts/ChartRadar.mjs +13 -11
- package/dist/components/charts/ChartScatter.mjs +12 -11
- package/dist/components/charts/ChartTreemap.mjs +10 -10
- package/dist/components/containers/ChartDecimation.mjs +6 -6
- package/dist/components/containers/ChartGroup.mjs +4 -4
- package/dist/components/containers/ChartOverlap.mjs +5 -5
- package/dist/components/containers/ChartRange.mjs +6 -6
- package/dist/components/containers/ChartStacked.mjs +6 -6
- package/dist/components/containers/ChartWaterfall.mjs +5 -5
- package/dist/components/customizations/ChartAccessibility.mjs +9 -9
- package/dist/components/customizations/ChartAnnotation.mjs +5 -5
- package/dist/components/customizations/ChartAxisCategory.mjs +3 -3
- package/dist/components/customizations/ChartAxisGroup.mjs +3 -3
- package/dist/components/customizations/ChartBreadcrumb.mjs +6 -6
- package/dist/components/customizations/ChartCaption.mjs +9 -9
- package/dist/components/customizations/ChartColorLegend.mjs +9 -9
- package/dist/components/customizations/ChartDataLabels.mjs +9 -9
- package/dist/components/customizations/ChartExportMenu.mjs +9 -9
- package/dist/components/customizations/ChartHover.mjs +9 -9
- package/dist/components/customizations/ChartLegend.mjs +9 -9
- package/dist/components/customizations/ChartNavigator.mjs +10 -10
- package/dist/components/customizations/ChartReferenceBand.mjs +5 -5
- package/dist/components/customizations/ChartReferenceLine.mjs +5 -5
- package/dist/components/customizations/ChartResponsive.mjs +9 -9
- package/dist/components/customizations/ChartTitle.mjs +9 -9
- package/dist/components/customizations/ChartTooltip.mjs +9 -9
- package/dist/components/customizations/ChartXAxis.mjs +10 -10
- package/dist/components/customizations/ChartYAxis.mjs +10 -10
- package/dist/components/customizations/ChartZoom.mjs +9 -9
- package/dist/components/items/ChartItem.mjs +3 -3
- package/dist/components/items/ChartTreemapGroup.mjs +5 -5
- package/dist/components/renderers/CartesianRenderer.mjs +9 -9
- package/dist/components/renderers/CartesianRenderer.vue.d.ts +2 -0
- package/dist/components/renderers/ColorLegendRenderer.mjs +2 -2
- package/dist/components/renderers/LegendRenderer.mjs +3 -3
- package/dist/components/renderers/NavigatorRenderer.mjs +5 -5
- package/dist/components/renderers/RadialRenderer.mjs +9 -9
- package/dist/components/renderers/RadialRenderer.vue.d.ts +1 -1
- package/dist/components/renderers/RectRenderer.mjs +9 -9
- package/dist/components/renderers/RectRenderer.vue.d.ts +1 -1
- package/dist/components/renderers/TooltipRenderer.mjs +4 -4
- package/dist/components/renderers/layers/BarLayerCanvas.mjs +10 -10
- package/dist/components/renderers/layers/BarLayerSvg.mjs +10 -10
- package/dist/components/renderers/layers/CandlestickLayer.mjs +9 -9
- package/dist/components/renderers/layers/HeatmapLayer.mjs +9 -9
- package/dist/components/renderers/layers/LineLayer.mjs +10 -9
- package/dist/components/renderers/layers/PieLayer.mjs +7 -9
- package/dist/components/renderers/layers/PolarLayer.mjs +8 -9
- package/dist/components/renderers/layers/RadarLayer.mjs +8 -9
- package/dist/components/renderers/layers/ScatterLayer.mjs +10 -9
- package/dist/composables/index.d.ts +0 -8
- package/dist/composables/useAnimationProps.d.ts +2 -5
- package/dist/composables/useChartSync.spec.d.ts +1 -0
- package/dist/composables/useChartSyncCoordinator.spec.d.ts +1 -0
- package/dist/composables/useHeatmapRenderer.spec.d.ts +1 -0
- package/dist/composables/usePolarRenderer.spec.d.ts +1 -0
- package/dist/composables/useResponsiveConfig.d.ts +1 -1
- package/dist/composables/useResponsiveDimensions.spec.d.ts +1 -0
- package/dist/composables/useTreemapRenderer.spec.d.ts +1 -0
- package/dist/context/ChartContext.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +69 -66
- package/dist/namespace.mjs +69 -112
- package/dist/release-date.d.ts +1 -1
- package/dist/types/animation.types.d.ts +2 -0
- package/dist/types/bar.types.d.ts +2 -1
- package/dist/types/candlestick.types.d.ts +0 -1
- package/dist/types/heatmap.types.d.ts +0 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/item.types.d.ts +0 -1
- package/dist/types/line.types.d.ts +4 -1
- package/dist/types/scatter.types.d.ts +3 -2
- package/dist/useChartContext.spec.d.ts +1 -0
- package/package.json +9 -14
- package/LICENSE +0 -23
- package/dist/chunk-54DLUFIA.mjs +0 -96
- package/dist/chunk-CQHNYT2V.mjs +0 -1692
- package/dist/chunk-JKK3D33U.mjs +0 -64
- package/dist/chunk-UO27BCRL.mjs +0 -86
- package/dist/chunk-VWABO23U.mjs +0 -143
- /package/dist/{chunk-FZ3PZ66C.mjs → chunks/chunk-4Q3QUNX6.mjs} +0 -0
- /package/dist/{chunk-5SRBQVU5.mjs → chunks/chunk-EHSDNH7K.mjs} +0 -0
- /package/dist/{chunk-LD57I4SY.mjs → chunks/chunk-H4HLHGUW.mjs} +0 -0
- /package/dist/{chunk-TEOO4OLV.mjs → chunks/chunk-L6N5IYAJ.mjs} +0 -0
- /package/dist/{chunk-E4ROAOPT.mjs → chunks/chunk-S4YR4YK7.mjs} +0 -0
- /package/dist/{chunk-7P6ASYW6.mjs → chunks/chunk-VIHIR2BE.mjs} +0 -0
- /package/dist/{chunk-J43KLCZF.mjs → chunks/chunk-ZH4A4L6W.mjs} +0 -0
|
@@ -0,0 +1,832 @@
|
|
|
1
|
+
import { STACKED_CONTEXT_KEY, RANGE_CONTEXT_KEY } from './chunk-L6N5IYAJ.mjs';
|
|
2
|
+
import { useCustomizationRegistration, useChartRefreshHook } from './chunk-ZLD5VNMP.mjs';
|
|
3
|
+
import { useChartMethods } from './chunk-QOWKMWNO.mjs';
|
|
4
|
+
import { SYNC_BUS_KEY } from './chunk-H4HLHGUW.mjs';
|
|
5
|
+
import { ITEM_COLLECTOR_KEY } from './chunk-4Q3QUNX6.mjs';
|
|
6
|
+
import { getCurrentInstance, computed, ref, watch, onUnmounted, toValue, watchEffect, inject, shallowRef, onMounted, onScopeDispose, shallowReactive, provide, onBeforeUnmount, unref } from 'vue';
|
|
7
|
+
import { normalizeAnimationsMap, setupPropertyAnimations, createAnimationDriver, AnimationRegistry, buildStaticFrame, renderWithCompositor, driveCartesianUpdate, resolveHoverRepaintFrame, cancelDriverRafs, CartesianLayoutController, resolveSyncConfig, DatasetRegistrationController, DrilldownStateController, ItemCollector, getEasing, ChartSyncCoordinator, INACTIVE_STATE, KeyboardNavigationController, getResponsiveTier, getAdaptiveDefaults, evaluateResponsiveRules, ResponsiveDimensionsController, createInitialZoomState, configureCanvasHiDPI, renderCartesianOverlay, buildAnimatedFrame, isZoomed, AxisRegistrationController, AxisTransitionState, ZoomPanController, normalizeSubConfig } from '@primeui/chart-core';
|
|
8
|
+
|
|
9
|
+
function useAxisRegistration(axis, id, props) {
|
|
10
|
+
const methods = useChartMethods();
|
|
11
|
+
const controller = new AxisRegistrationController({
|
|
12
|
+
id: id.value,
|
|
13
|
+
axis,
|
|
14
|
+
registerX: (cid, cprops) => methods.registerXAxis(cid, cprops),
|
|
15
|
+
unregisterX: (cid) => methods.unregisterXAxis(cid),
|
|
16
|
+
updateX: (cid, cprops) => methods.updateXAxis(cid, cprops),
|
|
17
|
+
registerY: (cid, cprops) => methods.registerYAxis(cid, cprops),
|
|
18
|
+
unregisterY: (cid) => methods.unregisterYAxis(cid),
|
|
19
|
+
updateY: (cid, cprops) => methods.updateYAxis(cid, cprops)
|
|
20
|
+
});
|
|
21
|
+
watch(
|
|
22
|
+
props,
|
|
23
|
+
(newProps) => {
|
|
24
|
+
controller.update(newProps);
|
|
25
|
+
},
|
|
26
|
+
{ deep: false }
|
|
27
|
+
);
|
|
28
|
+
onMounted(() => {
|
|
29
|
+
controller.mount(props.value);
|
|
30
|
+
});
|
|
31
|
+
useChartRefreshHook(() => {
|
|
32
|
+
controller.forceRefresh(props.value);
|
|
33
|
+
});
|
|
34
|
+
onUnmounted(() => {
|
|
35
|
+
controller.unmount();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/composables/useAxisComponentBase.ts
|
|
40
|
+
function useAxisComponentBase(axis, axisId, props, hasChildren) {
|
|
41
|
+
const instance = getCurrentInstance();
|
|
42
|
+
const vnodeProps = instance?.vnode.props || {};
|
|
43
|
+
const axisProps = computed(() => {
|
|
44
|
+
const boolOrUndef = (v, propName) => {
|
|
45
|
+
const kebab = propName.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
46
|
+
if (propName in vnodeProps || kebab in vnodeProps) return v;
|
|
47
|
+
return void 0;
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
label: props.label,
|
|
51
|
+
position: props.position,
|
|
52
|
+
type: props.type,
|
|
53
|
+
min: props.min,
|
|
54
|
+
max: props.max,
|
|
55
|
+
tickCount: props.tickCount,
|
|
56
|
+
tickFormat: props.tickFormat,
|
|
57
|
+
tickRotation: props.tickRotation,
|
|
58
|
+
tickStyle: props.tickStyle,
|
|
59
|
+
render: props.render,
|
|
60
|
+
renderTick: props.renderTick,
|
|
61
|
+
gridLines: boolOrUndef(props.gridLines, "gridLines"),
|
|
62
|
+
color: props.color,
|
|
63
|
+
gridColor: props.gridColor,
|
|
64
|
+
gridStyle: props.gridStyle,
|
|
65
|
+
gridStrokeWidth: props.gridStrokeWidth,
|
|
66
|
+
gridOpacity: props.gridOpacity,
|
|
67
|
+
gridShape: props.gridShape,
|
|
68
|
+
category: props.category,
|
|
69
|
+
tickInterval: props.tickInterval,
|
|
70
|
+
minorGridLines: boolOrUndef(props.minorGridLines, "minorGridLines"),
|
|
71
|
+
minorGridColor: props.minorGridColor,
|
|
72
|
+
minorGridStrokeWidth: props.minorGridStrokeWidth,
|
|
73
|
+
minorGridOpacity: props.minorGridOpacity,
|
|
74
|
+
minorGridCount: props.minorGridCount,
|
|
75
|
+
minorGridStyle: props.minorGridStyle,
|
|
76
|
+
alternateGridColor: props.alternateGridColor,
|
|
77
|
+
alternateGridOpacity: props.alternateGridOpacity,
|
|
78
|
+
scale: props.scale,
|
|
79
|
+
timezone: props.timezone,
|
|
80
|
+
dateTimeFormats: props.dateTimeFormats,
|
|
81
|
+
tickConfig: props.tickConfig,
|
|
82
|
+
minUnit: props.minUnit,
|
|
83
|
+
gapless: boolOrUndef(props.gapless, "gapless"),
|
|
84
|
+
grouping: props.grouping,
|
|
85
|
+
autoRotate: boolOrUndef(props.autoRotate, "autoRotate"),
|
|
86
|
+
autoRotateAngle: props.autoRotateAngle,
|
|
87
|
+
labelMinSpacing: props.labelMinSpacing,
|
|
88
|
+
startFromZero: boolOrUndef(props.startFromZero, "startFromZero"),
|
|
89
|
+
reversed: boolOrUndef(props.reversed, "reversed"),
|
|
90
|
+
softMin: props.softMin,
|
|
91
|
+
softMax: props.softMax,
|
|
92
|
+
tickPosition: props.tickPosition,
|
|
93
|
+
minorTicks: boolOrUndef(props.minorTicks, "minorTicks"),
|
|
94
|
+
minorTickLength: props.minorTickLength,
|
|
95
|
+
minorTickColor: props.minorTickColor,
|
|
96
|
+
minorTickStrokeWidth: props.minorTickStrokeWidth,
|
|
97
|
+
showFirstLabel: boolOrUndef(props.showFirstLabel, "showFirstLabel"),
|
|
98
|
+
showLastLabel: boolOrUndef(props.showLastLabel, "showLastLabel"),
|
|
99
|
+
showLine: boolOrUndef(props.showLine, "showLine"),
|
|
100
|
+
showTicks: boolOrUndef(props.showTicks, "showTicks"),
|
|
101
|
+
showLabels: boolOrUndef(props.showLabels, "showLabels"),
|
|
102
|
+
autoSkip: boolOrUndef(props.autoSkip, "autoSkip"),
|
|
103
|
+
visible: boolOrUndef(props.visible, "visible"),
|
|
104
|
+
labelFontSize: props.labelFontSize,
|
|
105
|
+
chartPaddingMin: props.chartPaddingMin,
|
|
106
|
+
chartPaddingMax: props.chartPaddingMax,
|
|
107
|
+
minGridDistance: props.minGridDistance
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
useAxisRegistration(axis, axisId, axisProps);
|
|
111
|
+
const methods = useChartMethods();
|
|
112
|
+
const groups = ref([]);
|
|
113
|
+
const groupCollector = {
|
|
114
|
+
addGroup: (group) => {
|
|
115
|
+
const existing = groups.value.findIndex((g) => g.label === group.label);
|
|
116
|
+
if (existing >= 0) {
|
|
117
|
+
const next = [...groups.value];
|
|
118
|
+
next[existing] = group;
|
|
119
|
+
groups.value = next;
|
|
120
|
+
} else {
|
|
121
|
+
groups.value = [...groups.value, group];
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
removeGroup: (label) => {
|
|
125
|
+
groups.value = groups.value.filter((g) => g.label !== label);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
if (hasChildren) {
|
|
129
|
+
const featureKey = `axisGroup:${axis}:${axisId.value}`;
|
|
130
|
+
watch(groups, (newGroups) => {
|
|
131
|
+
if (newGroups.length > 0) {
|
|
132
|
+
methods.registerCustomization(featureKey, { groups: [...newGroups], axis });
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
onUnmounted(() => {
|
|
136
|
+
methods.unregisterCustomization(featureKey);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return { collectorValue: groupCollector, hasChildren: hasChildren ?? false };
|
|
140
|
+
}
|
|
141
|
+
function useDatasetAnimationRegistration(datasetId, animations) {
|
|
142
|
+
const payload = computed(() => {
|
|
143
|
+
const id2 = toValue(datasetId);
|
|
144
|
+
const map = toValue(animations);
|
|
145
|
+
if (!id2) return {};
|
|
146
|
+
const configs = normalizeAnimationsMap(map, { datasetId: id2 });
|
|
147
|
+
return { propertyAnimations: configs.length ? configs : void 0 };
|
|
148
|
+
});
|
|
149
|
+
const id = toValue(datasetId);
|
|
150
|
+
const featureKey = id ? `animation:${id}` : "animation:__unscoped__";
|
|
151
|
+
useCustomizationRegistration(featureKey, payload);
|
|
152
|
+
}
|
|
153
|
+
function usePropertyAnimations(configs, registry, store, onPropertyComplete) {
|
|
154
|
+
watchEffect((onCleanup) => {
|
|
155
|
+
const resolved = toValue(configs);
|
|
156
|
+
if (!resolved?.length || !registry || !store) return;
|
|
157
|
+
onCleanup(setupPropertyAnimations(resolved, registry, store, onPropertyComplete));
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function useAxisTransition() {
|
|
161
|
+
return new AxisTransitionState();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/composables/useCartesianAnimation.ts
|
|
165
|
+
function useCartesianAnimation(options) {
|
|
166
|
+
const {
|
|
167
|
+
layoutData,
|
|
168
|
+
renderer,
|
|
169
|
+
canvasEl,
|
|
170
|
+
overlayCanvasEl,
|
|
171
|
+
markerOverlays,
|
|
172
|
+
groupRef,
|
|
173
|
+
gridGroupRef,
|
|
174
|
+
hover,
|
|
175
|
+
features,
|
|
176
|
+
width,
|
|
177
|
+
height,
|
|
178
|
+
renderFrame: renderFrameParam,
|
|
179
|
+
compositor,
|
|
180
|
+
dir,
|
|
181
|
+
globalFont,
|
|
182
|
+
locale,
|
|
183
|
+
theme,
|
|
184
|
+
customTickOverlayRefs,
|
|
185
|
+
skipHoverRepaint,
|
|
186
|
+
isZoomed,
|
|
187
|
+
isDragging,
|
|
188
|
+
propertyAnimations,
|
|
189
|
+
animStoreRef,
|
|
190
|
+
onAnimFrame,
|
|
191
|
+
onPropertyComplete
|
|
192
|
+
} = options;
|
|
193
|
+
const driver = createAnimationDriver();
|
|
194
|
+
const axisTransition = useAxisTransition();
|
|
195
|
+
const canvasRegistry = new AnimationRegistry();
|
|
196
|
+
function paintOverlay(axisLayouts, cartesianArea) {
|
|
197
|
+
const overlay = overlayCanvasEl?.value;
|
|
198
|
+
if (!overlay) return;
|
|
199
|
+
configureCanvasHiDPI(overlay, width.value, height.value);
|
|
200
|
+
renderCartesianOverlay({
|
|
201
|
+
canvas: overlay,
|
|
202
|
+
axisLayouts,
|
|
203
|
+
hover: hover.value,
|
|
204
|
+
registry: canvasRegistry,
|
|
205
|
+
cartesianArea,
|
|
206
|
+
markerOverlays: markerOverlays?.value
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
canvasRegistry.setRepaintCallback(() => {
|
|
210
|
+
if (renderer === "svg") {
|
|
211
|
+
onAnimFrame?.();
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (!driver.cachedLayout) return;
|
|
215
|
+
if (overlayCanvasEl?.value) {
|
|
216
|
+
paintOverlay(axisTransition.apply(driver.cachedLayout.axisLayouts), driver.cachedLayout.cartesianArea);
|
|
217
|
+
} else if (!onAnimFrame) {
|
|
218
|
+
renderFrame(buildStatic());
|
|
219
|
+
}
|
|
220
|
+
onAnimFrame?.();
|
|
221
|
+
});
|
|
222
|
+
usePropertyAnimations(propertyAnimations, canvasRegistry, animStoreRef?.value ?? null, onPropertyComplete);
|
|
223
|
+
const stopOverlayCanvasWatch = overlayCanvasEl ? watch(overlayCanvasEl, (el) => {
|
|
224
|
+
if (!el || !driver.cachedLayout) return;
|
|
225
|
+
paintOverlay(axisTransition.apply(driver.cachedLayout.axisLayouts), driver.cachedLayout.cartesianArea);
|
|
226
|
+
}) : null;
|
|
227
|
+
const stopMarkerOverlaysWatch = markerOverlays && overlayCanvasEl ? watch(markerOverlays, () => {
|
|
228
|
+
if (!driver.cachedLayout || !overlayCanvasEl.value) return;
|
|
229
|
+
paintOverlay(axisTransition.apply(driver.cachedLayout.axisLayouts), driver.cachedLayout.cartesianArea);
|
|
230
|
+
}) : null;
|
|
231
|
+
function getFrameCtx() {
|
|
232
|
+
return {
|
|
233
|
+
renderer,
|
|
234
|
+
theme: theme(),
|
|
235
|
+
group: groupRef.value,
|
|
236
|
+
gridGroup: gridGroupRef.value,
|
|
237
|
+
canvas: canvasEl.value,
|
|
238
|
+
customTickOverlayRefs,
|
|
239
|
+
isZoomed: isZoomed?.value,
|
|
240
|
+
rtl: dir?.value === "rtl",
|
|
241
|
+
globalFont
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function buildStatic() {
|
|
245
|
+
return buildStaticFrame(getFrameCtx(), driver.cachedLayout, axisTransition);
|
|
246
|
+
}
|
|
247
|
+
function buildAnimated(valueScales, valueDomains, axisLayouts, categoryScale, valueXScales) {
|
|
248
|
+
return buildAnimatedFrame(getFrameCtx(), driver.cachedLayout, axisTransition, { axisLayouts, valueScales, valueDomains, categoryScale, valueXScales });
|
|
249
|
+
}
|
|
250
|
+
function renderFrame(frameParams) {
|
|
251
|
+
driver.lastFrame = frameParams;
|
|
252
|
+
renderWithCompositor(frameParams, renderFrameParam, {
|
|
253
|
+
renderer,
|
|
254
|
+
canvas: canvasEl.value,
|
|
255
|
+
compositor,
|
|
256
|
+
overlayCanvas: overlayCanvasEl?.value,
|
|
257
|
+
registry: canvasRegistry,
|
|
258
|
+
hover: hover.value,
|
|
259
|
+
markerOverlays: markerOverlays?.value
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
watch(
|
|
263
|
+
[layoutData, groupRef, gridGroupRef],
|
|
264
|
+
() => {
|
|
265
|
+
const layout = layoutData.value;
|
|
266
|
+
if (!layout) return;
|
|
267
|
+
if (renderer === "svg" && !groupRef.value) return;
|
|
268
|
+
const animFeature = features.value.get("animation")?.props;
|
|
269
|
+
driveCartesianUpdate(layout, driver, axisTransition, animFeature, renderFrame, buildStatic, buildAnimated, globalFont, locale, isDragging?.value);
|
|
270
|
+
},
|
|
271
|
+
{ immediate: true, flush: "post" }
|
|
272
|
+
);
|
|
273
|
+
watch(hover, () => {
|
|
274
|
+
if (!driver.cachedLayout) return;
|
|
275
|
+
if (skipHoverRepaint?.value) return;
|
|
276
|
+
const frame = resolveHoverRepaintFrame(driver, getFrameCtx(), buildStatic);
|
|
277
|
+
renderFrame(frame);
|
|
278
|
+
});
|
|
279
|
+
if (isZoomed) {
|
|
280
|
+
watch(isZoomed, () => {
|
|
281
|
+
if (!driver.cachedLayout) return;
|
|
282
|
+
renderFrame(buildStatic());
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
onUnmounted(() => {
|
|
286
|
+
cancelDriverRafs(driver);
|
|
287
|
+
canvasRegistry.destroy();
|
|
288
|
+
if (animStoreRef) {
|
|
289
|
+
animStoreRef.value?.destroy();
|
|
290
|
+
animStoreRef.value = null;
|
|
291
|
+
}
|
|
292
|
+
stopOverlayCanvasWatch?.();
|
|
293
|
+
stopMarkerOverlaysWatch?.();
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
function useCartesianLayout(options) {
|
|
297
|
+
const { cartesianArea, datasets, axes, features, datasetVisibility, hoverConfig, chartId, renderer, width, height, zoomState, globalFont } = options;
|
|
298
|
+
const controller = new CartesianLayoutController();
|
|
299
|
+
onUnmounted(() => controller.destroy());
|
|
300
|
+
return computed(() => {
|
|
301
|
+
const area = cartesianArea.value;
|
|
302
|
+
if (!area) return null;
|
|
303
|
+
return controller.compute({
|
|
304
|
+
cartesianArea: area,
|
|
305
|
+
datasets: datasets.value,
|
|
306
|
+
axes: axes.value,
|
|
307
|
+
features: features.value,
|
|
308
|
+
datasetVisibility: datasetVisibility.value,
|
|
309
|
+
hoverConfig: hoverConfig.value,
|
|
310
|
+
chartId,
|
|
311
|
+
renderer,
|
|
312
|
+
dimensions: { width: width.value, height: height.value },
|
|
313
|
+
zoomState: zoomState?.value ?? void 0,
|
|
314
|
+
dir: options.dir?.value ?? "ltr",
|
|
315
|
+
font: globalFont,
|
|
316
|
+
locale: options.locale?.value,
|
|
317
|
+
theme: options.theme.value
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
function useChartSync(options) {
|
|
322
|
+
const syncBus = inject(SYNC_BUS_KEY, null);
|
|
323
|
+
const initialSync = toValue(options.sync);
|
|
324
|
+
if (!syncBus || initialSync === false) {
|
|
325
|
+
return { syncInfo: null };
|
|
326
|
+
}
|
|
327
|
+
const resolvedConfig = resolveSyncConfig(initialSync);
|
|
328
|
+
syncBus.register(options.chartId, resolvedConfig);
|
|
329
|
+
watch(
|
|
330
|
+
() => toValue(options.sync),
|
|
331
|
+
(next) => {
|
|
332
|
+
if (next === false) return;
|
|
333
|
+
syncBus.updateConfig(options.chartId, resolveSyncConfig(next));
|
|
334
|
+
},
|
|
335
|
+
{ deep: true }
|
|
336
|
+
);
|
|
337
|
+
onUnmounted(() => {
|
|
338
|
+
syncBus.unregister(options.chartId);
|
|
339
|
+
});
|
|
340
|
+
return {
|
|
341
|
+
syncInfo: {
|
|
342
|
+
bus: syncBus,
|
|
343
|
+
chartId: options.chartId,
|
|
344
|
+
config: resolvedConfig
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function useDatasetRegistration({ id, type, props, typeResolver }) {
|
|
349
|
+
const methods = useChartMethods();
|
|
350
|
+
const stackedContext = inject(STACKED_CONTEXT_KEY, null);
|
|
351
|
+
const rangeContext = inject(RANGE_CONTEXT_KEY, null);
|
|
352
|
+
let autoOrder = void 0;
|
|
353
|
+
if (stackedContext && props.value.order === void 0) {
|
|
354
|
+
autoOrder = stackedContext.getNextOrder();
|
|
355
|
+
}
|
|
356
|
+
const controller = new DatasetRegistrationController({
|
|
357
|
+
id: id.value,
|
|
358
|
+
type,
|
|
359
|
+
typeResolver,
|
|
360
|
+
register: (cid, ctype, cprops) => methods.registerDataset(cid, ctype, cprops),
|
|
361
|
+
unregister: (cid) => methods.unregisterDataset(cid),
|
|
362
|
+
update: (cid, cprops) => methods.updateDataset(cid, cprops)
|
|
363
|
+
});
|
|
364
|
+
const getExtras = () => ({
|
|
365
|
+
stackId: stackedContext?.stackId,
|
|
366
|
+
rangeId: rangeContext?.rangeId,
|
|
367
|
+
order: props.value.order ?? autoOrder
|
|
368
|
+
});
|
|
369
|
+
const stableProps = shallowRef(props.value);
|
|
370
|
+
watch(
|
|
371
|
+
props,
|
|
372
|
+
(newProps) => {
|
|
373
|
+
controller.update(newProps, getExtras());
|
|
374
|
+
stableProps.value = newProps;
|
|
375
|
+
},
|
|
376
|
+
{ deep: false }
|
|
377
|
+
);
|
|
378
|
+
onMounted(() => {
|
|
379
|
+
controller.mount(props.value, getExtras());
|
|
380
|
+
});
|
|
381
|
+
useChartRefreshHook(() => {
|
|
382
|
+
controller.forceRefresh(props.value, getExtras());
|
|
383
|
+
});
|
|
384
|
+
onUnmounted(() => {
|
|
385
|
+
controller.unmount();
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
function useDrilldownState(datasets) {
|
|
389
|
+
const controller = new DrilldownStateController();
|
|
390
|
+
const snapshot = shallowRef(controller.getSnapshot());
|
|
391
|
+
const unsubscribe = controller.subscribe(() => {
|
|
392
|
+
snapshot.value = controller.getSnapshot();
|
|
393
|
+
});
|
|
394
|
+
onScopeDispose(unsubscribe);
|
|
395
|
+
watch(datasets, (next) => controller.setDatasets(next), { immediate: true });
|
|
396
|
+
return {
|
|
397
|
+
currentParentId: computed(() => snapshot.value.currentParentId),
|
|
398
|
+
path: computed(() => snapshot.value.path),
|
|
399
|
+
isActive: computed(() => snapshot.value.isActive),
|
|
400
|
+
enabled: computed(() => snapshot.value.enabled),
|
|
401
|
+
drillInto: controller.drillInto,
|
|
402
|
+
drillToLevel: controller.drillToLevel
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
var FAMILY_RENDERERS_KEY = /* @__PURE__ */ Symbol.for("primeui-chart-family-renderers");
|
|
406
|
+
function provideFamilyRenderers() {
|
|
407
|
+
const registry = shallowReactive({ cartesian: void 0, radial: void 0, rect: void 0 });
|
|
408
|
+
provide(FAMILY_RENDERERS_KEY, registry);
|
|
409
|
+
return registry;
|
|
410
|
+
}
|
|
411
|
+
function registerFamilyRenderer(family, component) {
|
|
412
|
+
const registry = inject(FAMILY_RENDERERS_KEY, null);
|
|
413
|
+
if (registry && !registry[family]) registry[family] = component;
|
|
414
|
+
}
|
|
415
|
+
var NAVIGATOR_RENDERER_KEY = /* @__PURE__ */ Symbol.for("primeui-chart-navigator-renderer");
|
|
416
|
+
function registerNavigatorRenderer(component) {
|
|
417
|
+
const slot = inject(NAVIGATOR_RENDERER_KEY, null);
|
|
418
|
+
if (slot && !slot.value) slot.value = component;
|
|
419
|
+
}
|
|
420
|
+
var ZOOM_CONTROLLER_KEY = /* @__PURE__ */ Symbol.for("primeui-chart-zoom-controller");
|
|
421
|
+
function registerZoomController(ctor) {
|
|
422
|
+
const slot = inject(ZOOM_CONTROLLER_KEY, null);
|
|
423
|
+
if (slot && !slot.value) slot.value = ctor;
|
|
424
|
+
}
|
|
425
|
+
var KEYBOARD_CONTROLLER_KEY = /* @__PURE__ */ Symbol.for("primeui-chart-keyboard-controller");
|
|
426
|
+
function registerKeyboardController(ctor) {
|
|
427
|
+
const slot = inject(KEYBOARD_CONTROLLER_KEY, null);
|
|
428
|
+
if (slot && !slot.value) slot.value = ctor;
|
|
429
|
+
}
|
|
430
|
+
var CHART_LAYERS_KEY = /* @__PURE__ */ Symbol.for("primeui-chart-layers");
|
|
431
|
+
function provideChartLayers() {
|
|
432
|
+
const registry = shallowReactive(/* @__PURE__ */ new Map());
|
|
433
|
+
provide(CHART_LAYERS_KEY, registry);
|
|
434
|
+
return registry;
|
|
435
|
+
}
|
|
436
|
+
function registerChartLayer(type, entry) {
|
|
437
|
+
const registry = inject(CHART_LAYERS_KEY, null);
|
|
438
|
+
if (registry && !registry.has(type)) registry.set(type, entry);
|
|
439
|
+
}
|
|
440
|
+
function useChartLayers() {
|
|
441
|
+
return inject(CHART_LAYERS_KEY, null);
|
|
442
|
+
}
|
|
443
|
+
var CARTESIAN_FRAME_KEY = /* @__PURE__ */ Symbol.for("primeui-chart-cartesian-frame");
|
|
444
|
+
function provideCartesianFrame(shared) {
|
|
445
|
+
const handles = shallowReactive(/* @__PURE__ */ new Map());
|
|
446
|
+
const frame = {
|
|
447
|
+
...shared,
|
|
448
|
+
handles,
|
|
449
|
+
register: (h) => handles.set(h.type, h),
|
|
450
|
+
unregister: (type) => handles.delete(type)
|
|
451
|
+
};
|
|
452
|
+
provide(CARTESIAN_FRAME_KEY, frame);
|
|
453
|
+
return frame;
|
|
454
|
+
}
|
|
455
|
+
function useCartesianFrame() {
|
|
456
|
+
return inject(CARTESIAN_FRAME_KEY, null);
|
|
457
|
+
}
|
|
458
|
+
function useCartesianFrameRegistration(handle) {
|
|
459
|
+
const frame = inject(CARTESIAN_FRAME_KEY, null);
|
|
460
|
+
if (!frame) return;
|
|
461
|
+
frame.register(handle);
|
|
462
|
+
onBeforeUnmount(() => frame.unregister(handle.type));
|
|
463
|
+
}
|
|
464
|
+
function useItemCollector() {
|
|
465
|
+
const collector = new ItemCollector();
|
|
466
|
+
provide(ITEM_COLLECTOR_KEY, {
|
|
467
|
+
registerItem: (index, props) => collector.registerItem(index, props),
|
|
468
|
+
unregisterItem: (index) => collector.unregisterItem(index),
|
|
469
|
+
getNextIndex: () => collector.getNextIndex()
|
|
470
|
+
});
|
|
471
|
+
return { getItems: () => collector.getItems() };
|
|
472
|
+
}
|
|
473
|
+
function useAnimationProps(props, methods) {
|
|
474
|
+
const registration = computed(() => {
|
|
475
|
+
const p = toValue(props);
|
|
476
|
+
const animation = p.animation;
|
|
477
|
+
const rawEasing = animation ? animation.easing : void 0;
|
|
478
|
+
const resolvedEasing = typeof rawEasing === "function" ? rawEasing : rawEasing ? getEasing(rawEasing) : void 0;
|
|
479
|
+
const flattened = normalizeAnimationsMap(p.animations);
|
|
480
|
+
const propertyAnimations = flattened.length ? flattened : void 0;
|
|
481
|
+
return {
|
|
482
|
+
enabled: animation === false ? false : void 0,
|
|
483
|
+
duration: animation ? animation.duration : void 0,
|
|
484
|
+
easing: resolvedEasing,
|
|
485
|
+
limit: animation ? animation.limit : void 0,
|
|
486
|
+
propertyAnimations
|
|
487
|
+
};
|
|
488
|
+
});
|
|
489
|
+
useCustomizationRegistration("animation", registration, methods);
|
|
490
|
+
}
|
|
491
|
+
function useChartContext(options) {
|
|
492
|
+
const { coreCtx, width, height, dir, theme, rendererDelegate, drilldownEnabled, onClickCb, onLegendClickCb, syncInfo, containerRef } = options;
|
|
493
|
+
const { coreChart, emitHandlerRef, setHover } = coreCtx;
|
|
494
|
+
const tooltip = shallowRef(null);
|
|
495
|
+
function handleCoreEmit(event, ...args) {
|
|
496
|
+
switch (event) {
|
|
497
|
+
case "tooltip-change": {
|
|
498
|
+
const val = args[0];
|
|
499
|
+
tooltip.value = val;
|
|
500
|
+
coreChart.$setState({ tooltip: val });
|
|
501
|
+
break;
|
|
502
|
+
}
|
|
503
|
+
case "hover-change": {
|
|
504
|
+
const hover = args[0];
|
|
505
|
+
hover.datasetId;
|
|
506
|
+
hover.index;
|
|
507
|
+
coreChart.$setState({ lastHover: { datasetId: hover.datasetId, index: hover.index } });
|
|
508
|
+
setHover(hover.datasetId, hover.index, hover.axisIdx, hover.axisX);
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
case "cursor-change": {
|
|
512
|
+
const cursor = args[0];
|
|
513
|
+
coreChart.$setState({ cursor });
|
|
514
|
+
if (containerRef.value) containerRef.value.style.cursor = cursor;
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
case "sync-broadcast": {
|
|
518
|
+
if (!syncInfo) break;
|
|
519
|
+
const broadcasts = args[0];
|
|
520
|
+
for (const b of broadcasts) {
|
|
521
|
+
syncInfo.bus.broadcastHighlight({
|
|
522
|
+
sourceId: syncInfo.chartId,
|
|
523
|
+
axis: b.axis,
|
|
524
|
+
normalized: b.normalized,
|
|
525
|
+
categoryIndex: b.categoryIndex,
|
|
526
|
+
sourceType: b.sourceType
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
case "rect-hover-update": {
|
|
532
|
+
rendererDelegate.value?.updateHoverOverlay(null);
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
535
|
+
case "click-callback": {
|
|
536
|
+
onClickCb.value?.(args[0]);
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
case "dataset-toggle": {
|
|
540
|
+
coreChart.toggleDatasetVisibility(args[0]);
|
|
541
|
+
setHover(null, null);
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
case "item-toggle": {
|
|
545
|
+
const { datasetId, index } = args[0];
|
|
546
|
+
coreChart.toggleItemVisibility(datasetId, index);
|
|
547
|
+
setHover(null, null);
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
case "items-toggle": {
|
|
551
|
+
const { datasetId, indices } = args[0];
|
|
552
|
+
for (const i of indices) coreChart.toggleItemVisibility(datasetId, i);
|
|
553
|
+
setHover(null, null);
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
556
|
+
case "legend-callback": {
|
|
557
|
+
onLegendClickCb.value?.(args[0]);
|
|
558
|
+
break;
|
|
559
|
+
}
|
|
560
|
+
case "legend-hover": {
|
|
561
|
+
const hover = args[0];
|
|
562
|
+
setHover(hover.datasetId, hover.index);
|
|
563
|
+
break;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
emitHandlerRef.current = handleCoreEmit;
|
|
568
|
+
const stopPropsSync = watchEffect(() => {
|
|
569
|
+
coreChart.$setProps({
|
|
570
|
+
width: width.value,
|
|
571
|
+
height: height.value,
|
|
572
|
+
dir: dir.value,
|
|
573
|
+
theme: theme.value,
|
|
574
|
+
rendererDelegate: rendererDelegate.value,
|
|
575
|
+
drilldownEnabled: drilldownEnabled.value,
|
|
576
|
+
onClickCb: onClickCb.value,
|
|
577
|
+
onLegendClickCb: onLegendClickCb.value,
|
|
578
|
+
syncInfo
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
onBeforeUnmount(() => {
|
|
582
|
+
stopPropsSync();
|
|
583
|
+
});
|
|
584
|
+
const onMouseMove = (x, y) => coreChart.onMouseMove(x, y);
|
|
585
|
+
const onMouseLeave = () => coreChart.onMouseLeave();
|
|
586
|
+
const onClick = (x, y) => coreChart.onClick(x, y);
|
|
587
|
+
const onLegendClick = (item) => coreChart.onLegendClick(item);
|
|
588
|
+
const onLegendHover = (item) => coreChart.onLegendHover(item);
|
|
589
|
+
const onSyncedResult = (result) => coreChart.onSyncedResult(result);
|
|
590
|
+
return {
|
|
591
|
+
tooltip,
|
|
592
|
+
onMouseMove,
|
|
593
|
+
onMouseLeave,
|
|
594
|
+
onClick,
|
|
595
|
+
onLegendClick,
|
|
596
|
+
onLegendHover,
|
|
597
|
+
onSyncedResult
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
function useChartSyncCoordinator({
|
|
601
|
+
syncInfo,
|
|
602
|
+
datasets,
|
|
603
|
+
datasetVisibility,
|
|
604
|
+
theme,
|
|
605
|
+
zoomState,
|
|
606
|
+
hasCrosshair,
|
|
607
|
+
isSharedMode,
|
|
608
|
+
isCartesian,
|
|
609
|
+
isRect,
|
|
610
|
+
width,
|
|
611
|
+
height,
|
|
612
|
+
getZoomState,
|
|
613
|
+
rendererDelegate,
|
|
614
|
+
updateZoom,
|
|
615
|
+
setDatasetVisibility,
|
|
616
|
+
toggleItemVisibility,
|
|
617
|
+
onSyncedResult
|
|
618
|
+
}) {
|
|
619
|
+
if (!syncInfo) return;
|
|
620
|
+
const coordinator = new ChartSyncCoordinator(syncInfo);
|
|
621
|
+
watch([datasets, theme], () => coordinator.updateDatasets(datasets.value, theme.value), { immediate: true });
|
|
622
|
+
watch(zoomState, (zs) => coordinator.onZoomChange(zs));
|
|
623
|
+
watch(datasetVisibility, (vis) => coordinator.onVisibilityChange(vis));
|
|
624
|
+
const cleanup = coordinator.start({
|
|
625
|
+
getZoomState,
|
|
626
|
+
getRendererDelegate: () => rendererDelegate.value,
|
|
627
|
+
getIsCartesian: () => isCartesian.value,
|
|
628
|
+
getIsRect: () => isRect.value,
|
|
629
|
+
getHasCrosshair: () => hasCrosshair.value,
|
|
630
|
+
getIsSharedMode: () => isSharedMode.value,
|
|
631
|
+
getDatasets: () => datasets.value,
|
|
632
|
+
getDimensions: () => ({ width: width.value, height: height.value }),
|
|
633
|
+
applyZoom: updateZoom,
|
|
634
|
+
applyVisibility: setDatasetVisibility,
|
|
635
|
+
applyItemToggle: (seriesId, itemLabel) => toggleItemVisibility(seriesId, itemLabel),
|
|
636
|
+
applyHighlight: onSyncedResult
|
|
637
|
+
});
|
|
638
|
+
onBeforeUnmount(cleanup);
|
|
639
|
+
}
|
|
640
|
+
function useKeyboardNavigation(options) {
|
|
641
|
+
const { enabled, config, datasets, datasetVisibility, setHover, rendererDelegate, emitFocusMove, emitFocusLeave } = options;
|
|
642
|
+
const state = ref({ ...INACTIVE_STATE });
|
|
643
|
+
const announcement = ref("");
|
|
644
|
+
const controller = new KeyboardNavigationController();
|
|
645
|
+
controller.onNavigate = (datasetId, index, ann) => {
|
|
646
|
+
state.value = { active: true, focusedDatasetId: datasetId, focusedIndex: index, focusedSection: "series" };
|
|
647
|
+
announcement.value = ann;
|
|
648
|
+
const pos = emitFocusMove ? rendererDelegate.value?.getPointPosition(datasetId, index) ?? null : null;
|
|
649
|
+
if (emitFocusMove && pos) {
|
|
650
|
+
emitFocusMove(pos.x + pos.width / 2, pos.y + pos.height / 2);
|
|
651
|
+
} else {
|
|
652
|
+
setHover(datasetId, index);
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
function resetState() {
|
|
656
|
+
state.value = { ...INACTIVE_STATE };
|
|
657
|
+
announcement.value = "";
|
|
658
|
+
if (emitFocusLeave) {
|
|
659
|
+
emitFocusLeave();
|
|
660
|
+
} else {
|
|
661
|
+
setHover(null, null);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
controller.onReset = resetState;
|
|
665
|
+
let pointerFocus = false;
|
|
666
|
+
function notifyPointerDown() {
|
|
667
|
+
pointerFocus = true;
|
|
668
|
+
}
|
|
669
|
+
const focusPosition = computed(() => {
|
|
670
|
+
const s = state.value;
|
|
671
|
+
if (!s.active || !s.focusedDatasetId || s.focusedIndex === null) return null;
|
|
672
|
+
return rendererDelegate.value?.getPointPosition(s.focusedDatasetId, s.focusedIndex) ?? null;
|
|
673
|
+
});
|
|
674
|
+
function onKeyDown(e) {
|
|
675
|
+
if (!enabled.value) return;
|
|
676
|
+
const handled = controller.handleKeyDown(e.key, datasets.value, datasetVisibility.value, config.value);
|
|
677
|
+
if (handled) e.preventDefault();
|
|
678
|
+
}
|
|
679
|
+
function onMouseMove() {
|
|
680
|
+
controller.handleMouseMove();
|
|
681
|
+
}
|
|
682
|
+
function onFocus() {
|
|
683
|
+
if (!enabled.value) return;
|
|
684
|
+
if (pointerFocus) {
|
|
685
|
+
pointerFocus = false;
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
controller.activate(datasets.value, datasetVisibility.value, config.value);
|
|
689
|
+
}
|
|
690
|
+
function onBlur() {
|
|
691
|
+
pointerFocus = false;
|
|
692
|
+
controller.reset();
|
|
693
|
+
resetState();
|
|
694
|
+
}
|
|
695
|
+
watch(enabled, (val) => {
|
|
696
|
+
if (!val) {
|
|
697
|
+
controller.reset();
|
|
698
|
+
resetState();
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
onUnmounted(() => {
|
|
702
|
+
controller.destroy();
|
|
703
|
+
});
|
|
704
|
+
return { state, focusPosition, announcement, onKeyDown, onMouseMove, onFocus, onBlur, notifyPointerDown };
|
|
705
|
+
}
|
|
706
|
+
function useResponsiveConfig(width, height, responsiveFeature, globalFont) {
|
|
707
|
+
const config = computed(() => {
|
|
708
|
+
const tier = getResponsiveTier(width.value, responsiveFeature.value?.breakpoints);
|
|
709
|
+
const defaults = responsiveFeature.value?.disableAutoAdaptive ? getAdaptiveDefaults("lg", globalFont) : getAdaptiveDefaults(tier, globalFont);
|
|
710
|
+
const ruleOverrides = responsiveFeature.value?.rules ? evaluateResponsiveRules(responsiveFeature.value.rules, width.value, height.value) : {};
|
|
711
|
+
return { tier, defaults, ruleOverrides };
|
|
712
|
+
});
|
|
713
|
+
return {
|
|
714
|
+
defaults: computed(() => config.value.defaults),
|
|
715
|
+
ruleOverrides: computed(() => config.value.ruleOverrides)
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
function useResponsiveDimensions(options) {
|
|
719
|
+
const containerRef = ref(null);
|
|
720
|
+
const width = ref(unref(options.width) ?? 400);
|
|
721
|
+
const height = ref(unref(options.height) ?? 400);
|
|
722
|
+
const controller = new ResponsiveDimensionsController();
|
|
723
|
+
onMounted(() => {
|
|
724
|
+
if (!containerRef.value) return;
|
|
725
|
+
if (unref(options.responsive)) {
|
|
726
|
+
controller.onDimensionsChange = (w, h) => {
|
|
727
|
+
if (width.value !== w || height.value !== h) {
|
|
728
|
+
width.value = w;
|
|
729
|
+
height.value = h;
|
|
730
|
+
options.onResize?.(w, h);
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
controller.attach(containerRef.value, {
|
|
734
|
+
debounceWithRAF: options.debounceWithRAF ?? true,
|
|
735
|
+
debounceDelay: unref(options.debounceDelay),
|
|
736
|
+
aspectRatio: unref(options.aspectRatio),
|
|
737
|
+
maxDimensions: unref(options.maxDimensions),
|
|
738
|
+
maxWidth: unref(options.width),
|
|
739
|
+
maxHeight: unref(options.height)
|
|
740
|
+
});
|
|
741
|
+
} else if (!unref(options.width) && !unref(options.height)) {
|
|
742
|
+
const w = containerRef.value.offsetWidth;
|
|
743
|
+
const h = containerRef.value.offsetHeight;
|
|
744
|
+
if (w > 0) width.value = w;
|
|
745
|
+
if (h > 0) height.value = h;
|
|
746
|
+
options.onResize?.(width.value, height.value);
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
watch([() => unref(options.width), () => unref(options.height)], ([newW, newH]) => {
|
|
750
|
+
if (!unref(options.responsive)) {
|
|
751
|
+
if (newW !== void 0 && width.value !== newW) width.value = newW;
|
|
752
|
+
if (newH !== void 0 && height.value !== newH) height.value = newH;
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
onUnmounted(() => {
|
|
756
|
+
controller.destroy();
|
|
757
|
+
});
|
|
758
|
+
return { containerRef, width, height };
|
|
759
|
+
}
|
|
760
|
+
function useZoomPan(options) {
|
|
761
|
+
const { zoomConfig, containerRef, getPlotArea, getScales, getOriginalDomains, isCartesian } = options;
|
|
762
|
+
const zoomState = shallowRef(createInitialZoomState());
|
|
763
|
+
const selectionRect = ref(null);
|
|
764
|
+
const isDragging = ref(false);
|
|
765
|
+
const isZoomedRef = ref(false);
|
|
766
|
+
const getConfig = () => {
|
|
767
|
+
const cfg = zoomConfig.value;
|
|
768
|
+
return {
|
|
769
|
+
mode: cfg?.mode ?? "x",
|
|
770
|
+
wheelCfg: normalizeSubConfig(cfg?.wheel, { enabled: true, speed: 0.1 }),
|
|
771
|
+
dragCfg: normalizeSubConfig(cfg?.drag, { enabled: true }),
|
|
772
|
+
panCfg: normalizeSubConfig(cfg?.pan, { enabled: true, modifierKey: "shift" }),
|
|
773
|
+
pinchCfg: normalizeSubConfig(cfg?.pinch, { enabled: true }),
|
|
774
|
+
limits: cfg?.limits
|
|
775
|
+
};
|
|
776
|
+
};
|
|
777
|
+
let controller = null;
|
|
778
|
+
const buildDeps = () => ({
|
|
779
|
+
getPlotArea,
|
|
780
|
+
getScales,
|
|
781
|
+
getOriginalDomains,
|
|
782
|
+
getConfig,
|
|
783
|
+
getZoomState: () => controller.getZoomState(),
|
|
784
|
+
getCurrentWindow: (axis) => controller.getCurrentWindow(axis)
|
|
785
|
+
});
|
|
786
|
+
function ensureController() {
|
|
787
|
+
if (controller) return controller;
|
|
788
|
+
controller = new ZoomPanController(buildDeps());
|
|
789
|
+
controller.onSettle = (state) => {
|
|
790
|
+
zoomState.value = state;
|
|
791
|
+
isZoomedRef.value = isZoomed(state);
|
|
792
|
+
zoomConfig.value?.onZoomChange?.(state);
|
|
793
|
+
};
|
|
794
|
+
return controller;
|
|
795
|
+
}
|
|
796
|
+
let cleanup = null;
|
|
797
|
+
const attachListeners = () => {
|
|
798
|
+
cleanup?.();
|
|
799
|
+
cleanup = null;
|
|
800
|
+
const enabled = !!zoomConfig.value && isCartesian.value;
|
|
801
|
+
if (!enabled) return;
|
|
802
|
+
const container = containerRef.value;
|
|
803
|
+
if (!container) return;
|
|
804
|
+
const ctrl = ensureController();
|
|
805
|
+
if (!ctrl) return;
|
|
806
|
+
ctrl.updateDeps(buildDeps());
|
|
807
|
+
cleanup = ctrl.attach(container, {
|
|
808
|
+
onDragging: (v) => isDragging.value = v,
|
|
809
|
+
onSelectionRect: (r) => selectionRect.value = r
|
|
810
|
+
});
|
|
811
|
+
};
|
|
812
|
+
watch([zoomConfig, containerRef, isCartesian], attachListeners, { flush: "post", immediate: true });
|
|
813
|
+
watch(zoomConfig, (cfg) => {
|
|
814
|
+
if (!cfg && controller && isZoomed(controller.getZoomState())) controller.resetZoom();
|
|
815
|
+
});
|
|
816
|
+
onBeforeUnmount(() => {
|
|
817
|
+
cleanup?.();
|
|
818
|
+
cleanup = null;
|
|
819
|
+
controller?.destroyZoomState();
|
|
820
|
+
});
|
|
821
|
+
return {
|
|
822
|
+
zoomState,
|
|
823
|
+
resetZoom: () => controller?.resetZoom(),
|
|
824
|
+
updateZoom: (s) => controller?.updateZoom(s),
|
|
825
|
+
getZoomState: () => controller?.getZoomState() ?? zoomState.value,
|
|
826
|
+
isZoomed: isZoomedRef,
|
|
827
|
+
isDragging,
|
|
828
|
+
selectionRect
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
export { provideCartesianFrame, provideChartLayers, provideFamilyRenderers, registerChartLayer, registerFamilyRenderer, registerKeyboardController, registerNavigatorRenderer, registerZoomController, useAnimationProps, useAxisComponentBase, useCartesianAnimation, useCartesianFrame, useCartesianFrameRegistration, useCartesianLayout, useChartContext, useChartLayers, useChartSync, useChartSyncCoordinator, useDatasetAnimationRegistration, useDatasetRegistration, useDrilldownState, useItemCollector, useKeyboardNavigation, usePropertyAnimations, useResponsiveConfig, useResponsiveDimensions, useZoomPan };
|