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
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { mouseLeaveItem, setActiveMouseOverItemIndex } from "../../state/tooltipSlice.mjs";
|
|
2
|
+
import { useAppDispatch, useAppSelector } from "../../state/hooks.mjs";
|
|
3
|
+
import { useIsAnimating } from "../../hooks/useIsAnimating.mjs";
|
|
4
|
+
import { Layer } from "../../container/Layer.mjs";
|
|
5
|
+
import { provideCartesianLabelListData } from "../../context/cartesianLabelListContext.mjs";
|
|
6
|
+
import { Animate } from "../../animation/Animate.mjs";
|
|
7
|
+
import { SetPolarGraphicalItem } from "../../state/SetGraphicalItem.mjs";
|
|
8
|
+
import { SetLegendPayload } from "../../state/SetLegendPayload.mjs";
|
|
9
|
+
import { SetTooltipEntrySettings } from "../../state/SetTooltipEntrySettings.mjs";
|
|
10
|
+
import { extractCellProps, filterOutCells } from "../../utils/cell.mjs";
|
|
11
|
+
import { Trapezoid } from "../../shape/Trapezoid.mjs";
|
|
12
|
+
import { selectFunnelTrapezoids } from "../../state/selectors/funnelSelectors.mjs";
|
|
13
|
+
import { FunnelVueProps } from "./type.mjs";
|
|
14
|
+
import { computed, createVNode, defineComponent, mergeProps, shallowRef } from "vue";
|
|
15
|
+
//#region src/cartesian/funnel/Funnel.tsx
|
|
16
|
+
var Funnel = /* @__PURE__ */ defineComponent({
|
|
17
|
+
name: "Funnel",
|
|
18
|
+
props: FunnelVueProps,
|
|
19
|
+
inheritAttrs: false,
|
|
20
|
+
slots: Object,
|
|
21
|
+
setup(props, { attrs, slots }) {
|
|
22
|
+
const dispatch = useAppDispatch();
|
|
23
|
+
const isAnimating = useIsAnimating(() => props.isAnimationActive);
|
|
24
|
+
const cellPropsRef = shallowRef([]);
|
|
25
|
+
const funnelSettings = computed(() => ({
|
|
26
|
+
data: props.data,
|
|
27
|
+
dataKey: props.dataKey,
|
|
28
|
+
nameKey: props.nameKey,
|
|
29
|
+
tooltipType: props.tooltipType,
|
|
30
|
+
lastShapeType: props.lastShapeType,
|
|
31
|
+
reversed: props.reversed,
|
|
32
|
+
customWidth: props.width,
|
|
33
|
+
presentationProps: {
|
|
34
|
+
fill: props.fill,
|
|
35
|
+
stroke: props.stroke
|
|
36
|
+
}
|
|
37
|
+
}));
|
|
38
|
+
SetPolarGraphicalItem(computed(() => ({
|
|
39
|
+
type: "funnel",
|
|
40
|
+
data: props.data ?? [],
|
|
41
|
+
dataKey: props.dataKey,
|
|
42
|
+
hide: props.hide,
|
|
43
|
+
angleAxisId: 0,
|
|
44
|
+
radiusAxisId: 0
|
|
45
|
+
})));
|
|
46
|
+
const composedData = useAppSelector((state) => selectFunnelTrapezoids(state, funnelSettings.value));
|
|
47
|
+
const trapezoids = computed(() => composedData.value?.trapezoids ?? []);
|
|
48
|
+
SetLegendPayload(computed(() => {
|
|
49
|
+
const trapList = trapezoids.value;
|
|
50
|
+
if (!trapList || trapList.length === 0) return [];
|
|
51
|
+
const cells = cellPropsRef.value;
|
|
52
|
+
return trapList.map((trap, i) => ({
|
|
53
|
+
type: props.legendType,
|
|
54
|
+
value: String(trap.name ?? ""),
|
|
55
|
+
color: cells[i]?.fill ?? trap.fill ?? props.fill,
|
|
56
|
+
payload: trap.payload
|
|
57
|
+
}));
|
|
58
|
+
}));
|
|
59
|
+
SetTooltipEntrySettings({
|
|
60
|
+
fn: (v) => v,
|
|
61
|
+
args: computed(() => ({
|
|
62
|
+
dataDefinedOnItem: props.data ?? [],
|
|
63
|
+
positions: trapezoids.value.map((t) => t.tooltipPosition),
|
|
64
|
+
settings: {
|
|
65
|
+
dataKey: props.dataKey,
|
|
66
|
+
nameKey: props.nameKey,
|
|
67
|
+
name: String(props.dataKey ?? ""),
|
|
68
|
+
hide: props.hide,
|
|
69
|
+
type: props.tooltipType,
|
|
70
|
+
color: props.fill,
|
|
71
|
+
fill: props.fill,
|
|
72
|
+
stroke: props.stroke,
|
|
73
|
+
unit: ""
|
|
74
|
+
}
|
|
75
|
+
}))
|
|
76
|
+
});
|
|
77
|
+
provideCartesianLabelListData(computed(() => {
|
|
78
|
+
if (props.isAnimationActive && isAnimating.value) return void 0;
|
|
79
|
+
const trapList = trapezoids.value;
|
|
80
|
+
if (!trapList || trapList.length === 0) return void 0;
|
|
81
|
+
return trapList.map((trap) => ({
|
|
82
|
+
x: trap.x,
|
|
83
|
+
y: trap.y,
|
|
84
|
+
width: Math.max(trap.upperWidth, trap.lowerWidth),
|
|
85
|
+
height: trap.height,
|
|
86
|
+
value: trap.value ?? trap.val ?? "",
|
|
87
|
+
payload: trap.payload,
|
|
88
|
+
parentViewBox: trap.parentViewBox,
|
|
89
|
+
fill: trap.fill ?? props.fill
|
|
90
|
+
}));
|
|
91
|
+
}));
|
|
92
|
+
function handleTrapezoidEnter(trap, index) {
|
|
93
|
+
dispatch(setActiveMouseOverItemIndex({
|
|
94
|
+
activeIndex: String(index),
|
|
95
|
+
activeDataKey: props.dataKey,
|
|
96
|
+
activeCoordinate: trap.tooltipPosition
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
function handleTrapezoidLeave() {
|
|
100
|
+
dispatch(mouseLeaveItem());
|
|
101
|
+
}
|
|
102
|
+
return () => {
|
|
103
|
+
if (props.hide) return null;
|
|
104
|
+
const trapList = trapezoids.value;
|
|
105
|
+
if (!trapList || trapList.length === 0) return null;
|
|
106
|
+
const defaultContent = slots.default?.() ?? [];
|
|
107
|
+
const cells = extractCellProps(defaultContent);
|
|
108
|
+
cellPropsRef.value = cells;
|
|
109
|
+
const nonCellContent = cells.length > 0 ? filterOutCells(defaultContent) : defaultContent;
|
|
110
|
+
const stroke = attrs.stroke ?? props.stroke;
|
|
111
|
+
return createVNode(Layer, { "class": ["v-charts-funnel", props.class] }, { default: () => [createVNode(Animate, {
|
|
112
|
+
"isActive": props.isAnimationActive,
|
|
113
|
+
"from": 0,
|
|
114
|
+
"to": 1,
|
|
115
|
+
"transition": props.transition,
|
|
116
|
+
"onAnimationStart": props.onAnimationStart,
|
|
117
|
+
"onAnimationEnd": () => {
|
|
118
|
+
isAnimating.value = false;
|
|
119
|
+
props.onAnimationEnd?.();
|
|
120
|
+
}
|
|
121
|
+
}, { default: (progress) => {
|
|
122
|
+
return trapList.map((trap, i) => {
|
|
123
|
+
const animatedHeight = trap.height * progress;
|
|
124
|
+
const yOffset = trap.height * (1 - progress);
|
|
125
|
+
const animatedUpperWidth = trap.upperWidth * progress;
|
|
126
|
+
const animatedLowerWidth = trap.lowerWidth * progress;
|
|
127
|
+
const animatedX = trap.x + trap.upperWidth / 2 - animatedUpperWidth / 2;
|
|
128
|
+
const cellProps = cells[i] ?? {};
|
|
129
|
+
const trapFill = cellProps.fill ?? trap.fill ?? props.fill;
|
|
130
|
+
const trapStroke = cellProps.stroke ?? stroke;
|
|
131
|
+
const trapezoidProps = {
|
|
132
|
+
...trap,
|
|
133
|
+
x: animatedX,
|
|
134
|
+
y: trap.y + yOffset / 2,
|
|
135
|
+
height: animatedHeight,
|
|
136
|
+
upperWidth: animatedUpperWidth,
|
|
137
|
+
lowerWidth: animatedLowerWidth,
|
|
138
|
+
fill: trapFill,
|
|
139
|
+
stroke: trapStroke,
|
|
140
|
+
animationProgress: progress
|
|
141
|
+
};
|
|
142
|
+
const content = slots.shape ? slots.shape(trapezoidProps) : createVNode(Trapezoid, mergeProps(attrs, {
|
|
143
|
+
"x": trapezoidProps.x,
|
|
144
|
+
"y": trapezoidProps.y,
|
|
145
|
+
"upperWidth": trapezoidProps.upperWidth,
|
|
146
|
+
"lowerWidth": trapezoidProps.lowerWidth,
|
|
147
|
+
"height": trapezoidProps.height,
|
|
148
|
+
"fill": trapFill,
|
|
149
|
+
"stroke": trapStroke
|
|
150
|
+
}), null);
|
|
151
|
+
return createVNode("g", {
|
|
152
|
+
"key": `trapezoid-${i}`,
|
|
153
|
+
"onMouseenter": () => handleTrapezoidEnter(trap, i),
|
|
154
|
+
"onMouseleave": handleTrapezoidLeave
|
|
155
|
+
}, [content]);
|
|
156
|
+
});
|
|
157
|
+
} }), nonCellContent] });
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
//#endregion
|
|
162
|
+
export { Funnel };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { classProp } from "../../types/common.mjs";
|
|
2
|
+
//#region src/cartesian/funnel/type.ts
|
|
3
|
+
var FunnelVueProps = {
|
|
4
|
+
data: {
|
|
5
|
+
type: Array,
|
|
6
|
+
default: void 0
|
|
7
|
+
},
|
|
8
|
+
dataKey: {
|
|
9
|
+
type: [
|
|
10
|
+
String,
|
|
11
|
+
Number,
|
|
12
|
+
Function
|
|
13
|
+
],
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
nameKey: {
|
|
17
|
+
type: [
|
|
18
|
+
String,
|
|
19
|
+
Number,
|
|
20
|
+
Function
|
|
21
|
+
],
|
|
22
|
+
default: "name"
|
|
23
|
+
},
|
|
24
|
+
lastShapeType: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: "triangle"
|
|
27
|
+
},
|
|
28
|
+
reversed: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: false
|
|
31
|
+
},
|
|
32
|
+
fill: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: "#808080"
|
|
35
|
+
},
|
|
36
|
+
stroke: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: "#fff"
|
|
39
|
+
},
|
|
40
|
+
legendType: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: "rect"
|
|
43
|
+
},
|
|
44
|
+
tooltipType: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: void 0
|
|
47
|
+
},
|
|
48
|
+
hide: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: false
|
|
51
|
+
},
|
|
52
|
+
isAnimationActive: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: true
|
|
55
|
+
},
|
|
56
|
+
transition: {
|
|
57
|
+
type: Object,
|
|
58
|
+
default: () => ({
|
|
59
|
+
duration: .8,
|
|
60
|
+
ease: "easeOut"
|
|
61
|
+
})
|
|
62
|
+
},
|
|
63
|
+
onAnimationStart: {
|
|
64
|
+
type: Function,
|
|
65
|
+
default: void 0
|
|
66
|
+
},
|
|
67
|
+
onAnimationEnd: {
|
|
68
|
+
type: Function,
|
|
69
|
+
default: void 0
|
|
70
|
+
},
|
|
71
|
+
width: {
|
|
72
|
+
type: [Number, String],
|
|
73
|
+
default: void 0
|
|
74
|
+
},
|
|
75
|
+
class: classProp
|
|
76
|
+
};
|
|
77
|
+
//#endregion
|
|
78
|
+
export { FunnelVueProps };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { isNumber } from "../../utils/validate.mjs";
|
|
2
|
+
import { getValueByDataKey } from "../../utils/chart.mjs";
|
|
3
|
+
import { omit } from "lodash-es";
|
|
4
|
+
//#region src/cartesian/funnel/utils.ts
|
|
5
|
+
function getRealWidthHeight({ customWidth }, offset) {
|
|
6
|
+
const { width, height, left, right, top, bottom } = offset;
|
|
7
|
+
const realHeight = height;
|
|
8
|
+
let realWidth = width;
|
|
9
|
+
if (isNumber(customWidth)) realWidth = customWidth;
|
|
10
|
+
else if (typeof customWidth === "string") realWidth = realWidth * parseFloat(customWidth) / 100;
|
|
11
|
+
return {
|
|
12
|
+
realWidth: realWidth - left - right,
|
|
13
|
+
realHeight: realHeight - bottom - top,
|
|
14
|
+
offsetX: (width - realWidth) / 2,
|
|
15
|
+
offsetY: (height - realHeight) / 2
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function computeFunnelTrapezoids({ dataKey, nameKey, displayedData, tooltipType, lastShapeType, reversed, offset, customWidth }) {
|
|
19
|
+
const { left, top } = offset;
|
|
20
|
+
const { realHeight, realWidth, offsetX, offsetY } = getRealWidthHeight({ customWidth }, offset);
|
|
21
|
+
const maxValue = Math.max.apply(null, displayedData.map((entry) => getValueByDataKey(entry, dataKey, 0)));
|
|
22
|
+
const len = displayedData.length;
|
|
23
|
+
const rowHeight = realHeight / len;
|
|
24
|
+
const parentViewBox = {
|
|
25
|
+
x: offset.left,
|
|
26
|
+
y: offset.top,
|
|
27
|
+
width: offset.width,
|
|
28
|
+
height: offset.height
|
|
29
|
+
};
|
|
30
|
+
let trapezoids = displayedData.map((entry, i) => {
|
|
31
|
+
const rawVal = getValueByDataKey(entry, dataKey, 0);
|
|
32
|
+
const name = getValueByDataKey(entry, nameKey, i);
|
|
33
|
+
let val = rawVal;
|
|
34
|
+
let nextVal;
|
|
35
|
+
if (i !== len - 1) {
|
|
36
|
+
nextVal = getValueByDataKey(displayedData[i + 1], dataKey, 0);
|
|
37
|
+
if (Array.isArray(nextVal)) [nextVal] = nextVal;
|
|
38
|
+
} else if (Array.isArray(rawVal) && rawVal.length === 2) [val, nextVal] = rawVal;
|
|
39
|
+
else if (lastShapeType === "rectangle") nextVal = val;
|
|
40
|
+
else nextVal = 0;
|
|
41
|
+
const x = (maxValue - val) * realWidth / (2 * maxValue) + left + offsetX;
|
|
42
|
+
const y = rowHeight * i + top + offsetY;
|
|
43
|
+
const upperWidth = val / maxValue * realWidth;
|
|
44
|
+
const lowerWidth = nextVal / maxValue * realWidth;
|
|
45
|
+
const tooltipPayload = [{
|
|
46
|
+
name,
|
|
47
|
+
value: val,
|
|
48
|
+
payload: entry,
|
|
49
|
+
dataKey,
|
|
50
|
+
type: tooltipType
|
|
51
|
+
}];
|
|
52
|
+
const tooltipPosition = {
|
|
53
|
+
x: x + upperWidth / 2,
|
|
54
|
+
y: y + rowHeight / 2
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
x,
|
|
58
|
+
y,
|
|
59
|
+
width: Math.max(upperWidth, lowerWidth),
|
|
60
|
+
upperWidth,
|
|
61
|
+
lowerWidth,
|
|
62
|
+
height: rowHeight,
|
|
63
|
+
name,
|
|
64
|
+
val,
|
|
65
|
+
tooltipPayload,
|
|
66
|
+
tooltipPosition,
|
|
67
|
+
...omit(entry, "width"),
|
|
68
|
+
payload: entry,
|
|
69
|
+
parentViewBox,
|
|
70
|
+
labelViewBox: {
|
|
71
|
+
x: x + (upperWidth - lowerWidth) / 4,
|
|
72
|
+
y,
|
|
73
|
+
width: Math.abs(upperWidth - lowerWidth) / 2 + Math.min(upperWidth, lowerWidth),
|
|
74
|
+
height: rowHeight
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
if (reversed) trapezoids = trapezoids.map((entry, index) => {
|
|
79
|
+
const newY = entry.y - index * rowHeight + (len - 1 - index) * rowHeight;
|
|
80
|
+
return {
|
|
81
|
+
...entry,
|
|
82
|
+
upperWidth: entry.lowerWidth,
|
|
83
|
+
lowerWidth: entry.upperWidth,
|
|
84
|
+
x: entry.x - (entry.lowerWidth - entry.upperWidth) / 2,
|
|
85
|
+
y: entry.y - index * rowHeight + (len - 1 - index) * rowHeight,
|
|
86
|
+
tooltipPosition: {
|
|
87
|
+
...entry.tooltipPosition,
|
|
88
|
+
y: newY + rowHeight / 2
|
|
89
|
+
},
|
|
90
|
+
labelViewBox: {
|
|
91
|
+
...entry.labelViewBox,
|
|
92
|
+
y: newY
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
return {
|
|
97
|
+
trapezoids,
|
|
98
|
+
data: displayedData
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { computeFunnelTrapezoids };
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { isNullish
|
|
2
|
-
import { selectActiveTooltipIndex
|
|
3
|
-
import { useAppSelector
|
|
4
|
-
import { Layer
|
|
5
|
-
import { Dot
|
|
6
|
-
import { createVNode
|
|
1
|
+
import { isNullish } from "../../utils/validate.mjs";
|
|
2
|
+
import { selectActiveTooltipIndex } from "../../state/selectors/tooltipSelectors.mjs";
|
|
3
|
+
import { useAppSelector } from "../../state/hooks.mjs";
|
|
4
|
+
import { Layer } from "../../container/Layer.mjs";
|
|
5
|
+
import { Dot } from "../../shape/Dot.mjs";
|
|
6
|
+
import { createVNode, defineComponent, isVNode } from "vue";
|
|
7
7
|
//#region src/cartesian/line/ActivePoints.tsx
|
|
8
|
-
function
|
|
9
|
-
return typeof
|
|
8
|
+
function _isSlot(s) {
|
|
9
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
10
10
|
}
|
|
11
|
-
var
|
|
11
|
+
var ActivePoints = /* @__PURE__ */ defineComponent({
|
|
12
12
|
name: "ActivePoints",
|
|
13
13
|
props: {
|
|
14
14
|
points: {
|
|
15
15
|
type: Array,
|
|
16
|
-
required:
|
|
16
|
+
required: true
|
|
17
17
|
},
|
|
18
18
|
mainColor: {
|
|
19
19
|
type: String,
|
|
20
|
-
required:
|
|
20
|
+
required: true
|
|
21
21
|
},
|
|
22
22
|
itemDataKey: {
|
|
23
23
|
type: [
|
|
@@ -25,7 +25,7 @@ var l = /* @__PURE__ */ o({
|
|
|
25
25
|
Number,
|
|
26
26
|
Function
|
|
27
27
|
],
|
|
28
|
-
required:
|
|
28
|
+
required: true
|
|
29
29
|
},
|
|
30
30
|
activeDot: {
|
|
31
31
|
type: [
|
|
@@ -33,43 +33,47 @@ var l = /* @__PURE__ */ o({
|
|
|
33
33
|
Boolean,
|
|
34
34
|
Function
|
|
35
35
|
],
|
|
36
|
-
required:
|
|
36
|
+
required: true
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
slots: Object,
|
|
40
|
-
setup(
|
|
41
|
-
|
|
40
|
+
setup(props, { slots }) {
|
|
41
|
+
const activeTooltipIndex = useAppSelector(selectActiveTooltipIndex);
|
|
42
42
|
return () => {
|
|
43
|
-
|
|
44
|
-
if (!
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
const { points } = props;
|
|
44
|
+
if (!points?.length || isNullish(activeTooltipIndex.value)) return null;
|
|
45
|
+
const activePoint = points[Number(activeTooltipIndex.value)];
|
|
46
|
+
if (isNullish(activePoint)) return null;
|
|
47
|
+
return renderActivePoint({
|
|
48
|
+
point: activePoint,
|
|
49
|
+
childIndex: Number(activeTooltipIndex.value),
|
|
50
|
+
mainColor: props.mainColor,
|
|
51
|
+
dataKey: props.itemDataKey,
|
|
52
|
+
activeDot: props.activeDot,
|
|
53
|
+
slots
|
|
53
54
|
});
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
});
|
|
57
|
-
function
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
index:
|
|
61
|
-
dataKey
|
|
62
|
-
cx:
|
|
63
|
-
cy:
|
|
64
|
-
r: 4,
|
|
65
|
-
fill:
|
|
58
|
+
function renderActivePoint({ point, childIndex, mainColor, activeDot, dataKey, slots }) {
|
|
59
|
+
if (activeDot === false) return null;
|
|
60
|
+
const dotProps = {
|
|
61
|
+
"index": childIndex,
|
|
62
|
+
dataKey,
|
|
63
|
+
"cx": point.x,
|
|
64
|
+
"cy": point.y,
|
|
65
|
+
"r": 4,
|
|
66
|
+
"fill": mainColor,
|
|
66
67
|
"stroke-width": 2,
|
|
67
|
-
stroke: "#fff",
|
|
68
|
-
payload:
|
|
69
|
-
value:
|
|
70
|
-
...typeof
|
|
71
|
-
}
|
|
72
|
-
|
|
68
|
+
"stroke": "#fff",
|
|
69
|
+
"payload": point.payload,
|
|
70
|
+
"value": point.value,
|
|
71
|
+
...typeof activeDot === "object" ? activeDot : {}
|
|
72
|
+
};
|
|
73
|
+
let dot;
|
|
74
|
+
if (slots.activeDot) dot = slots.activeDot(dotProps);
|
|
75
|
+
else dot = createVNode(Dot, dotProps, null);
|
|
76
|
+
return createVNode(Layer, { "class": "v-charts-active-dot" }, _isSlot(dot) ? dot : { default: () => [dot] });
|
|
73
77
|
}
|
|
74
78
|
//#endregion
|
|
75
|
-
export {
|
|
79
|
+
export { ActivePoints };
|
|
@@ -1,46 +1,50 @@
|
|
|
1
|
-
import { Layer
|
|
2
|
-
import { provideCartesianLabelListData
|
|
3
|
-
import { useSetupGraphicalItem
|
|
4
|
-
import { useGraphicalLayerRef
|
|
5
|
-
import { GraphicalItemClipPath
|
|
6
|
-
import { LineVueProps
|
|
7
|
-
import { useLine
|
|
8
|
-
import { StaticLine
|
|
9
|
-
import { ActivePoints
|
|
10
|
-
import { Fragment
|
|
1
|
+
import { Layer } from "../../container/Layer.mjs";
|
|
2
|
+
import { provideCartesianLabelListData } from "../../context/cartesianLabelListContext.mjs";
|
|
3
|
+
import { useSetupGraphicalItem } from "../../hooks/useSetupGraphicalItem.mjs";
|
|
4
|
+
import { useGraphicalLayerRef } from "../../context/graphicalLayerContext.mjs";
|
|
5
|
+
import { GraphicalItemClipPath } from "../GraphicalItemClipPath.mjs";
|
|
6
|
+
import { LineVueProps } from "./type.mjs";
|
|
7
|
+
import { useLine } from "./hooks/useLine.mjs";
|
|
8
|
+
import { StaticLine } from "./StaticLine.mjs";
|
|
9
|
+
import { ActivePoints } from "./ActivePoints.mjs";
|
|
10
|
+
import { Fragment, Teleport, computed, createVNode, defineComponent, isVNode } from "vue";
|
|
11
11
|
//#region src/cartesian/line/Line.tsx
|
|
12
|
-
function
|
|
13
|
-
return typeof
|
|
12
|
+
function _isSlot(s) {
|
|
13
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
14
14
|
}
|
|
15
|
-
var
|
|
15
|
+
var Line = /* @__PURE__ */ defineComponent({
|
|
16
16
|
name: "Line",
|
|
17
|
-
props:
|
|
18
|
-
inheritAttrs:
|
|
17
|
+
props: LineVueProps,
|
|
18
|
+
inheritAttrs: false,
|
|
19
19
|
slots: Object,
|
|
20
|
-
setup(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
setup(props, { attrs, slots }) {
|
|
21
|
+
useSetupGraphicalItem(props, "line");
|
|
22
|
+
const { shouldRender, needClip, clipPathId, lineData, points } = useLine(props, attrs, slots.shape, slots.dot, slots.label);
|
|
23
|
+
const graphicalLayerRef = useGraphicalLayerRef(null);
|
|
24
|
+
provideCartesianLabelListData(computed(() => lineData.value));
|
|
25
|
+
return () => {
|
|
26
|
+
if (!shouldRender.value) return null;
|
|
27
|
+
let activeDot;
|
|
28
|
+
if (slots.activeDot) activeDot = { activeDot: slots.activeDot };
|
|
29
|
+
const defaultContent = slots.default?.();
|
|
30
|
+
const lineContent = createVNode(Fragment, null, [createVNode(Layer, { "class": ["v-charts-line", attrs.class] }, { default: () => [
|
|
31
|
+
needClip.value && createVNode("defs", null, [createVNode(GraphicalItemClipPath, {
|
|
32
|
+
"clipPathId": clipPathId.value,
|
|
33
|
+
"xAxisId": props.xAxisId,
|
|
34
|
+
"yAxisId": props.yAxisId
|
|
32
35
|
}, null)]),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
] }),
|
|
36
|
-
points:
|
|
37
|
-
mainColor:
|
|
38
|
-
itemDataKey:
|
|
39
|
-
activeDot:
|
|
40
|
-
},
|
|
41
|
-
|
|
36
|
+
createVNode(StaticLine, null, null),
|
|
37
|
+
defaultContent
|
|
38
|
+
] }), createVNode(ActivePoints, {
|
|
39
|
+
"points": lineData.value ?? [],
|
|
40
|
+
"mainColor": attrs.stroke ?? props.stroke,
|
|
41
|
+
"itemDataKey": props.dataKey,
|
|
42
|
+
"activeDot": props.activeDot
|
|
43
|
+
}, _isSlot(activeDot) ? activeDot : { default: () => [activeDot] })]);
|
|
44
|
+
if (graphicalLayerRef?.value) return createVNode(Teleport, { "to": graphicalLayerRef.value }, _isSlot(lineContent) ? lineContent : { default: () => [lineContent] });
|
|
45
|
+
return lineContent;
|
|
42
46
|
};
|
|
43
47
|
}
|
|
44
48
|
});
|
|
45
49
|
//#endregion
|
|
46
|
-
export {
|
|
50
|
+
export { Line };
|