vccs 0.1.0 → 0.3.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/README.md +151 -0
- package/dist/animation/Animate.d.ts +1 -1
- package/dist/cartesian/area/type.d.ts +3 -3
- package/dist/cartesian/bar/type.d.ts +1 -13
- package/dist/cartesian/brush/components/Slide.d.ts +1 -1
- package/dist/cartesian/brush/components/TravellerLayer.d.ts +1 -1
- package/dist/cartesian/brush/type.d.ts +2 -1
- package/dist/cartesian/cartesian-axis/CartesianAxis.d.ts +2 -1
- 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 -6
- package/dist/cartesian/index.d.ts +2 -0
- package/dist/cartesian/line/Line.d.ts +7 -13
- package/dist/cartesian/line/type.d.ts +4 -17
- package/dist/cartesian/reference-area/ReferenceArea.d.ts +16 -16
- package/dist/cartesian/reference-dot/ReferenceDot.d.ts +143 -0
- package/dist/cartesian/reference-dot/index.d.ts +2 -0
- package/dist/cartesian/reference-line/ReferenceLine.d.ts +8 -8
- package/dist/cartesian/scatter/Scatter.d.ts +1 -1
- package/dist/chart/FunnelChart.d.ts +1 -0
- package/dist/chart/RechartsWrapper.d.ts +7 -3
- package/dist/chart/Surface.d.ts +2 -1
- package/dist/chart/Treemap.d.ts +237 -0
- package/dist/chart/generateCategoricalChart.d.ts +2 -1
- package/dist/chart/index.d.ts +2 -0
- package/dist/chart/treemapUtils.d.ts +22 -0
- package/dist/components/Customized.d.ts +23 -0
- package/dist/components/Text.d.ts +4 -4
- package/dist/components/Tooltip.d.ts +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/label/Label.d.ts +3 -3
- package/dist/components/label/types.d.ts +1 -1
- package/dist/container/Surface.d.ts +3 -2
- 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 +13 -15
- 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 +78 -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 +11 -25
- 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 +162 -0
- package/dist/es/cartesian/funnel/type.mjs +78 -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 +13 -18
- package/dist/es/cartesian/line/utils.mjs +27 -26
- package/dist/es/cartesian/reference-area/ReferenceArea.mjs +79 -78
- package/dist/es/cartesian/reference-dot/ReferenceDot.mjs +134 -0
- package/dist/es/cartesian/reference-line/ReferenceLine.mjs +93 -84
- 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 +113 -89
- 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/Treemap.mjs +379 -0
- package/dist/es/chart/const.mjs +2 -2
- package/dist/es/chart/generateCategoricalChart.mjs +99 -89
- package/dist/es/chart/provideClipPathId.mjs +12 -7
- package/dist/es/chart/treemapUtils.mjs +32 -0
- package/dist/es/components/Cell.mjs +16 -4
- package/dist/es/components/Customized.mjs +43 -0
- 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 +10 -6
- 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 +71 -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 +25 -23
- 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/publicHooks.mjs +207 -0
- package/dist/es/hooks/useIsAnimating.mjs +28 -0
- package/dist/es/hooks/useSetupGraphicalItem.mjs +52 -43
- package/dist/es/index.mjs +54 -42
- package/dist/es/polar/pie/Pie.mjs +131 -115
- package/dist/es/polar/pie/type.mjs +8 -10
- 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 +71 -44
- package/dist/es/shape/Dot.mjs +12 -11
- package/dist/es/shape/Polygon.mjs +19 -0
- package/dist/es/shape/Rectangle.mjs +41 -30
- package/dist/es/shape/Sector.mjs +105 -79
- package/dist/es/shape/Symbols.mjs +45 -34
- package/dist/es/shape/Trapezoid.mjs +50 -0
- package/dist/es/state/ReportChartProps.mjs +23 -24
- 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 +24 -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 +784 -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/common.mjs +12 -0
- 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/cell.mjs +28 -0
- package/dist/es/utils/chart.mjs +298 -197
- package/dist/es/utils/const.mjs +30 -2
- package/dist/es/utils/createCategoricalInverse.mjs +46 -0
- 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/scale.mjs +46 -0
- 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/publicHooks.d.ts +143 -0
- package/dist/hooks/useIsAnimating.d.ts +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/polar/pie/type.d.ts +2 -2
- package/dist/polar/radar/Radar.d.ts +4 -4
- package/dist/shape/Curve.d.ts +2 -1
- package/dist/shape/Polygon.d.ts +9 -0
- package/dist/shape/Rectangle.d.ts +0 -4
- package/dist/shape/Sector.d.ts +2 -2
- package/dist/shape/Symbols.d.ts +2 -1
- package/dist/shape/Trapezoid.d.ts +30 -0
- package/dist/shape/index.d.ts +2 -0
- package/dist/shape/types.d.ts +4 -5
- package/dist/state/ReportChartProps.d.ts +3 -3
- package/dist/state/graphicalItemsSlice.d.ts +1 -1
- package/dist/state/rootPropsSlice.d.ts +2 -2
- package/dist/state/selectors/axisSelectors.d.ts +5 -0
- package/dist/types/axis.d.ts +2 -2
- package/dist/types/bar.d.ts +2 -6
- package/dist/types/categorical.d.ts +2 -2
- package/dist/types/common.d.ts +7 -1
- package/dist/types/tooltip.d.ts +2 -2
- package/dist/utils/cell.d.ts +11 -0
- package/dist/utils/createCategoricalInverse.d.ts +16 -0
- package/dist/utils/scale.d.ts +23 -0
- package/package.json +2 -1
|
@@ -1,148 +1,217 @@
|
|
|
1
|
-
import { interpolate
|
|
2
|
-
import { Curve
|
|
3
|
-
import { Layer
|
|
4
|
-
import { Dot
|
|
5
|
-
import { LabelList
|
|
6
|
-
import { useLineContext
|
|
7
|
-
import { Fragment
|
|
8
|
-
import { animate
|
|
1
|
+
import { interpolate } from "../../utils/data-utils.mjs";
|
|
2
|
+
import { Curve } from "../../shape/Curve.mjs";
|
|
3
|
+
import { Layer } from "../../container/Layer.mjs";
|
|
4
|
+
import { Dot } from "../../shape/Dot.mjs";
|
|
5
|
+
import { LabelList } from "../../components/label/LabelList.mjs";
|
|
6
|
+
import { useLineContext } from "./hooks/useLine.mjs";
|
|
7
|
+
import { Fragment, createVNode, defineComponent, mergeProps, onBeforeUnmount, ref, watch } from "vue";
|
|
8
|
+
import { animate } from "motion-v";
|
|
9
9
|
//#region src/cartesian/line/StaticLine.tsx
|
|
10
|
-
var
|
|
10
|
+
var Dots = /* @__PURE__ */ defineComponent({
|
|
11
11
|
name: "LineDots",
|
|
12
12
|
props: { points: {
|
|
13
13
|
type: Array,
|
|
14
14
|
default: () => []
|
|
15
15
|
} },
|
|
16
|
-
setup(
|
|
17
|
-
|
|
16
|
+
setup(_props) {
|
|
17
|
+
const { clipPathId, clipDot, props, attrs, needClip, dotSlot } = useLineContext();
|
|
18
18
|
return () => {
|
|
19
|
-
|
|
20
|
-
if (!
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"stroke
|
|
25
|
-
|
|
19
|
+
const { points } = _props;
|
|
20
|
+
if (!shouldRenderDots(points, props.dot)) return null;
|
|
21
|
+
const dotObjProps = typeof props.dot === "object" && props.dot !== null ? props.dot : {};
|
|
22
|
+
const dotsProps = {
|
|
23
|
+
"fill": "#fff",
|
|
24
|
+
"stroke": props.stroke,
|
|
25
|
+
"stroke-width": props.strokeWidth,
|
|
26
|
+
...dotObjProps
|
|
26
27
|
};
|
|
27
|
-
return
|
|
28
|
-
class: "v-charts-line-dots",
|
|
29
|
-
"clip-path":
|
|
30
|
-
}, { default: () => [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
...
|
|
34
|
-
...
|
|
35
|
-
cx:
|
|
36
|
-
cy:
|
|
37
|
-
index
|
|
38
|
-
value:
|
|
39
|
-
payload:
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
return createVNode(Layer, {
|
|
29
|
+
"class": "v-charts-line-dots",
|
|
30
|
+
"clip-path": needClip.value ? `url(#clipPath-${clipDot ? "" : "dots-"}${clipPathId.value})` : void 0
|
|
31
|
+
}, { default: () => [points?.map((point, index) => {
|
|
32
|
+
const pointAsLine = point;
|
|
33
|
+
if (dotSlot) return dotSlot({
|
|
34
|
+
...dotsProps,
|
|
35
|
+
...attrs,
|
|
36
|
+
cx: point.x,
|
|
37
|
+
cy: point.y,
|
|
38
|
+
index,
|
|
39
|
+
value: pointAsLine.value,
|
|
40
|
+
payload: pointAsLine.payload
|
|
41
|
+
});
|
|
42
|
+
return createVNode(Dot, mergeProps({ "r": 3 }, dotsProps, attrs, {
|
|
43
|
+
"cx": point.x,
|
|
44
|
+
"cy": point.y,
|
|
45
|
+
"class": "v-charts-line-dot",
|
|
46
|
+
"clipDot": clipDot
|
|
45
47
|
}), null);
|
|
46
48
|
})] });
|
|
47
49
|
};
|
|
48
50
|
}
|
|
49
|
-
})
|
|
51
|
+
});
|
|
52
|
+
var StaticLine = /* @__PURE__ */ defineComponent({
|
|
50
53
|
name: "StaticLine",
|
|
51
54
|
setup() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
const { points, clipPathId, layout, attrs, lineData, props, isAnimating, needClip, shapeSlot, labelSlot } = useLineContext();
|
|
56
|
+
const currentPoints = ref([]);
|
|
57
|
+
const strokeDashRatio = ref(1);
|
|
58
|
+
let isFirstRender = true;
|
|
59
|
+
let prevPoints = [];
|
|
60
|
+
let animationTarget = [];
|
|
61
|
+
let currentAnimation = null;
|
|
62
|
+
let revealAnimationRunning = false;
|
|
63
|
+
function stopCurrentAnimation() {
|
|
64
|
+
if (currentAnimation) {
|
|
65
|
+
currentAnimation.stop();
|
|
66
|
+
currentAnimation = null;
|
|
67
|
+
}
|
|
55
68
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
69
|
+
onBeforeUnmount(() => {
|
|
70
|
+
stopCurrentAnimation();
|
|
71
|
+
});
|
|
72
|
+
watch(points, (newPoints) => {
|
|
73
|
+
if (newPoints && animationTarget.length === newPoints.length && newPoints.every((p, i) => p.x === animationTarget[i].x && p.y === animationTarget[i].y)) return;
|
|
74
|
+
if (newPoints && newPoints.length > 0) {
|
|
75
|
+
if (!props.isAnimationActive) {
|
|
76
|
+
isFirstRender = false;
|
|
77
|
+
stopCurrentAnimation();
|
|
78
|
+
revealAnimationRunning = false;
|
|
79
|
+
isAnimating.value = false;
|
|
80
|
+
currentPoints.value = newPoints;
|
|
81
|
+
prevPoints = newPoints;
|
|
82
|
+
animationTarget = newPoints;
|
|
83
|
+
strokeDashRatio.value = 0;
|
|
62
84
|
return;
|
|
63
85
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
86
|
+
if (isFirstRender) {
|
|
87
|
+
isFirstRender = false;
|
|
88
|
+
revealAnimationRunning = true;
|
|
89
|
+
isAnimating.value = true;
|
|
90
|
+
currentPoints.value = newPoints;
|
|
91
|
+
animationTarget = newPoints;
|
|
92
|
+
strokeDashRatio.value = 1;
|
|
93
|
+
stopCurrentAnimation();
|
|
94
|
+
currentAnimation = animate(1, 0, {
|
|
95
|
+
...props.transition,
|
|
96
|
+
onUpdate(v) {
|
|
97
|
+
if (!revealAnimationRunning) return;
|
|
98
|
+
strokeDashRatio.value = v;
|
|
99
|
+
},
|
|
100
|
+
onPlay() {
|
|
101
|
+
props.onAnimationStart?.();
|
|
102
|
+
},
|
|
103
|
+
onComplete() {
|
|
104
|
+
strokeDashRatio.value = 0;
|
|
105
|
+
isAnimating.value = false;
|
|
106
|
+
revealAnimationRunning = false;
|
|
107
|
+
currentAnimation = null;
|
|
108
|
+
prevPoints = currentPoints.value;
|
|
109
|
+
animationTarget = prevPoints;
|
|
110
|
+
props.onAnimationEnd?.();
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
} else if (revealAnimationRunning) {
|
|
114
|
+
currentPoints.value = newPoints;
|
|
115
|
+
animationTarget = newPoints;
|
|
116
|
+
} else {
|
|
117
|
+
isAnimating.value = true;
|
|
118
|
+
strokeDashRatio.value = 0;
|
|
119
|
+
if (currentPoints.value.length) prevPoints = currentPoints.value;
|
|
120
|
+
animationTarget = newPoints;
|
|
121
|
+
stopCurrentAnimation();
|
|
122
|
+
currentAnimation = animate(0, 1, {
|
|
123
|
+
...props.transition,
|
|
124
|
+
onUpdate(t) {
|
|
125
|
+
if (prevPoints.length) {
|
|
126
|
+
const prevPointsDiffFactor = prevPoints.length / newPoints.length;
|
|
127
|
+
currentPoints.value = t === 1 ? newPoints : newPoints.map((entry, index) => {
|
|
128
|
+
const prevPointIndex = Math.floor(index * prevPointsDiffFactor);
|
|
129
|
+
if (prevPoints[prevPointIndex]) {
|
|
130
|
+
const prev = prevPoints[prevPointIndex];
|
|
131
|
+
return {
|
|
132
|
+
...entry,
|
|
133
|
+
x: interpolate(prev.x, entry.x, t),
|
|
134
|
+
y: interpolate(prev.y, entry.y, t)
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return entry;
|
|
138
|
+
});
|
|
139
|
+
} else currentPoints.value = newPoints;
|
|
140
|
+
},
|
|
141
|
+
onPlay() {
|
|
142
|
+
props.onAnimationStart?.();
|
|
143
|
+
},
|
|
144
|
+
onComplete() {
|
|
145
|
+
isAnimating.value = false;
|
|
146
|
+
prevPoints = newPoints;
|
|
147
|
+
animationTarget = newPoints;
|
|
148
|
+
currentAnimation = null;
|
|
149
|
+
props.onAnimationEnd?.();
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
stopCurrentAnimation();
|
|
155
|
+
revealAnimationRunning = false;
|
|
156
|
+
isAnimating.value = false;
|
|
157
|
+
currentPoints.value = newPoints || [];
|
|
158
|
+
prevPoints = currentPoints.value;
|
|
159
|
+
animationTarget = prevPoints;
|
|
160
|
+
strokeDashRatio.value = 0;
|
|
161
|
+
}
|
|
162
|
+
}, { immediate: true });
|
|
163
|
+
return () => {
|
|
164
|
+
const curveAttrs = {
|
|
165
|
+
...attrs,
|
|
166
|
+
"fill": "none",
|
|
167
|
+
"stroke": props.stroke,
|
|
168
|
+
"stroke-width": props.strokeWidth
|
|
169
|
+
};
|
|
170
|
+
const dashRatio = strokeDashRatio.value;
|
|
171
|
+
const showLabels = !isAnimating.value && (props.label || labelSlot);
|
|
172
|
+
const labelProps = typeof props.label === "object" ? props.label : {};
|
|
173
|
+
let curveContent = null;
|
|
174
|
+
if (currentPoints.value && currentPoints.value.length > 1) if (shapeSlot) curveContent = shapeSlot({
|
|
175
|
+
...curveAttrs,
|
|
176
|
+
points: currentPoints.value,
|
|
177
|
+
connectNulls: props.connectNulls,
|
|
178
|
+
type: props.type,
|
|
179
|
+
layout: layout.value,
|
|
115
180
|
class: "v-charts-line-curve"
|
|
116
|
-
})
|
|
117
|
-
|
|
181
|
+
});
|
|
182
|
+
else curveContent = createVNode(Curve, mergeProps(curveAttrs, !(attrs["stroke-dasharray"] != null) && dashRatio > 0 ? {
|
|
183
|
+
"pathLength": 1,
|
|
118
184
|
"stroke-dasharray": 1,
|
|
119
|
-
"stroke-dashoffset":
|
|
185
|
+
"stroke-dashoffset": dashRatio
|
|
120
186
|
} : {}, {
|
|
121
|
-
points:
|
|
122
|
-
connectNulls:
|
|
123
|
-
type:
|
|
124
|
-
layout:
|
|
125
|
-
class: "v-charts-line-curve"
|
|
126
|
-
}), null)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
187
|
+
"points": currentPoints.value,
|
|
188
|
+
"connectNulls": props.connectNulls,
|
|
189
|
+
"type": props.type,
|
|
190
|
+
"layout": layout.value,
|
|
191
|
+
"class": "v-charts-line-curve"
|
|
192
|
+
}), null);
|
|
193
|
+
const hasCustomDashArray = attrs["stroke-dasharray"] != null;
|
|
194
|
+
const needClipAnim = (shapeSlot || hasCustomDashArray) && dashRatio > 0 && curveContent;
|
|
195
|
+
return createVNode(Fragment, null, [
|
|
196
|
+
curveContent && createVNode(Layer, { "clip-path": needClip.value ? `url(#clipPath-${clipPathId.value})` : void 0 }, { default: () => [needClipAnim ? createVNode("g", null, [createVNode("defs", null, [createVNode("clipPath", { "id": `line-anim-${clipPathId.value}` }, [createVNode("rect", {
|
|
197
|
+
"x": "0",
|
|
198
|
+
"y": "0",
|
|
199
|
+
"width": `${(1 - dashRatio) * 100}%`,
|
|
200
|
+
"height": "100%"
|
|
201
|
+
}, null)])]), createVNode("g", { "clip-path": `url(#line-anim-${clipPathId.value})` }, [curveContent])]) : curveContent] }),
|
|
202
|
+
createVNode(Dots, { "points": currentPoints.value }, null),
|
|
203
|
+
showLabels && createVNode(LabelList, mergeProps(labelProps, {
|
|
204
|
+
"data": lineData.value ?? [],
|
|
205
|
+
"dataKey": props.dataKey
|
|
206
|
+
}), labelSlot ? { label: labelSlot } : void 0)
|
|
140
207
|
]);
|
|
141
208
|
};
|
|
142
209
|
}
|
|
143
210
|
});
|
|
144
|
-
function
|
|
145
|
-
|
|
211
|
+
function shouldRenderDots(points, dot) {
|
|
212
|
+
if (points == null || !points.length) return false;
|
|
213
|
+
if (dot) return true;
|
|
214
|
+
return points.length === 1;
|
|
146
215
|
}
|
|
147
216
|
//#endregion
|
|
148
|
-
export {
|
|
217
|
+
export { StaticLine };
|
|
@@ -1,53 +1,69 @@
|
|
|
1
|
-
import { uniqueId
|
|
2
|
-
import { useIsPanorama
|
|
3
|
-
import { isClipDot
|
|
4
|
-
import { useAppSelector
|
|
5
|
-
import { useChartLayout
|
|
6
|
-
import { useChartName
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
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 { useIsAnimating } from "../../../hooks/useIsAnimating.mjs";
|
|
8
|
+
import { filterProps } from "../../../utils/VueUtils.mjs";
|
|
9
|
+
import { useNeedsClip } from "../../useNeedsClip.mjs";
|
|
10
|
+
import { selectLinePoints } from "../../../state/selectors/lineSelectors.mjs";
|
|
11
|
+
import { computed, inject, provide } from "vue";
|
|
11
12
|
//#region src/cartesian/line/hooks/useLine.ts
|
|
12
|
-
var
|
|
13
|
-
function
|
|
14
|
-
|
|
13
|
+
var LineContextKey = Symbol("LineContext");
|
|
14
|
+
function provideLineContext(context) {
|
|
15
|
+
provide(LineContextKey, context);
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
if (!
|
|
19
|
-
return
|
|
17
|
+
function useLineContext() {
|
|
18
|
+
const context = inject(LineContextKey);
|
|
19
|
+
if (!context) throw new Error("useLineContext must be used within Line component");
|
|
20
|
+
return context;
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
function useLine(props, attrs = {}, shapeSlot, dotSlot, labelSlot) {
|
|
23
|
+
const layout = useChartLayout();
|
|
24
|
+
const chartName = useChartName();
|
|
25
|
+
const localId = uniqueId("v-charts-line-");
|
|
26
|
+
const clipPathId = computed(() => props.id || localId);
|
|
27
|
+
const isPanorama = useIsPanorama();
|
|
28
|
+
const isAnimating = useIsAnimating(() => props.isAnimationActive);
|
|
29
|
+
const { needClip } = useNeedsClip(props.xAxisId, props.yAxisId);
|
|
30
|
+
const shouldRender = computed(() => (layout.value === "horizontal" || layout.value === "vertical") && (chartName.value === "LineChart" || chartName.value === "ComposedChart") && !props.hide);
|
|
31
|
+
const lineSettings = computed(() => ({
|
|
32
|
+
data: props.data,
|
|
33
|
+
dataKey: props.dataKey
|
|
34
|
+
}));
|
|
35
|
+
const lineData = useAppSelector((state) => selectLinePoints(state, props.xAxisId, props.yAxisId, isPanorama, lineSettings.value));
|
|
36
|
+
const dot = props.dot;
|
|
37
|
+
const clipDot = isClipDot(dot);
|
|
38
|
+
const { r = 3, strokeWidth = 2 } = filterProps(dot, false) ?? {
|
|
26
39
|
r: 3,
|
|
27
40
|
strokeWidth: 2
|
|
28
|
-
}, j = k * 2 + A, M = {
|
|
29
|
-
clipPathId: b,
|
|
30
|
-
layout: _,
|
|
31
|
-
points: l(() => E.value),
|
|
32
|
-
props: u,
|
|
33
|
-
attrs: d,
|
|
34
|
-
lineData: E,
|
|
35
|
-
isAnimating: S,
|
|
36
|
-
needClip: C,
|
|
37
|
-
dot: D,
|
|
38
|
-
clipDot: O,
|
|
39
|
-
dotSize: j,
|
|
40
|
-
shapeSlot: p,
|
|
41
|
-
dotSlot: h,
|
|
42
|
-
labelSlot: g
|
|
43
41
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
points:
|
|
49
|
-
|
|
42
|
+
const dotSize = r * 2 + strokeWidth;
|
|
43
|
+
const lineContext = {
|
|
44
|
+
clipPathId,
|
|
45
|
+
layout,
|
|
46
|
+
points: computed(() => lineData.value),
|
|
47
|
+
props,
|
|
48
|
+
attrs,
|
|
49
|
+
lineData,
|
|
50
|
+
isAnimating,
|
|
51
|
+
needClip,
|
|
52
|
+
dot,
|
|
53
|
+
clipDot,
|
|
54
|
+
dotSize,
|
|
55
|
+
shapeSlot,
|
|
56
|
+
dotSlot,
|
|
57
|
+
labelSlot
|
|
58
|
+
};
|
|
59
|
+
provideLineContext(lineContext);
|
|
60
|
+
return {
|
|
61
|
+
shouldRender,
|
|
62
|
+
needClip,
|
|
63
|
+
lineData,
|
|
64
|
+
points: lineContext.points,
|
|
65
|
+
clipPathId
|
|
50
66
|
};
|
|
51
67
|
}
|
|
52
68
|
//#endregion
|
|
53
|
-
export {
|
|
69
|
+
export { LineContextKey, provideLineContext, useLine, useLineContext };
|
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { classProp } from "../../types/common.mjs";
|
|
2
|
+
import { CurveVueProps } from "../../shape/Curve.mjs";
|
|
2
3
|
//#region src/cartesian/line/type.ts
|
|
3
|
-
var
|
|
4
|
-
...
|
|
4
|
+
var LineVueProps = {
|
|
5
|
+
...CurveVueProps,
|
|
5
6
|
activeDot: {
|
|
6
7
|
type: [
|
|
7
8
|
Boolean,
|
|
8
9
|
Object,
|
|
9
10
|
Function
|
|
10
11
|
],
|
|
11
|
-
default:
|
|
12
|
-
},
|
|
13
|
-
animationDuration: { type: Number },
|
|
14
|
-
animationEasing: { type: String },
|
|
15
|
-
animationBegin: {
|
|
16
|
-
type: Number,
|
|
17
|
-
default: 0
|
|
12
|
+
default: true
|
|
18
13
|
},
|
|
19
14
|
animationId: { type: String },
|
|
20
15
|
isAnimationActive: {
|
|
21
16
|
type: Boolean,
|
|
22
|
-
default:
|
|
17
|
+
default: true
|
|
23
18
|
},
|
|
24
19
|
connectNulls: {
|
|
25
20
|
type: Boolean,
|
|
26
|
-
default:
|
|
21
|
+
default: false
|
|
27
22
|
},
|
|
28
23
|
data: {
|
|
29
24
|
type: Array,
|
|
@@ -35,7 +30,7 @@ var t = {
|
|
|
35
30
|
Number,
|
|
36
31
|
Function
|
|
37
32
|
],
|
|
38
|
-
required:
|
|
33
|
+
required: true
|
|
39
34
|
},
|
|
40
35
|
dot: {
|
|
41
36
|
type: [
|
|
@@ -43,11 +38,11 @@ var t = {
|
|
|
43
38
|
Object,
|
|
44
39
|
Function
|
|
45
40
|
],
|
|
46
|
-
default:
|
|
41
|
+
default: true
|
|
47
42
|
},
|
|
48
43
|
hide: {
|
|
49
44
|
type: Boolean,
|
|
50
|
-
default:
|
|
45
|
+
default: false
|
|
51
46
|
},
|
|
52
47
|
label: { type: [Boolean, Object] },
|
|
53
48
|
legendType: {
|
|
@@ -84,7 +79,7 @@ var t = {
|
|
|
84
79
|
},
|
|
85
80
|
needClip: {
|
|
86
81
|
type: Boolean,
|
|
87
|
-
default:
|
|
82
|
+
default: false
|
|
88
83
|
},
|
|
89
84
|
id: { type: String },
|
|
90
85
|
activeIndex: { type: Number },
|
|
@@ -106,7 +101,7 @@ var t = {
|
|
|
106
101
|
default: 0
|
|
107
102
|
},
|
|
108
103
|
name: { type: [String, Number] },
|
|
109
|
-
class:
|
|
104
|
+
class: classProp
|
|
110
105
|
};
|
|
111
106
|
//#endregion
|
|
112
|
-
export {
|
|
107
|
+
export { LineVueProps };
|
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import { isNullish
|
|
2
|
-
import { getCateCoordinateOfLine
|
|
1
|
+
import { isNullish } from "../../utils/validate.mjs";
|
|
2
|
+
import { getCateCoordinateOfLine, getValueByDataKey } from "../../utils/chart.mjs";
|
|
3
3
|
//#region src/cartesian/line/utils.ts
|
|
4
|
-
function
|
|
5
|
-
return
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
x:
|
|
9
|
-
axis:
|
|
10
|
-
ticks:
|
|
11
|
-
bandSize
|
|
12
|
-
entry
|
|
13
|
-
index
|
|
4
|
+
function computeLinePoints({ layout, xAxis, yAxis, xAxisTicks, yAxisTicks, dataKey, bandSize, displayedData }) {
|
|
5
|
+
return displayedData.map((entry, index) => {
|
|
6
|
+
const value = getValueByDataKey(entry, dataKey);
|
|
7
|
+
if (layout === "horizontal") return {
|
|
8
|
+
x: getCateCoordinateOfLine({
|
|
9
|
+
axis: xAxis,
|
|
10
|
+
ticks: xAxisTicks,
|
|
11
|
+
bandSize,
|
|
12
|
+
entry,
|
|
13
|
+
index
|
|
14
14
|
}),
|
|
15
|
-
y:
|
|
16
|
-
value
|
|
17
|
-
payload:
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
y: isNullish(value) ? null : yAxis.scale(value),
|
|
16
|
+
value,
|
|
17
|
+
payload: entry
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
x: isNullish(value) ? null : xAxis.scale(value),
|
|
21
|
+
y: getCateCoordinateOfLine({
|
|
22
|
+
axis: yAxis,
|
|
23
|
+
ticks: yAxisTicks,
|
|
24
|
+
bandSize,
|
|
25
|
+
entry,
|
|
26
|
+
index
|
|
26
27
|
}),
|
|
27
|
-
value
|
|
28
|
-
payload:
|
|
28
|
+
value,
|
|
29
|
+
payload: entry
|
|
29
30
|
};
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
//#endregion
|
|
33
|
-
export {
|
|
34
|
+
export { computeLinePoints };
|