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,104 +1,125 @@
|
|
|
1
|
-
import { isNumber
|
|
2
|
-
import { useAreaContext
|
|
3
|
-
import { Animate
|
|
4
|
-
import { createVNode
|
|
1
|
+
import { isNumber, isWellBehavedNumber } from "../../utils/validate.mjs";
|
|
2
|
+
import { useAreaContext } from "./hooks/useArea.mjs";
|
|
3
|
+
import { Animate } from "../../animation/Animate.mjs";
|
|
4
|
+
import { createVNode, defineComponent, ref, watch } from "vue";
|
|
5
5
|
//#region src/cartesian/area/ClipRect.tsx
|
|
6
|
-
var
|
|
6
|
+
var HorizontalRect = /* @__PURE__ */ defineComponent({
|
|
7
7
|
name: "HorizontalRect",
|
|
8
8
|
props: {
|
|
9
9
|
alpha: {
|
|
10
10
|
type: Number,
|
|
11
|
-
required:
|
|
11
|
+
required: true
|
|
12
12
|
},
|
|
13
13
|
points: {
|
|
14
14
|
type: Array,
|
|
15
|
-
required:
|
|
15
|
+
required: true
|
|
16
16
|
},
|
|
17
17
|
baseLine: {
|
|
18
18
|
type: [Number, Array],
|
|
19
|
-
required:
|
|
19
|
+
required: true
|
|
20
20
|
},
|
|
21
21
|
strokeWidth: {
|
|
22
22
|
type: Number,
|
|
23
|
-
required:
|
|
23
|
+
required: true
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
|
-
setup(
|
|
27
|
-
|
|
26
|
+
setup(props) {
|
|
27
|
+
const { points } = props;
|
|
28
28
|
return () => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
const { alpha, baseLine, strokeWidth } = props;
|
|
30
|
+
const startX = points[0].x;
|
|
31
|
+
const endX = points[points.length - 1].x;
|
|
32
|
+
const width = alpha * Math.abs(startX - endX);
|
|
33
|
+
let maxY = Math.max(...points.map((entry) => entry.y || 0));
|
|
34
|
+
if (isNumber(baseLine)) maxY = Math.max(baseLine, maxY);
|
|
35
|
+
else if (baseLine && Array.isArray(baseLine) && baseLine.length) maxY = Math.max(...baseLine.map((entry) => entry.y || 0), maxY);
|
|
36
|
+
if (isNumber(maxY)) return createVNode("rect", {
|
|
37
|
+
"x": startX < endX ? startX : startX - width,
|
|
38
|
+
"y": 0,
|
|
39
|
+
"width": width,
|
|
40
|
+
"height": Math.floor(maxY + (strokeWidth ? parseInt(`${strokeWidth}`, 10) : 1))
|
|
41
|
+
}, null);
|
|
42
|
+
return null;
|
|
36
43
|
};
|
|
37
44
|
}
|
|
38
|
-
})
|
|
45
|
+
});
|
|
46
|
+
var VerticalRect = /* @__PURE__ */ defineComponent({
|
|
39
47
|
name: "VerticalRect",
|
|
40
48
|
props: {
|
|
41
49
|
alpha: {
|
|
42
50
|
type: Number,
|
|
43
|
-
required:
|
|
51
|
+
required: true
|
|
44
52
|
},
|
|
45
53
|
points: {
|
|
46
54
|
type: Array,
|
|
47
|
-
required:
|
|
55
|
+
required: true
|
|
48
56
|
},
|
|
49
57
|
baseLine: {
|
|
50
58
|
type: [Number, Array],
|
|
51
|
-
required:
|
|
59
|
+
required: true
|
|
52
60
|
},
|
|
53
61
|
strokeWidth: {
|
|
54
62
|
type: Number,
|
|
55
|
-
required:
|
|
63
|
+
required: true
|
|
56
64
|
}
|
|
57
65
|
},
|
|
58
|
-
setup(
|
|
59
|
-
|
|
66
|
+
setup(props) {
|
|
67
|
+
const { points } = props;
|
|
60
68
|
return () => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
const { alpha, baseLine, strokeWidth } = props;
|
|
70
|
+
const startY = points[0].y;
|
|
71
|
+
const endY = points[points.length - 1].y;
|
|
72
|
+
if (!isWellBehavedNumber(startY) || !isWellBehavedNumber(endY)) return null;
|
|
73
|
+
const height = alpha * Math.abs(startY - endY);
|
|
74
|
+
let maxX = Math.max(...points.map((entry) => entry.x || 0));
|
|
75
|
+
if (isNumber(baseLine)) maxX = Math.max(baseLine, maxX);
|
|
76
|
+
else if (baseLine && Array.isArray(baseLine) && baseLine.length) maxX = Math.max(...baseLine.map((entry) => entry.x || 0), maxX);
|
|
77
|
+
return createVNode("rect", {
|
|
78
|
+
"x": 0,
|
|
79
|
+
"y": startY < endY ? startY : startY - height,
|
|
80
|
+
"width": maxX + (strokeWidth ? parseInt(`${strokeWidth}`, 10) : 1),
|
|
81
|
+
"height": Math.floor(height)
|
|
69
82
|
}, null);
|
|
70
83
|
};
|
|
71
84
|
}
|
|
72
|
-
})
|
|
85
|
+
});
|
|
86
|
+
var ClipRect = /* @__PURE__ */ defineComponent({
|
|
73
87
|
name: "ClipRect",
|
|
74
88
|
setup() {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
89
|
+
const { points, props, areaData, layout, isClipRectAnimating } = useAreaContext();
|
|
90
|
+
const isAnimationActive = ref(false);
|
|
91
|
+
watch(points, (newPoints) => {
|
|
92
|
+
if (newPoints && newPoints.length > 0 && !isAnimationActive.value) isAnimationActive.value = true;
|
|
93
|
+
}, { immediate: true });
|
|
94
|
+
const handleAnimationEnd = () => {
|
|
95
|
+
isAnimationActive.value = false;
|
|
96
|
+
isClipRectAnimating.value = false;
|
|
97
|
+
props.onAnimationEnd?.();
|
|
81
98
|
};
|
|
82
99
|
return () => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
const baseLine = areaData.value?.baseLine;
|
|
101
|
+
if (!points.value || points.value.length === 0) return null;
|
|
102
|
+
return createVNode(Animate, {
|
|
103
|
+
"isActive": isAnimationActive.value,
|
|
104
|
+
"transition": props.transition,
|
|
105
|
+
"onAnimationStart": props.onAnimationStart,
|
|
106
|
+
"onAnimationEnd": handleAnimationEnd
|
|
107
|
+
}, { default: (t) => {
|
|
108
|
+
if (layout.value === "horizontal") return createVNode(HorizontalRect, {
|
|
109
|
+
"alpha": t,
|
|
110
|
+
"points": points.value,
|
|
111
|
+
"baseLine": baseLine,
|
|
112
|
+
"strokeWidth": props.strokeWidth || 2
|
|
113
|
+
}, null);
|
|
114
|
+
return createVNode(VerticalRect, {
|
|
115
|
+
"alpha": t,
|
|
116
|
+
"points": points.value,
|
|
117
|
+
"baseLine": baseLine,
|
|
118
|
+
"strokeWidth": props.strokeWidth || 2
|
|
119
|
+
}, null);
|
|
120
|
+
} });
|
|
100
121
|
};
|
|
101
122
|
}
|
|
102
123
|
});
|
|
103
124
|
//#endregion
|
|
104
|
-
export {
|
|
125
|
+
export { ClipRect };
|
|
@@ -1,151 +1,185 @@
|
|
|
1
|
-
import { isNan
|
|
2
|
-
import { interpolate
|
|
3
|
-
import { Curve
|
|
4
|
-
import { isClipDot
|
|
5
|
-
import { useOffset
|
|
6
|
-
import { useAreaContext
|
|
7
|
-
import { Layer
|
|
8
|
-
import { Dot
|
|
9
|
-
import { LabelList
|
|
10
|
-
import { Fragment
|
|
11
|
-
import { animate
|
|
1
|
+
import { isNan, isNullish, isNumber } from "../../utils/validate.mjs";
|
|
2
|
+
import { interpolate } from "../../utils/data-utils.mjs";
|
|
3
|
+
import { Curve } from "../../shape/Curve.mjs";
|
|
4
|
+
import { isClipDot } from "../../utils/chart.mjs";
|
|
5
|
+
import { useOffset } from "../../context/chartLayoutContext.mjs";
|
|
6
|
+
import { useAreaContext } from "./hooks/useArea.mjs";
|
|
7
|
+
import { Layer } from "../../container/Layer.mjs";
|
|
8
|
+
import { Dot } from "../../shape/Dot.mjs";
|
|
9
|
+
import { LabelList } from "../../components/label/LabelList.mjs";
|
|
10
|
+
import { Fragment, createVNode, defineComponent, mergeProps, ref, watch } from "vue";
|
|
11
|
+
import { animate } from "motion-v";
|
|
12
12
|
//#region src/cartesian/area/RenderArea.tsx
|
|
13
|
-
var
|
|
13
|
+
var Dots = /* @__PURE__ */ defineComponent({
|
|
14
14
|
name: "Dots",
|
|
15
15
|
props: { points: {
|
|
16
16
|
type: Array,
|
|
17
17
|
default: () => []
|
|
18
18
|
} },
|
|
19
|
-
setup(
|
|
20
|
-
|
|
19
|
+
setup(_props) {
|
|
20
|
+
const { clipPathId, props, attrs, dotSlot } = useAreaContext();
|
|
21
21
|
return () => {
|
|
22
|
-
|
|
23
|
-
if (!
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"fill
|
|
27
|
-
"
|
|
28
|
-
stroke:
|
|
22
|
+
const { points } = _props;
|
|
23
|
+
if (!shouldRenderDots(points, props.dot)) return null;
|
|
24
|
+
const clipDot = isClipDot(props.dot);
|
|
25
|
+
const dotsProps = {
|
|
26
|
+
"fill": props.fill,
|
|
27
|
+
"fill-opacity": props.fillOpacity,
|
|
28
|
+
"stroke-width": props.strokeWidth,
|
|
29
|
+
"stroke": props.stroke
|
|
29
30
|
};
|
|
30
|
-
return
|
|
31
|
-
class: "v-charts-area-dots",
|
|
32
|
-
"clip-path":
|
|
33
|
-
}, { default: () => [
|
|
34
|
-
|
|
35
|
-
...
|
|
36
|
-
...
|
|
31
|
+
return createVNode(Layer, {
|
|
32
|
+
"class": "v-charts-area-dots",
|
|
33
|
+
"clip-path": props.needClip ? `url(#clipPath-${clipDot ? "" : "dots-"}${clipPathId.value})` : void 0
|
|
34
|
+
}, { default: () => [points?.map((point) => {
|
|
35
|
+
const dotProps = {
|
|
36
|
+
...dotsProps,
|
|
37
|
+
...attrs,
|
|
37
38
|
r: 3,
|
|
38
|
-
cx:
|
|
39
|
-
cy:
|
|
39
|
+
cx: point.x,
|
|
40
|
+
cy: point.y,
|
|
40
41
|
class: "v-charts-area-dot",
|
|
41
|
-
clipDot
|
|
42
|
+
clipDot
|
|
42
43
|
};
|
|
43
|
-
|
|
44
|
+
if (dotSlot) return dotSlot(dotProps);
|
|
45
|
+
return createVNode(Dot, dotProps, null);
|
|
44
46
|
})] });
|
|
45
47
|
};
|
|
46
48
|
}
|
|
47
|
-
})
|
|
49
|
+
});
|
|
50
|
+
var StaticArea = /* @__PURE__ */ defineComponent({
|
|
48
51
|
name: "StaticArea",
|
|
49
52
|
setup() {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
const { points, clipPathId, layout, attrs, areaData, props, isAnimating, isClipRectAnimating } = useAreaContext();
|
|
54
|
+
const offset = useOffset();
|
|
55
|
+
const currentPoints = ref(points.value || []);
|
|
56
|
+
const currentBaseLine = ref(areaData.value?.baseLine || []);
|
|
57
|
+
let prevPoints = currentPoints.value || [];
|
|
58
|
+
let prevBaseLine = areaData.value?.baseLine || [];
|
|
59
|
+
let animationStopped = false;
|
|
60
|
+
watch(points, (newPoints, _, onCleanup) => {
|
|
61
|
+
if (isClipRectAnimating.value) {
|
|
62
|
+
currentPoints.value = newPoints;
|
|
63
|
+
currentBaseLine.value = areaData.value?.baseLine || [];
|
|
54
64
|
return;
|
|
55
65
|
}
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
if (newPoints && newPoints.length > 0) {
|
|
67
|
+
animationStopped = false;
|
|
68
|
+
isAnimating.value = true;
|
|
69
|
+
const animation = animate(0, 1, {
|
|
70
|
+
...props.transition,
|
|
71
|
+
onUpdate(t) {
|
|
72
|
+
if (animationStopped) return;
|
|
73
|
+
if (prevPoints.length) {
|
|
74
|
+
const prevPointsDiffFactor = prevPoints.length / newPoints.length;
|
|
75
|
+
const stepPoints = t === 1 ? newPoints : newPoints.map((entry, index) => {
|
|
76
|
+
const prevPointIndex = Math.floor(index * prevPointsDiffFactor);
|
|
77
|
+
if (prevPoints[prevPointIndex]) {
|
|
78
|
+
const prev = prevPoints[prevPointIndex];
|
|
66
79
|
return {
|
|
67
|
-
...
|
|
68
|
-
x:
|
|
69
|
-
y:
|
|
80
|
+
...entry,
|
|
81
|
+
x: interpolate(prev.x, entry.x, t),
|
|
82
|
+
y: interpolate(prev.y, entry.y, t)
|
|
70
83
|
};
|
|
71
84
|
}
|
|
72
|
-
return
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
85
|
+
return entry;
|
|
86
|
+
});
|
|
87
|
+
let stepBaseLine;
|
|
88
|
+
if (isNumber(areaData.value?.baseLine)) stepBaseLine = interpolate(prevBaseLine, areaData.value?.baseLine, t);
|
|
89
|
+
else if (isNullish(areaData.value?.baseLine) || isNan(areaData.value?.baseLine)) stepBaseLine = interpolate(prevBaseLine, 0, t);
|
|
90
|
+
else stepBaseLine = areaData?.value.baseLine.map((entry, index) => {
|
|
91
|
+
const prevPointIndex = Math.floor(index * prevPointsDiffFactor);
|
|
92
|
+
if (Array.isArray(prevBaseLine) && prevBaseLine[prevPointIndex]) {
|
|
93
|
+
const prev = prevBaseLine[prevPointIndex];
|
|
78
94
|
return {
|
|
79
|
-
...
|
|
80
|
-
x:
|
|
81
|
-
y:
|
|
95
|
+
...entry,
|
|
96
|
+
x: interpolate(prev.x, entry.x, t),
|
|
97
|
+
y: interpolate(prev.y, entry.y, t)
|
|
82
98
|
};
|
|
83
99
|
}
|
|
84
|
-
return
|
|
85
|
-
})
|
|
100
|
+
return entry;
|
|
101
|
+
});
|
|
102
|
+
currentPoints.value = stepPoints;
|
|
103
|
+
currentBaseLine.value = stepBaseLine;
|
|
86
104
|
}
|
|
87
105
|
},
|
|
88
106
|
onPlay() {
|
|
89
|
-
|
|
107
|
+
props.onAnimationStart?.();
|
|
90
108
|
},
|
|
91
109
|
onComplete() {
|
|
92
|
-
|
|
110
|
+
isAnimating.value = false;
|
|
111
|
+
props.onAnimationEnd?.();
|
|
93
112
|
}
|
|
94
113
|
});
|
|
95
|
-
|
|
96
|
-
|
|
114
|
+
onCleanup(() => {
|
|
115
|
+
animationStopped = true;
|
|
116
|
+
animation.stop();
|
|
117
|
+
prevPoints = currentPoints.value;
|
|
118
|
+
prevBaseLine = currentBaseLine.value;
|
|
97
119
|
});
|
|
98
|
-
} else
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
120
|
+
} else {
|
|
121
|
+
isAnimating.value = false;
|
|
122
|
+
currentPoints.value = newPoints || [];
|
|
123
|
+
currentBaseLine.value = areaData.value?.baseLine || [];
|
|
124
|
+
prevPoints = currentPoints.value;
|
|
125
|
+
prevBaseLine = currentBaseLine.value;
|
|
126
|
+
}
|
|
127
|
+
}, { immediate: true });
|
|
128
|
+
return () => {
|
|
129
|
+
const curveAttrs = {
|
|
130
|
+
...attrs,
|
|
131
|
+
"fill": props.fill,
|
|
132
|
+
"fill-opacity": props.fillOpacity,
|
|
133
|
+
"height": offset.value.height,
|
|
134
|
+
"width": offset.value.width,
|
|
135
|
+
"stroke-width": props.strokeWidth
|
|
136
|
+
};
|
|
137
|
+
const isRange = areaData.value?.isRange;
|
|
138
|
+
const showLabels = !isAnimating.value && props.label;
|
|
139
|
+
const labelProps = typeof props.label === "object" ? props.label : {};
|
|
140
|
+
return createVNode(Fragment, null, [
|
|
141
|
+
currentPoints.value && currentPoints.value.length > 1 && createVNode(Layer, { "clip-path": props.needClip ? `url(#clipPath-${clipPathId.value})` : void 0 }, { default: () => [
|
|
142
|
+
createVNode(Curve, mergeProps(curveAttrs, {
|
|
143
|
+
"points": currentPoints.value,
|
|
144
|
+
"connectNulls": props.connectNulls,
|
|
145
|
+
"type": props.type,
|
|
146
|
+
"layout": layout.value,
|
|
147
|
+
"baseLine": currentBaseLine.value,
|
|
148
|
+
"stroke": "none",
|
|
149
|
+
"class": "v-charts-area-area"
|
|
118
150
|
}), null),
|
|
119
|
-
|
|
120
|
-
layout:
|
|
121
|
-
type:
|
|
122
|
-
connectNulls:
|
|
123
|
-
fill: "none",
|
|
124
|
-
points:
|
|
125
|
-
stroke:
|
|
126
|
-
class: "v-charts-area-curve"
|
|
151
|
+
attrs.stroke !== "none" && createVNode(Curve, mergeProps(curveAttrs, {
|
|
152
|
+
"layout": layout.value,
|
|
153
|
+
"type": props.type,
|
|
154
|
+
"connectNulls": props.connectNulls,
|
|
155
|
+
"fill": "none",
|
|
156
|
+
"points": currentPoints.value,
|
|
157
|
+
"stroke": props.stroke,
|
|
158
|
+
"class": "v-charts-area-curve"
|
|
127
159
|
}), null),
|
|
128
|
-
|
|
129
|
-
class: "v-charts-area-curve",
|
|
130
|
-
layout:
|
|
131
|
-
type:
|
|
132
|
-
connectNulls:
|
|
133
|
-
fill: "none",
|
|
134
|
-
points:
|
|
135
|
-
stroke:
|
|
160
|
+
attrs.stroke !== "none" && isRange && createVNode(Curve, mergeProps(curveAttrs, {
|
|
161
|
+
"class": "v-charts-area-curve",
|
|
162
|
+
"layout": layout.value,
|
|
163
|
+
"type": props.type,
|
|
164
|
+
"connectNulls": props.connectNulls,
|
|
165
|
+
"fill": "none",
|
|
166
|
+
"points": currentBaseLine.value,
|
|
167
|
+
"stroke": props.stroke
|
|
136
168
|
}), null)
|
|
137
169
|
] }),
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
data:
|
|
141
|
-
dataKey:
|
|
170
|
+
createVNode(Dots, { "points": currentPoints.value }, null),
|
|
171
|
+
showLabels && createVNode(LabelList, mergeProps(labelProps, {
|
|
172
|
+
"data": areaData.value?.points ?? [],
|
|
173
|
+
"dataKey": props.dataKey
|
|
142
174
|
}), null)
|
|
143
175
|
]);
|
|
144
176
|
};
|
|
145
177
|
}
|
|
146
178
|
});
|
|
147
|
-
function
|
|
148
|
-
|
|
179
|
+
function shouldRenderDots(points, dot) {
|
|
180
|
+
if (points == null || !points.length) return false;
|
|
181
|
+
if (dot) return true;
|
|
182
|
+
return points.length === 1;
|
|
149
183
|
}
|
|
150
184
|
//#endregion
|
|
151
|
-
export {
|
|
185
|
+
export { StaticArea };
|
|
@@ -1,57 +1,81 @@
|
|
|
1
|
-
import { uniqueId
|
|
2
|
-
import { useIsPanorama
|
|
3
|
-
import { isClipDot
|
|
4
|
-
import { useAppSelector
|
|
5
|
-
import { useChartLayout
|
|
6
|
-
import { useChartName
|
|
7
|
-
import { selectArea
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { uniqueId } from "../../../utils/data-utils.mjs";
|
|
2
|
+
import { useIsPanorama } from "../../../context/PanoramaContextProvider.mjs";
|
|
3
|
+
import { isClipDot } from "../../../utils/chart.mjs";
|
|
4
|
+
import { useAppSelector } from "../../../state/hooks.mjs";
|
|
5
|
+
import { useChartLayout } from "../../../context/chartLayoutContext.mjs";
|
|
6
|
+
import { useChartName } from "../../../state/selectors/selectors.mjs";
|
|
7
|
+
import { selectArea } from "../../../state/selectors/areaSelectors.mjs";
|
|
8
|
+
import { useIsAnimating } from "../../../hooks/useIsAnimating.mjs";
|
|
9
|
+
import { filterProps } from "../../../utils/VueUtils.mjs";
|
|
10
|
+
import { computed, inject, provide, ref, watch } from "vue";
|
|
10
11
|
//#region src/cartesian/area/hooks/useArea.ts
|
|
11
|
-
var
|
|
12
|
-
function
|
|
13
|
-
|
|
12
|
+
var AreaContextKey = Symbol("AreaContext");
|
|
13
|
+
function provideAreaContext(context) {
|
|
14
|
+
provide(AreaContextKey, context);
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
if (!
|
|
18
|
-
return
|
|
16
|
+
function useAreaContext() {
|
|
17
|
+
const context = inject(AreaContextKey);
|
|
18
|
+
if (!context) throw new Error("useAreaContext must be used within Area component");
|
|
19
|
+
return context;
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
function useArea(props, attrs = {}, dotSlot) {
|
|
22
|
+
const layout = useChartLayout();
|
|
23
|
+
const chartName = useChartName();
|
|
24
|
+
const localId = uniqueId("v-charts-area-");
|
|
25
|
+
const clipPathId = computed(() => props.id || localId);
|
|
26
|
+
const isPanorama = useIsPanorama();
|
|
27
|
+
/**
|
|
28
|
+
* is Area animating
|
|
29
|
+
*/
|
|
30
|
+
const isAnimating = useIsAnimating(() => props.isAnimationActive);
|
|
31
|
+
/**
|
|
32
|
+
* render only when layout is horizontal or vertical and chartName is AreaChart or ComposedChart
|
|
33
|
+
*/
|
|
34
|
+
const shouldRender = computed(() => (layout.value === "horizontal" || layout.value === "vertical") && (chartName.value === "AreaChart" || chartName.value === "ComposedChart") && !props.hide);
|
|
35
|
+
const areaSettings = computed(() => ({
|
|
36
|
+
baseValue: props.baseValue,
|
|
37
|
+
stackId: props.stackId,
|
|
38
|
+
connectNulls: props.connectNulls,
|
|
39
|
+
data: props.data,
|
|
40
|
+
dataKey: props.dataKey
|
|
41
|
+
}));
|
|
42
|
+
const areaData = useAppSelector((state) => selectArea(state, props.xAxisId, props.yAxisId, isPanorama, areaSettings.value));
|
|
43
|
+
const isClipRectAnimating = ref(true);
|
|
44
|
+
watch(() => props.hide, (v) => {
|
|
45
|
+
if (!v) isClipRectAnimating.value = true;
|
|
30
46
|
});
|
|
31
|
-
|
|
47
|
+
const shouldShowAnimation = computed(() => {
|
|
48
|
+
return props.isAnimationActive && areaData.value?.points?.length && isClipRectAnimating.value;
|
|
49
|
+
});
|
|
50
|
+
const dot = props.dot;
|
|
51
|
+
const clipDot = isClipDot(dot);
|
|
52
|
+
const { r = 3, strokeWidth = 2 } = filterProps(dot, false) ?? {
|
|
32
53
|
r: 3,
|
|
33
54
|
strokeWidth: 2
|
|
34
|
-
}, A = O * 2 + k, j = {
|
|
35
|
-
clipPathId: v,
|
|
36
|
-
layout: h,
|
|
37
|
-
points: c(() => C.value?.points),
|
|
38
|
-
props: l,
|
|
39
|
-
attrs: u,
|
|
40
|
-
dot: E,
|
|
41
|
-
clipDot: D,
|
|
42
|
-
dotSize: A,
|
|
43
|
-
dotSlot: p,
|
|
44
|
-
areaData: C,
|
|
45
|
-
isAnimating: b,
|
|
46
|
-
isClipRectAnimating: w
|
|
47
55
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
const dotSize = r * 2 + strokeWidth;
|
|
57
|
+
const areaContext = {
|
|
58
|
+
clipPathId,
|
|
59
|
+
layout,
|
|
60
|
+
points: computed(() => areaData.value?.points),
|
|
61
|
+
props,
|
|
62
|
+
attrs,
|
|
63
|
+
dot,
|
|
64
|
+
clipDot,
|
|
65
|
+
dotSize,
|
|
66
|
+
dotSlot,
|
|
67
|
+
areaData,
|
|
68
|
+
isAnimating,
|
|
69
|
+
isClipRectAnimating
|
|
70
|
+
};
|
|
71
|
+
provideAreaContext(areaContext);
|
|
72
|
+
return {
|
|
73
|
+
shouldRender,
|
|
74
|
+
areaData,
|
|
75
|
+
points: areaContext.points,
|
|
76
|
+
clipPathId,
|
|
77
|
+
shouldShowAnimation
|
|
54
78
|
};
|
|
55
79
|
}
|
|
56
80
|
//#endregion
|
|
57
|
-
export {
|
|
81
|
+
export { useArea, useAreaContext };
|