vccs 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cartesian/funnel/Funnel.d.ts +2 -0
- package/dist/cartesian/funnel/index.d.ts +2 -0
- package/dist/cartesian/funnel/type.d.ts +74 -5
- package/dist/cartesian/index.d.ts +1 -0
- package/dist/chart/FunnelChart.d.ts +1 -0
- package/dist/chart/index.d.ts +1 -0
- package/dist/es/animation/Animate.mjs +48 -22
- package/dist/es/cartesian/GraphicalItemClipPath.mjs +16 -15
- package/dist/es/cartesian/area/ActivePoints.mjs +44 -40
- package/dist/es/cartesian/area/Area.mjs +42 -31
- package/dist/es/cartesian/area/ClipRect.mjs +79 -58
- package/dist/es/cartesian/area/RenderArea.mjs +142 -108
- package/dist/es/cartesian/area/hooks/useArea.mjs +71 -47
- package/dist/es/cartesian/area/type.mjs +11 -11
- package/dist/es/cartesian/area/utils.mjs +69 -49
- package/dist/es/cartesian/axis/XAxis.mjs +87 -73
- package/dist/es/cartesian/axis/YAxis.mjs +67 -56
- package/dist/es/cartesian/bar/Bar.mjs +93 -71
- package/dist/es/cartesian/bar/components/BarBackground.mjs +22 -19
- package/dist/es/cartesian/bar/components/BarRectangles.mjs +117 -80
- package/dist/es/cartesian/bar/hooks/useBar.mjs +49 -37
- package/dist/es/cartesian/bar/type.mjs +9 -9
- package/dist/es/cartesian/bar/utils.mjs +97 -70
- package/dist/es/cartesian/cartesian-axis/CartesianAxis.mjs +165 -115
- package/dist/es/cartesian/cartesian-grid/Background.mjs +19 -16
- package/dist/es/cartesian/cartesian-grid/CartesianGrid.mjs +116 -97
- package/dist/es/cartesian/cartesian-grid/HorizontalGridLines.mjs +24 -23
- package/dist/es/cartesian/cartesian-grid/HorizontalStripes.mjs +24 -24
- package/dist/es/cartesian/cartesian-grid/VerticalGridLines.mjs +23 -22
- package/dist/es/cartesian/cartesian-grid/VerticalStripes.mjs +24 -24
- package/dist/es/cartesian/cartesian-grid/const.mjs +317 -10
- package/dist/es/cartesian/cartesian-grid/utils.mjs +18 -13
- package/dist/es/cartesian/error-bar/ErrorBar.mjs +111 -83
- package/dist/es/cartesian/error-bar/ErrorBarContext.mjs +13 -12
- package/dist/es/cartesian/funnel/Funnel.mjs +177 -0
- package/dist/es/cartesian/funnel/type.mjs +80 -0
- package/dist/es/cartesian/funnel/utils.mjs +102 -0
- package/dist/es/cartesian/line/ActivePoints.mjs +45 -41
- package/dist/es/cartesian/line/Line.mjs +41 -37
- package/dist/es/cartesian/line/StaticLine.mjs +191 -122
- package/dist/es/cartesian/line/hooks/useLine.mjs +60 -44
- package/dist/es/cartesian/line/type.mjs +11 -11
- package/dist/es/cartesian/line/utils.mjs +27 -26
- package/dist/es/cartesian/reference-area/ReferenceArea.mjs +86 -69
- package/dist/es/cartesian/reference-line/ReferenceLine.mjs +99 -77
- package/dist/es/cartesian/scatter/Scatter.mjs +168 -140
- package/dist/es/cartesian/scatter/hooks/useScatter.mjs +18 -14
- package/dist/es/cartesian/useNeedsClip.mjs +18 -9
- package/dist/es/cartesian/utils/get-ticks.mjs +103 -68
- package/dist/es/cartesian/z-axis/ZAxis.mjs +30 -28
- package/dist/es/chart/AreaChart.mjs +5 -5
- package/dist/es/chart/BarChart.mjs +5 -5
- package/dist/es/chart/ComposedChart.mjs +5 -5
- package/dist/es/chart/FunnelChart.mjs +11 -0
- package/dist/es/chart/LegendPortalContext.mjs +3 -3
- package/dist/es/chart/LineChart.mjs +5 -5
- package/dist/es/chart/PieChart.mjs +5 -5
- package/dist/es/chart/RadarChart.mjs +5 -5
- package/dist/es/chart/RadialBarChart.mjs +5 -5
- package/dist/es/chart/RechartsWrapper.mjs +111 -88
- package/dist/es/chart/ScatterChart.mjs +5 -5
- package/dist/es/chart/Surface.mjs +3 -3
- package/dist/es/chart/Surface.vue_vue_type_script_setup_true_lang.mjs +51 -45
- package/dist/es/chart/TooltipPortalContext.mjs +3 -3
- package/dist/es/chart/const.mjs +2 -2
- package/dist/es/chart/generateCategoricalChart.mjs +97 -88
- package/dist/es/chart/provideClipPathId.mjs +12 -7
- package/dist/es/components/Cell.mjs +16 -4
- package/dist/es/components/Text.mjs +3 -3
- package/dist/es/components/Text.vue_vue_type_script_setup_true_lang.mjs +106 -69
- package/dist/es/components/Tooltip.mjs +274 -199
- package/dist/es/components/label/Label.mjs +30 -26
- package/dist/es/components/label/LabelList.mjs +45 -39
- package/dist/es/components/label/types.mjs +8 -5
- package/dist/es/components/label/utils.mjs +194 -162
- package/dist/es/components/legend/Legend.mjs +82 -71
- package/dist/es/components/legend/LegendSymbol.mjs +40 -38
- package/dist/es/components/legend/hooks/useLegend.mjs +66 -46
- package/dist/es/components/legend/hooks/useLegendContent.mjs +52 -31
- package/dist/es/components/legend/type.mjs +2 -2
- package/dist/es/components/legend/utils.mjs +19 -11
- package/dist/es/components/utils.mjs +35 -22
- package/dist/es/container/ClipPath.mjs +14 -14
- package/dist/es/container/Layer.mjs +9 -7
- package/dist/es/container/ResponsiveContainer.mjs +3 -3
- package/dist/es/container/ResponsiveContainer.vue_vue_type_script_setup_true_lang.mjs +109 -77
- package/dist/es/container/Surface.mjs +23 -19
- package/dist/es/container/useSizeContext.mjs +3 -3
- package/dist/es/context/ChartDataContextProvider.mjs +19 -13
- package/dist/es/context/PanoramaContextProvider.mjs +15 -10
- package/dist/es/context/accessibilityContext.mjs +3 -3
- package/dist/es/context/cartesianLabelListContext.mjs +3 -3
- package/dist/es/context/chartLayoutContext.mjs +33 -30
- package/dist/es/context/cursorLayerContext.mjs +3 -3
- package/dist/es/context/graphicalLayerContext.mjs +3 -3
- package/dist/es/context/labelLayerContext.mjs +3 -3
- package/dist/es/context/polarLabelViewBoxContext.mjs +5 -5
- package/dist/es/context/useTooltipAxis.mjs +14 -12
- package/dist/es/events/useChartSynchronisation.mjs +91 -66
- package/dist/es/hooks/useIsAnimating.mjs +28 -0
- package/dist/es/hooks/useSetupGraphicalItem.mjs +52 -43
- package/dist/es/index.mjs +46 -42
- package/dist/es/polar/pie/Pie.mjs +131 -115
- package/dist/es/polar/pie/type.mjs +6 -6
- package/dist/es/polar/radar/PolarAngleAxis.mjs +103 -84
- package/dist/es/polar/radar/PolarGrid.mjs +72 -59
- package/dist/es/polar/radar/PolarRadiusAxis.mjs +90 -65
- package/dist/es/polar/radar/Radar.mjs +181 -145
- package/dist/es/polar/radial-bar/RadialBar.mjs +161 -140
- package/dist/es/polar/radial-bar/type.mjs +9 -9
- package/dist/es/shape/Cross.mjs +11 -10
- package/dist/es/shape/Curve.mjs +69 -43
- package/dist/es/shape/Dot.mjs +12 -11
- package/dist/es/shape/Rectangle.mjs +41 -26
- package/dist/es/shape/Sector.mjs +103 -75
- package/dist/es/shape/Symbols.mjs +45 -34
- package/dist/es/shape/Trapezoid.mjs +52 -0
- package/dist/es/state/ReportChartProps.mjs +21 -20
- package/dist/es/state/ReportMainChartProps.mjs +26 -21
- package/dist/es/state/ReportPolarOptions.mjs +23 -22
- package/dist/es/state/SetGraphicalItem.mjs +42 -27
- package/dist/es/state/SetLegendPayload.mjs +17 -13
- package/dist/es/state/SetTooltipEntrySettings.mjs +14 -12
- package/dist/es/state/brushSlice.mjs +12 -8
- package/dist/es/state/cartesianAxisSlice.mjs +23 -17
- package/dist/es/state/chartDataSlice.mjs +18 -13
- package/dist/es/state/externalEventsMiddleware.mjs +25 -15
- package/dist/es/state/graphicalItemsSlice.mjs +29 -25
- package/dist/es/state/hooks.mjs +4 -3
- package/dist/es/state/keyboardEventsMiddleware.mjs +50 -42
- package/dist/es/state/layoutSlice.mjs +18 -12
- package/dist/es/state/legendSlice.mjs +19 -14
- package/dist/es/state/mouseEventsMiddleware.mjs +31 -24
- package/dist/es/state/optionsSlice.mjs +14 -11
- package/dist/es/state/polarAxisSlice.mjs +15 -13
- package/dist/es/state/polarOptionsSlice.mjs +8 -6
- package/dist/es/state/reduxDevtoolsJsonStringifyReplacer.mjs +5 -3
- package/dist/es/state/referenceElementsSlice.mjs +21 -19
- package/dist/es/state/rootPropsSlice.mjs +20 -9
- package/dist/es/state/selectors/areaSelectors.mjs +65 -55
- package/dist/es/state/selectors/axisSelectors.mjs +755 -569
- package/dist/es/state/selectors/barSelectors.mjs +225 -162
- package/dist/es/state/selectors/brushSelectors.mjs +15 -14
- package/dist/es/state/selectors/combiners/combineActiveLabel.mjs +6 -5
- package/dist/es/state/selectors/combiners/combineActiveTooltipIndex.mjs +36 -27
- package/dist/es/state/selectors/combiners/combineAxisRangeWithReverse.mjs +5 -3
- package/dist/es/state/selectors/combiners/combineCoordinateForDefaultIndex.mjs +13 -11
- package/dist/es/state/selectors/combiners/combineTooltipInteractionState.mjs +26 -21
- package/dist/es/state/selectors/combiners/combineTooltipPayloadConfigurations.mjs +10 -6
- package/dist/es/state/selectors/common.mjs +2 -2
- package/dist/es/state/selectors/containerSelectors.mjs +5 -2
- package/dist/es/state/selectors/dataSelectors.mjs +28 -9
- package/dist/es/state/selectors/funnelSelectors.mjs +38 -0
- package/dist/es/state/selectors/legendSelectors.mjs +7 -6
- package/dist/es/state/selectors/lineSelectors.mjs +54 -47
- package/dist/es/state/selectors/pickAxisId.mjs +2 -2
- package/dist/es/state/selectors/pickAxisType.mjs +2 -2
- package/dist/es/state/selectors/pieSelectors.mjs +116 -81
- package/dist/es/state/selectors/polarAxisSelectors.mjs +113 -94
- package/dist/es/state/selectors/polarGridSelectors.mjs +13 -11
- package/dist/es/state/selectors/polarScaleSelectors.mjs +49 -46
- package/dist/es/state/selectors/polarSelectors.mjs +79 -62
- package/dist/es/state/selectors/radarSelectors.mjs +111 -91
- package/dist/es/state/selectors/radialBarSelectors.mjs +230 -183
- package/dist/es/state/selectors/rootPropsSelectors.mjs +11 -5
- package/dist/es/state/selectors/scatterSelectors.mjs +111 -95
- package/dist/es/state/selectors/selectActivePropsFromChartPointer.mjs +19 -17
- package/dist/es/state/selectors/selectAllAxes.mjs +8 -3
- package/dist/es/state/selectors/selectChartOffset.mjs +59 -50
- package/dist/es/state/selectors/selectChartOffsetInternal.mjs +55 -44
- package/dist/es/state/selectors/selectTooltipEventType.mjs +15 -14
- package/dist/es/state/selectors/selectTooltipPayloadSearcher.mjs +3 -3
- package/dist/es/state/selectors/selectTooltipSettings.mjs +2 -2
- package/dist/es/state/selectors/selectTooltipState.mjs +2 -2
- package/dist/es/state/selectors/selectors.mjs +94 -75
- package/dist/es/state/selectors/tooltipSelectors.mjs +253 -204
- package/dist/es/state/selectors/touchSelectors.mjs +17 -14
- package/dist/es/state/store.mjs +46 -46
- package/dist/es/state/tooltipSlice.mjs +64 -37
- package/dist/es/state/touchEventsMiddleware.mjs +35 -29
- package/dist/es/state/utils/useReportScale.mjs +16 -13
- package/dist/es/synchronisation/syncSelectors.mjs +3 -3
- package/dist/es/synchronisation/useChartSynchronisation.mjs +33 -19
- package/dist/es/types/event.mjs +164 -2
- package/dist/es/utils/ReduceCSSCalc.mjs +81 -49
- package/dist/es/utils/VueUtils.mjs +35 -14
- package/dist/es/utils/attrs.mjs +43 -26
- package/dist/es/utils/cartesian.mjs +47 -15
- package/dist/es/utils/chart.mjs +298 -197
- package/dist/es/utils/const.mjs +30 -2
- package/dist/es/utils/createContext.mjs +28 -9
- package/dist/es/utils/data-utils.mjs +9 -8
- package/dist/es/utils/data.mjs +35 -21
- package/dist/es/utils/events.mjs +5 -3
- package/dist/es/utils/getLinearRegression.mjs +28 -11
- package/dist/es/utils/grid.mjs +20 -5
- package/dist/es/utils/isDomainSpecifiedByUser.mjs +105 -54
- package/dist/es/utils/legend.mjs +13 -12
- package/dist/es/utils/log.mjs +10 -7
- package/dist/es/utils/payload/getUniqPayload.mjs +6 -4
- package/dist/es/utils/polar.mjs +37 -30
- package/dist/es/utils/props.mjs +16 -10
- package/dist/es/utils/resolveDefaultProps.mjs +23 -4
- package/dist/es/utils/scale/getNiceTickValues.mjs +127 -49
- package/dist/es/utils/scale/utils/arithmetic.mjs +49 -19
- package/dist/es/utils/scale/utils/utils.mjs +43 -24
- package/dist/es/utils/style.mjs +24 -13
- package/dist/es/utils/tick.mjs +34 -23
- package/dist/es/utils/tooltip/translate.mjs +63 -49
- package/dist/es/utils/validate.mjs +40 -29
- package/dist/hooks/useIsAnimating.d.ts +14 -0
- package/dist/shape/Trapezoid.d.ts +31 -0
- package/dist/shape/index.d.ts +1 -0
- package/dist/state/graphicalItemsSlice.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import { isNumOrStr
|
|
2
|
-
import { Curve
|
|
3
|
-
import { useTooltipEventType
|
|
4
|
-
import { setTooltipSettingsState
|
|
5
|
-
import { useAppDispatch
|
|
6
|
-
import { useChartLayout
|
|
7
|
-
import { selectActiveCoordinate
|
|
8
|
-
import { Rectangle
|
|
9
|
-
import { useCursorLayerRef
|
|
10
|
-
import { usePortal
|
|
11
|
-
import { useAccessibilityLayer
|
|
12
|
-
import { getTooltipTranslate
|
|
13
|
-
import { Cross
|
|
14
|
-
import { Sector
|
|
15
|
-
import { getCursorPoints
|
|
16
|
-
import { useTooltipAxisBandSize
|
|
17
|
-
import { useTooltipChartSynchronisation
|
|
18
|
-
import { Fragment
|
|
19
|
-
import { sortBy
|
|
20
|
-
import { animate
|
|
21
|
-
import { useElementBounding
|
|
1
|
+
import { isNumOrStr } from "../utils/validate.mjs";
|
|
2
|
+
import { Curve } from "../shape/Curve.mjs";
|
|
3
|
+
import { useTooltipEventType } from "../state/selectors/selectTooltipEventType.mjs";
|
|
4
|
+
import { setTooltipSettingsState } from "../state/tooltipSlice.mjs";
|
|
5
|
+
import { useAppDispatch, useAppSelector } from "../state/hooks.mjs";
|
|
6
|
+
import { useChartLayout, useOffsetInternal, useViewBox } from "../context/chartLayoutContext.mjs";
|
|
7
|
+
import { selectActiveCoordinate, selectActiveLabel, selectIsTooltipActive, selectTooltipPayload, useChartName } from "../state/selectors/selectors.mjs";
|
|
8
|
+
import { Rectangle } from "../shape/Rectangle.mjs";
|
|
9
|
+
import { useCursorLayerRef } from "../context/cursorLayerContext.mjs";
|
|
10
|
+
import { usePortal } from "../chart/TooltipPortalContext.mjs";
|
|
11
|
+
import { useAccessibilityLayer } from "../context/accessibilityContext.mjs";
|
|
12
|
+
import { getTooltipTranslate } from "../utils/tooltip/translate.mjs";
|
|
13
|
+
import { Cross } from "../shape/Cross.mjs";
|
|
14
|
+
import { Sector } from "../shape/Sector.mjs";
|
|
15
|
+
import { getCursorPoints } from "./utils.mjs";
|
|
16
|
+
import { useTooltipAxisBandSize } from "../context/useTooltipAxis.mjs";
|
|
17
|
+
import { useTooltipChartSynchronisation } from "../synchronisation/useChartSynchronisation.mjs";
|
|
18
|
+
import { Fragment, Teleport, computed, createVNode, defineComponent, isVNode, reactive, ref, watch, watchEffect, watchPostEffect } from "vue";
|
|
19
|
+
import { sortBy, uniqBy } from "es-toolkit/compat";
|
|
20
|
+
import { animate } from "motion-v";
|
|
21
|
+
import { useElementBounding, useMagicKeys, usePreferredReducedMotion } from "@vueuse/core";
|
|
22
22
|
//#region src/components/Tooltip.tsx
|
|
23
|
-
function
|
|
24
|
-
return typeof
|
|
23
|
+
function _isSlot(s) {
|
|
24
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
return
|
|
26
|
+
function defaultUniqBy(entry) {
|
|
27
|
+
return entry.dataKey;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
29
|
+
function getUniqPayload(payload, option, defaultUniqBy) {
|
|
30
|
+
if (option === true) return uniqBy(payload, defaultUniqBy);
|
|
31
|
+
if (typeof option === "function") return uniqBy(payload, option);
|
|
32
|
+
return payload;
|
|
31
33
|
}
|
|
32
|
-
function
|
|
33
|
-
return Array.isArray(
|
|
34
|
+
function defaultFormatter(value) {
|
|
35
|
+
return Array.isArray(value) && isNumOrStr(value[0]) && isNumOrStr(value[1]) ? value.join(" ~ ") : value;
|
|
34
36
|
}
|
|
35
|
-
var
|
|
37
|
+
var DefaultTooltipContent = /* @__PURE__ */ defineComponent({
|
|
36
38
|
name: "DefaultTooltipContent",
|
|
37
39
|
props: {
|
|
38
40
|
label: [String, Number],
|
|
@@ -48,57 +50,66 @@ var G = /* @__PURE__ */ O({
|
|
|
48
50
|
itemSorter: [Function, String],
|
|
49
51
|
formatter: Function
|
|
50
52
|
},
|
|
51
|
-
setup(
|
|
53
|
+
setup(props) {
|
|
52
54
|
return () => {
|
|
53
|
-
if (!
|
|
54
|
-
|
|
55
|
+
if (!props.active || !props.payload?.length) return null;
|
|
56
|
+
const { contentStyle, labelStyle, itemStyle } = props;
|
|
57
|
+
const finalStyle = {
|
|
55
58
|
margin: 0,
|
|
56
59
|
padding: "10px",
|
|
57
60
|
backgroundColor: "#fff",
|
|
58
61
|
border: "1px solid #ccc",
|
|
59
62
|
whiteSpace: "nowrap",
|
|
60
|
-
...
|
|
61
|
-
}
|
|
63
|
+
...contentStyle
|
|
64
|
+
};
|
|
65
|
+
const finalLabelStyle = {
|
|
62
66
|
margin: 0,
|
|
63
|
-
...
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
...labelStyle
|
|
68
|
+
};
|
|
69
|
+
const { itemSorter, payload, formatter } = props;
|
|
70
|
+
const sortedPayload = itemSorter ? sortBy(payload, itemSorter) : payload;
|
|
71
|
+
return createVNode("div", {
|
|
72
|
+
"class": "v-charts-tooltip-content",
|
|
73
|
+
"style": finalStyle
|
|
74
|
+
}, [props.label && createVNode("div", {
|
|
75
|
+
"class": "v-charts-tooltip-label",
|
|
76
|
+
"style": finalLabelStyle
|
|
77
|
+
}, [props.label]), createVNode("div", { "class": "v-charts-tooltip-list" }, [sortedPayload.map((entry, index) => {
|
|
78
|
+
const finalItemStyle = {
|
|
73
79
|
display: "block",
|
|
74
80
|
paddingTop: 4,
|
|
75
81
|
paddingBottom: 4,
|
|
76
|
-
color:
|
|
77
|
-
...
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
color: entry.color || "#000",
|
|
83
|
+
...itemStyle
|
|
84
|
+
};
|
|
85
|
+
const finalFormatter = entry.formatter || formatter || defaultFormatter;
|
|
86
|
+
const { value, name } = entry;
|
|
87
|
+
let finalValue = value;
|
|
88
|
+
let finalName = name;
|
|
89
|
+
if (finalFormatter) {
|
|
90
|
+
const formatted = finalFormatter(value, name, entry, index, payload);
|
|
91
|
+
if (Array.isArray(formatted)) [finalValue, finalName] = formatted;
|
|
92
|
+
else if (formatted != null) finalValue = formatted;
|
|
83
93
|
else return null;
|
|
84
94
|
}
|
|
85
|
-
return
|
|
86
|
-
key:
|
|
87
|
-
class: "v-charts-tooltip-item",
|
|
88
|
-
style:
|
|
95
|
+
return createVNode("div", {
|
|
96
|
+
"key": index,
|
|
97
|
+
"class": "v-charts-tooltip-item",
|
|
98
|
+
"style": finalItemStyle
|
|
89
99
|
}, [
|
|
90
|
-
|
|
91
|
-
class: "v-charts-tooltip-item-name",
|
|
92
|
-
style: { color:
|
|
93
|
-
}, [
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
100
|
+
createVNode("span", {
|
|
101
|
+
"class": "v-charts-tooltip-item-name",
|
|
102
|
+
"style": { color: entry.color }
|
|
103
|
+
}, [entry.name]),
|
|
104
|
+
createVNode("span", { "class": "v-charts-tooltip-separator" }, [props.separator]),
|
|
105
|
+
createVNode("span", { "class": "v-charts-tooltip-item-value" }, [finalValue]),
|
|
106
|
+
createVNode("span", { "class": "v-charts-tooltip-item-unit" }, [entry.unit || ""])
|
|
97
107
|
]);
|
|
98
108
|
})])]);
|
|
99
109
|
};
|
|
100
110
|
}
|
|
101
|
-
})
|
|
111
|
+
});
|
|
112
|
+
var TooltipBoundingBox = /* @__PURE__ */ defineComponent({
|
|
102
113
|
name: "TooltipBoundingBox",
|
|
103
114
|
props: {
|
|
104
115
|
allowEscapeViewBox: Object,
|
|
@@ -119,64 +130,86 @@ var G = /* @__PURE__ */ O({
|
|
|
119
130
|
viewBox: Object,
|
|
120
131
|
style: Object
|
|
121
132
|
},
|
|
122
|
-
setup(
|
|
123
|
-
|
|
133
|
+
setup(props, { slots }) {
|
|
134
|
+
const dismissed = ref(false);
|
|
135
|
+
const dismissedAtCoordinate = reactive({
|
|
124
136
|
x: 0,
|
|
125
137
|
y: 0
|
|
126
138
|
});
|
|
127
|
-
|
|
128
|
-
(
|
|
139
|
+
watchEffect(() => {
|
|
140
|
+
if (props.coordinate?.x !== dismissedAtCoordinate.x || props.coordinate?.y !== dismissedAtCoordinate.y) dismissed.value = false;
|
|
129
141
|
}, { flush: "post" });
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
142
|
+
const { escape } = useMagicKeys();
|
|
143
|
+
watch(escape, (v) => {
|
|
144
|
+
if (v) {
|
|
145
|
+
dismissed.value = true;
|
|
146
|
+
dismissedAtCoordinate.x = props.coordinate?.x ?? 0;
|
|
147
|
+
dismissedAtCoordinate.y = props.coordinate?.y ?? 0;
|
|
148
|
+
}
|
|
133
149
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
150
|
+
const el = ref();
|
|
151
|
+
const lastBoundingBox = useElementBounding(el, {});
|
|
152
|
+
let preTransform;
|
|
153
|
+
let animationControls;
|
|
154
|
+
const reducedMotion = usePreferredReducedMotion();
|
|
155
|
+
const currentTransform = computed(() => {
|
|
156
|
+
const { allowEscapeViewBox, coordinate, position, reverseDirection, viewBox } = props;
|
|
157
|
+
let { cssClasses, cssProperties, transform } = getTooltipTranslate({
|
|
158
|
+
allowEscapeViewBox,
|
|
159
|
+
coordinate,
|
|
160
|
+
offsetTopLeft: props.offset,
|
|
161
|
+
position,
|
|
162
|
+
reverseDirection,
|
|
141
163
|
tooltipBox: {
|
|
142
|
-
height:
|
|
143
|
-
width:
|
|
164
|
+
height: lastBoundingBox.height.value,
|
|
165
|
+
width: lastBoundingBox.width.value
|
|
144
166
|
},
|
|
145
|
-
useTranslate3d:
|
|
146
|
-
viewBox
|
|
167
|
+
useTranslate3d: false,
|
|
168
|
+
viewBox
|
|
147
169
|
});
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
170
|
+
transform = !lastBoundingBox.height.value && preTransform ? preTransform : transform;
|
|
171
|
+
preTransform = transform || preTransform;
|
|
172
|
+
return {
|
|
173
|
+
cssClasses,
|
|
174
|
+
cssProperties,
|
|
175
|
+
transform
|
|
152
176
|
};
|
|
153
177
|
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
178
|
+
watchPostEffect((onCleanup) => {
|
|
179
|
+
const element = el.value;
|
|
180
|
+
const transform = currentTransform.value.transform;
|
|
181
|
+
if (!element || !transform?.transform) return;
|
|
182
|
+
if (props.isAnimationActive && reducedMotion.value !== "reduce") animationControls = animate(element, { transform: transform.transform }, props.transition);
|
|
183
|
+
else element.style.transform = transform.transform;
|
|
184
|
+
onCleanup(() => {
|
|
185
|
+
animationControls?.stop();
|
|
186
|
+
animationControls = void 0;
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
return () => {
|
|
190
|
+
const { active, hasPayload, style } = props;
|
|
191
|
+
const { cssClasses, cssProperties } = currentTransform.value;
|
|
192
|
+
const boundingBoxStyle = {
|
|
193
|
+
...cssProperties,
|
|
162
194
|
pointerEvents: "none",
|
|
163
|
-
visibility: !
|
|
195
|
+
visibility: !dismissed.value && active && hasPayload ? "visible" : "hidden",
|
|
164
196
|
position: "absolute",
|
|
165
197
|
top: 0,
|
|
166
198
|
left: 0,
|
|
167
|
-
...
|
|
199
|
+
...style
|
|
168
200
|
};
|
|
169
|
-
return
|
|
170
|
-
role: "tooltip",
|
|
201
|
+
return createVNode("div", {
|
|
202
|
+
"role": "tooltip",
|
|
171
203
|
"aria-live": "polite",
|
|
172
|
-
tabindex: -1,
|
|
173
|
-
class:
|
|
174
|
-
style:
|
|
175
|
-
ref:
|
|
176
|
-
}, [
|
|
204
|
+
"tabindex": -1,
|
|
205
|
+
"class": cssClasses,
|
|
206
|
+
"style": boundingBoxStyle,
|
|
207
|
+
"ref": el
|
|
208
|
+
}, [slots.default?.()]);
|
|
177
209
|
};
|
|
178
210
|
}
|
|
179
|
-
})
|
|
211
|
+
});
|
|
212
|
+
var Cursor = /* @__PURE__ */ defineComponent({
|
|
180
213
|
name: "Cursor",
|
|
181
214
|
props: {
|
|
182
215
|
cursor: [Boolean, Object],
|
|
@@ -186,70 +219,86 @@ var G = /* @__PURE__ */ O({
|
|
|
186
219
|
payload: Array,
|
|
187
220
|
index: String
|
|
188
221
|
},
|
|
189
|
-
setup(
|
|
190
|
-
|
|
222
|
+
setup(props) {
|
|
223
|
+
const offset = useOffsetInternal();
|
|
224
|
+
const layout = useChartLayout();
|
|
225
|
+
const chartName = useChartName();
|
|
226
|
+
const tooltipAxisBandSize = useTooltipAxisBandSize();
|
|
227
|
+
const cursorLayerRef = useCursorLayerRef(null);
|
|
228
|
+
const points = computed(() => getCursorPoints(layout.value, props.coordinate, offset.value));
|
|
191
229
|
return () => {
|
|
192
|
-
if (!
|
|
193
|
-
|
|
194
|
-
if (!
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
230
|
+
if (!props.cursor || !props.coordinate) return null;
|
|
231
|
+
const isScatterChart = chartName.value === "ScatterChart";
|
|
232
|
+
if (!isScatterChart && props.tooltipEventType !== "axis") return null;
|
|
233
|
+
const cursor = props.cursor;
|
|
234
|
+
const cursorSvgProps = typeof cursor === "object" ? cursor : {};
|
|
235
|
+
let cursorElement;
|
|
236
|
+
if (isScatterChart) {
|
|
237
|
+
const { offset: _offset, ...coord } = props.coordinate;
|
|
238
|
+
const { top, left, width, height } = offset.value;
|
|
239
|
+
const crossProps = {
|
|
198
240
|
stroke: "#ccc",
|
|
199
241
|
fill: "none",
|
|
200
|
-
...
|
|
201
|
-
top
|
|
202
|
-
left
|
|
203
|
-
width
|
|
204
|
-
height
|
|
242
|
+
...coord,
|
|
243
|
+
top,
|
|
244
|
+
left,
|
|
245
|
+
width,
|
|
246
|
+
height,
|
|
205
247
|
class: "v-charts-tooltip-cursor",
|
|
206
248
|
style: { pointerEvents: "none" },
|
|
207
|
-
...
|
|
249
|
+
...cursorSvgProps
|
|
208
250
|
};
|
|
209
|
-
|
|
210
|
-
} else if (
|
|
211
|
-
|
|
251
|
+
cursorElement = props.cursorSlot ? props.cursorSlot(crossProps) : createVNode(Cross, crossProps, null);
|
|
252
|
+
} else if (chartName.value === "BarChart") {
|
|
253
|
+
const bandSize = tooltipAxisBandSize.value ?? 0;
|
|
254
|
+
const halfSize = bandSize / 2;
|
|
255
|
+
const coord = props.coordinate;
|
|
256
|
+
const off = offset.value;
|
|
257
|
+
const rectProps = {
|
|
212
258
|
stroke: "none",
|
|
213
259
|
fill: "#ccc",
|
|
214
|
-
x:
|
|
215
|
-
y:
|
|
216
|
-
width:
|
|
217
|
-
height:
|
|
260
|
+
x: layout.value === "horizontal" ? coord.x - halfSize : off.left + .5,
|
|
261
|
+
y: layout.value === "horizontal" ? off.top + .5 : coord.y - halfSize,
|
|
262
|
+
width: layout.value === "horizontal" ? bandSize : off.width - 1,
|
|
263
|
+
height: layout.value === "horizontal" ? off.height - 1 : bandSize,
|
|
218
264
|
class: "v-charts-tooltip-cursor",
|
|
219
265
|
style: { pointerEvents: "none" },
|
|
220
|
-
...
|
|
266
|
+
...cursorSvgProps
|
|
221
267
|
};
|
|
222
|
-
|
|
223
|
-
} else if (
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
268
|
+
cursorElement = props.cursorSlot ? props.cursorSlot(rectProps) : createVNode(Rectangle, rectProps, null);
|
|
269
|
+
} else if (layout.value === "radial" && props.coordinate?.cx != null) {
|
|
270
|
+
const radialPoints = points.value;
|
|
271
|
+
const sectorProps = {
|
|
272
|
+
cx: radialPoints.cx,
|
|
273
|
+
cy: radialPoints.cy,
|
|
274
|
+
startAngle: radialPoints.startAngle,
|
|
275
|
+
endAngle: radialPoints.endAngle,
|
|
276
|
+
innerRadius: radialPoints.radius,
|
|
277
|
+
outerRadius: radialPoints.radius,
|
|
231
278
|
stroke: "#ccc",
|
|
232
279
|
fill: "none",
|
|
233
280
|
class: "v-charts-tooltip-cursor",
|
|
234
281
|
style: { pointerEvents: "none" },
|
|
235
|
-
...
|
|
282
|
+
...cursorSvgProps
|
|
236
283
|
};
|
|
237
|
-
|
|
284
|
+
cursorElement = props.cursorSlot ? props.cursorSlot(sectorProps) : createVNode(Sector, sectorProps, null);
|
|
238
285
|
} else {
|
|
239
|
-
|
|
286
|
+
const cursorProps = {
|
|
240
287
|
stroke: "#ccc",
|
|
241
288
|
class: ["v-charts-tooltip-cursor"],
|
|
242
|
-
layout:
|
|
243
|
-
points:
|
|
289
|
+
layout: layout.value,
|
|
290
|
+
points: points.value,
|
|
244
291
|
style: { pointerEvents: "none" },
|
|
245
|
-
...
|
|
292
|
+
...cursorSvgProps
|
|
246
293
|
};
|
|
247
|
-
|
|
294
|
+
cursorElement = props.cursorSlot ? props.cursorSlot(cursorProps) : createVNode(Curve, cursorProps, null);
|
|
248
295
|
}
|
|
249
|
-
|
|
296
|
+
if (cursorLayerRef?.value) return createVNode(Teleport, { "to": cursorLayerRef.value }, _isSlot(cursorElement) ? cursorElement : { default: () => [cursorElement] });
|
|
297
|
+
return cursorElement;
|
|
250
298
|
};
|
|
251
299
|
}
|
|
252
|
-
})
|
|
300
|
+
});
|
|
301
|
+
var Tooltip = /* @__PURE__ */ defineComponent({
|
|
253
302
|
name: "Tooltip",
|
|
254
303
|
props: {
|
|
255
304
|
active: {
|
|
@@ -260,23 +309,23 @@ var G = /* @__PURE__ */ O({
|
|
|
260
309
|
allowEscapeViewBox: {
|
|
261
310
|
type: Object,
|
|
262
311
|
default: () => ({
|
|
263
|
-
x:
|
|
264
|
-
y:
|
|
312
|
+
x: false,
|
|
313
|
+
y: false
|
|
265
314
|
})
|
|
266
315
|
},
|
|
267
316
|
content: [Object, Function],
|
|
268
317
|
cursor: {
|
|
269
318
|
type: [Boolean, Object],
|
|
270
|
-
default:
|
|
319
|
+
default: true
|
|
271
320
|
},
|
|
272
321
|
filterNull: {
|
|
273
322
|
type: Boolean,
|
|
274
|
-
default:
|
|
323
|
+
default: true
|
|
275
324
|
},
|
|
276
325
|
defaultIndex: [Number, String],
|
|
277
326
|
isAnimationActive: {
|
|
278
327
|
type: Boolean,
|
|
279
|
-
default:
|
|
328
|
+
default: true
|
|
280
329
|
},
|
|
281
330
|
offset: {
|
|
282
331
|
type: Number,
|
|
@@ -291,8 +340,8 @@ var G = /* @__PURE__ */ O({
|
|
|
291
340
|
reverseDirection: {
|
|
292
341
|
type: Object,
|
|
293
342
|
default: () => ({
|
|
294
|
-
x:
|
|
295
|
-
y:
|
|
343
|
+
x: false,
|
|
344
|
+
y: false
|
|
296
345
|
})
|
|
297
346
|
},
|
|
298
347
|
shared: {
|
|
@@ -333,56 +382,82 @@ var G = /* @__PURE__ */ O({
|
|
|
333
382
|
}
|
|
334
383
|
},
|
|
335
384
|
slots: Object,
|
|
336
|
-
setup(
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
385
|
+
setup(props, { slots }) {
|
|
386
|
+
const dispatch = useAppDispatch();
|
|
387
|
+
const defaultIndexAsString = computed(() => typeof props.defaultIndex === "number" ? String(props.defaultIndex) : props.defaultIndex);
|
|
388
|
+
watchEffect(() => {
|
|
389
|
+
dispatch(setTooltipSettingsState({
|
|
390
|
+
shared: props.shared,
|
|
391
|
+
trigger: props.trigger,
|
|
392
|
+
axisId: props.axisId,
|
|
393
|
+
active: props.active,
|
|
394
|
+
defaultIndex: defaultIndexAsString.value
|
|
345
395
|
}));
|
|
346
396
|
});
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
397
|
+
const viewBox = useViewBox();
|
|
398
|
+
const accessibilityLayer = useAccessibilityLayer();
|
|
399
|
+
const tooltipEventType = useTooltipEventType(props.shared);
|
|
400
|
+
const tooltipState = useAppSelector((state) => selectIsTooltipActive(state, tooltipEventType.value, props.trigger, defaultIndexAsString.value));
|
|
401
|
+
const payloadFromRedux = useAppSelector((state) => selectTooltipPayload(state, tooltipEventType.value, props.trigger, defaultIndexAsString.value));
|
|
402
|
+
const labelFromRedux = useAppSelector((state) => selectActiveLabel(state, tooltipEventType.value, props.trigger, defaultIndexAsString.value));
|
|
403
|
+
const coordinate = useAppSelector((state) => selectActiveCoordinate(state, tooltipEventType.value, props.trigger, defaultIndexAsString.value));
|
|
404
|
+
const payload = computed(() => payloadFromRedux.value ?? []);
|
|
405
|
+
const tooltipPortalFromContext = usePortal();
|
|
406
|
+
const tooltipPortal = computed(() => props.portal ?? tooltipPortalFromContext?.value);
|
|
407
|
+
const finalIsActive = computed(() => props.active ?? tooltipState.value?.isActive);
|
|
408
|
+
const finalLabel = computed(() => tooltipEventType.value === "axis" ? labelFromRedux.value : void 0);
|
|
409
|
+
const emptyPayload = [];
|
|
410
|
+
const finalPayload = computed(() => {
|
|
411
|
+
if (!finalIsActive.value) return emptyPayload;
|
|
412
|
+
let result = payload.value ?? emptyPayload;
|
|
413
|
+
if (props.filterNull && result.length > 0) result = getUniqPayload(result.filter((entry) => entry.value != null && (entry.hide !== true || props.includeHidden)), props.payloadUniqBy, defaultUniqBy);
|
|
414
|
+
return result;
|
|
415
|
+
});
|
|
416
|
+
const hasPayload = computed(() => finalPayload.value.length > 0);
|
|
417
|
+
const contentComponent = computed(() => {
|
|
418
|
+
if (props.content) return props.content;
|
|
419
|
+
return DefaultTooltipContent;
|
|
420
|
+
});
|
|
421
|
+
const contentProps = computed(() => ({
|
|
422
|
+
...props,
|
|
423
|
+
payload: finalPayload.value,
|
|
424
|
+
label: finalLabel.value,
|
|
425
|
+
active: finalIsActive.value,
|
|
426
|
+
coordinate: coordinate.value,
|
|
427
|
+
accessibilityLayer: accessibilityLayer.value
|
|
428
|
+
}));
|
|
429
|
+
const hasContentSlot = computed(() => !!slots.content);
|
|
430
|
+
useTooltipChartSynchronisation({
|
|
431
|
+
tooltipEventType,
|
|
432
|
+
trigger: props.trigger,
|
|
433
|
+
activeCoordinate: coordinate,
|
|
434
|
+
activeLabel: finalLabel,
|
|
435
|
+
activeIndex: computed(() => tooltipState.value?.activeIndex),
|
|
436
|
+
isTooltipActive: finalIsActive
|
|
437
|
+
});
|
|
438
|
+
return () => {
|
|
439
|
+
if (!tooltipPortal.value) return null;
|
|
440
|
+
return createVNode(Fragment, null, [createVNode("foreignObject", null, [createVNode(Teleport, { "to": tooltipPortal.value }, { default: () => [createVNode(TooltipBoundingBox, {
|
|
441
|
+
"allowEscapeViewBox": props.allowEscapeViewBox,
|
|
442
|
+
"isAnimationActive": props.isAnimationActive,
|
|
443
|
+
"active": finalIsActive.value,
|
|
444
|
+
"coordinate": coordinate.value,
|
|
445
|
+
"hasPayload": hasPayload.value,
|
|
446
|
+
"offset": props.offset,
|
|
447
|
+
"position": props.position,
|
|
448
|
+
"reverseDirection": props.reverseDirection,
|
|
449
|
+
"viewBox": viewBox.value,
|
|
450
|
+
"style": props.style
|
|
451
|
+
}, { default: () => [hasContentSlot.value ? slots.content(contentProps.value) : createVNode(contentComponent.value, contentProps.value, null)] })] })]), finalIsActive.value && createVNode(Cursor, {
|
|
452
|
+
"cursor": props.cursor,
|
|
453
|
+
"cursorSlot": slots.cursor,
|
|
454
|
+
"tooltipEventType": tooltipEventType.value,
|
|
455
|
+
"coordinate": coordinate.value,
|
|
456
|
+
"payload": payload.value,
|
|
457
|
+
"index": tooltipState.value?.activeIndex
|
|
458
|
+
}, null)]);
|
|
459
|
+
};
|
|
385
460
|
}
|
|
386
461
|
});
|
|
387
462
|
//#endregion
|
|
388
|
-
export {
|
|
463
|
+
export { Tooltip as default, getUniqPayload };
|