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,89 +1,111 @@
|
|
|
1
|
-
import { getValueByDataKey
|
|
2
|
-
import { useChartLayout
|
|
3
|
-
import { Layer
|
|
4
|
-
import { provideCartesianLabelListData
|
|
5
|
-
import { LabelList
|
|
6
|
-
import { useSetupGraphicalItem
|
|
7
|
-
import { useGraphicalLayerRef
|
|
8
|
-
import { BarVueProps
|
|
9
|
-
import { useNeedsClip
|
|
10
|
-
import { useBar
|
|
11
|
-
import { GraphicalItemClipPath
|
|
12
|
-
import { BarBackground
|
|
13
|
-
import { BarRectangles
|
|
14
|
-
import { createErrorBarRegistry
|
|
15
|
-
import { Cell
|
|
16
|
-
import { Fragment
|
|
1
|
+
import { getValueByDataKey } from "../../utils/chart.mjs";
|
|
2
|
+
import { useChartLayout } from "../../context/chartLayoutContext.mjs";
|
|
3
|
+
import { Layer } from "../../container/Layer.mjs";
|
|
4
|
+
import { provideCartesianLabelListData } from "../../context/cartesianLabelListContext.mjs";
|
|
5
|
+
import { LabelList } from "../../components/label/LabelList.mjs";
|
|
6
|
+
import { useSetupGraphicalItem } from "../../hooks/useSetupGraphicalItem.mjs";
|
|
7
|
+
import { useGraphicalLayerRef } from "../../context/graphicalLayerContext.mjs";
|
|
8
|
+
import { BarVueProps } from "./type.mjs";
|
|
9
|
+
import { useNeedsClip } from "../useNeedsClip.mjs";
|
|
10
|
+
import { useBar } from "./hooks/useBar.mjs";
|
|
11
|
+
import { GraphicalItemClipPath } from "../GraphicalItemClipPath.mjs";
|
|
12
|
+
import { BarBackground } from "./components/BarBackground.mjs";
|
|
13
|
+
import { BarRectangles } from "./components/BarRectangles.mjs";
|
|
14
|
+
import { createErrorBarRegistry, provideErrorBarContext, provideErrorBarRegistry } from "../error-bar/ErrorBarContext.mjs";
|
|
15
|
+
import { Cell } from "../../components/Cell.mjs";
|
|
16
|
+
import { Fragment, Teleport, computed, createVNode, defineComponent, isVNode, mergeProps } from "vue";
|
|
17
17
|
//#region src/cartesian/bar/Bar.tsx
|
|
18
|
-
function
|
|
19
|
-
return typeof
|
|
18
|
+
function _isSlot(s) {
|
|
19
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
20
20
|
}
|
|
21
|
-
var
|
|
22
|
-
|
|
21
|
+
var errorBarDataPointFormatter = (dataPoint, dataKey) => {
|
|
22
|
+
const value = Array.isArray(dataPoint.value) ? dataPoint.value[1] : dataPoint.value;
|
|
23
23
|
return {
|
|
24
|
-
x:
|
|
25
|
-
y:
|
|
26
|
-
value
|
|
27
|
-
errorVal:
|
|
24
|
+
x: dataPoint.x,
|
|
25
|
+
y: dataPoint.y,
|
|
26
|
+
value,
|
|
27
|
+
errorVal: getValueByDataKey(dataPoint.payload ?? dataPoint, dataKey)
|
|
28
28
|
};
|
|
29
|
-
}
|
|
29
|
+
};
|
|
30
|
+
var Bar = /* @__PURE__ */ defineComponent({
|
|
30
31
|
name: "Bar",
|
|
31
|
-
props:
|
|
32
|
-
inheritAttrs:
|
|
32
|
+
props: BarVueProps,
|
|
33
|
+
inheritAttrs: false,
|
|
33
34
|
slots: Object,
|
|
34
|
-
setup(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
setup(props, { attrs, slots }) {
|
|
36
|
+
const errorBarRegistry = createErrorBarRegistry();
|
|
37
|
+
provideErrorBarRegistry(errorBarRegistry);
|
|
38
|
+
useSetupGraphicalItem(props, "bar", { errorBars: errorBarRegistry.errorBars });
|
|
39
|
+
const { shouldRender, clipPathId, barData, isAnimating, cellProps: cellPropsRef } = useBar(props, slots.shape, slots.activeBar);
|
|
40
|
+
const { needClip } = useNeedsClip(props.xAxisId, props.yAxisId);
|
|
41
|
+
const layout = useChartLayout();
|
|
42
|
+
const errorBarOffset = computed(() => {
|
|
43
|
+
const first = barData.value?.[0];
|
|
44
|
+
if (first == null || first.height == null || first.width == null) return 0;
|
|
45
|
+
return layout.value === "vertical" ? first.height / 2 : first.width / 2;
|
|
40
46
|
});
|
|
41
|
-
|
|
42
|
-
data:
|
|
43
|
-
xAxisId:
|
|
44
|
-
yAxisId:
|
|
45
|
-
dataPointFormatter:
|
|
46
|
-
errorBarOffset
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
provideErrorBarContext({
|
|
48
|
+
data: barData,
|
|
49
|
+
xAxisId: props.xAxisId ?? "xAxis-0",
|
|
50
|
+
yAxisId: props.yAxisId ?? "yAxis-0",
|
|
51
|
+
dataPointFormatter: errorBarDataPointFormatter,
|
|
52
|
+
errorBarOffset
|
|
53
|
+
});
|
|
54
|
+
provideCartesianLabelListData(computed(() => {
|
|
55
|
+
if (isAnimating.value || !barData.value) return void 0;
|
|
56
|
+
return barData.value.map((entry, i) => {
|
|
57
|
+
const fill = cellPropsRef.value?.[i]?.fill ?? entry.payload?.fill ?? props.fill;
|
|
50
58
|
return {
|
|
51
|
-
x:
|
|
52
|
-
y:
|
|
53
|
-
width:
|
|
54
|
-
height:
|
|
55
|
-
value:
|
|
56
|
-
payload:
|
|
57
|
-
parentViewBox:
|
|
58
|
-
...
|
|
59
|
+
x: entry.x,
|
|
60
|
+
y: entry.y,
|
|
61
|
+
width: entry.width,
|
|
62
|
+
height: entry.height,
|
|
63
|
+
value: entry.value,
|
|
64
|
+
payload: entry.payload,
|
|
65
|
+
parentViewBox: entry.parentViewBox,
|
|
66
|
+
...fill != null ? { fill } : {}
|
|
59
67
|
};
|
|
60
68
|
});
|
|
61
69
|
}));
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
const graphicalLayerRef = useGraphicalLayerRef(null);
|
|
71
|
+
const extractCellProps = (vnodes) => {
|
|
72
|
+
const result = [];
|
|
73
|
+
for (const vnode of vnodes) if (vnode.type === Cell) result.push(vnode.props ?? {});
|
|
74
|
+
else if (vnode.type === Fragment && Array.isArray(vnode.children)) result.push(...extractCellProps(vnode.children));
|
|
75
|
+
return result;
|
|
76
|
+
};
|
|
77
|
+
const filterOutCells = (vnodes) => {
|
|
78
|
+
const result = [];
|
|
79
|
+
for (const vnode of vnodes) {
|
|
80
|
+
if (vnode.type === Cell) continue;
|
|
81
|
+
if (vnode.type === Fragment && Array.isArray(vnode.children)) result.push(...filterOutCells(vnode.children));
|
|
82
|
+
else result.push(vnode);
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
};
|
|
67
86
|
return () => {
|
|
68
|
-
if (!
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
87
|
+
if (!shouldRender.value) return null;
|
|
88
|
+
const defaultContent = slots.default?.() ?? [];
|
|
89
|
+
const cells = extractCellProps(defaultContent);
|
|
90
|
+
cellPropsRef.value = cells;
|
|
91
|
+
const nonCellContent = cells.length > 0 ? filterOutCells(defaultContent) : defaultContent;
|
|
92
|
+
const barContent = createVNode(Layer, { "class": ["v-charts-bar", attrs.class] }, { default: () => [
|
|
93
|
+
needClip.value && createVNode("defs", null, [createVNode(GraphicalItemClipPath, {
|
|
94
|
+
"clipPathId": clipPathId,
|
|
95
|
+
"xAxisId": props.xAxisId,
|
|
96
|
+
"yAxisId": props.yAxisId
|
|
76
97
|
}, null)]),
|
|
77
|
-
|
|
78
|
-
class: "v-charts-bar-rectangles",
|
|
79
|
-
"clip-path":
|
|
80
|
-
}, { default: () => [
|
|
81
|
-
!
|
|
82
|
-
|
|
98
|
+
createVNode(Layer, {
|
|
99
|
+
"class": "v-charts-bar-rectangles",
|
|
100
|
+
"clip-path": needClip.value ? `url(#clipPath-${clipPathId})` : null
|
|
101
|
+
}, { default: () => [props.background && createVNode(BarBackground, null, null), createVNode(BarRectangles, null, null)] }),
|
|
102
|
+
!isAnimating.value && props.label && createVNode(LabelList, mergeProps(typeof props.label === "object" ? props.label : {}, { "data": barData.value }), null),
|
|
103
|
+
nonCellContent
|
|
83
104
|
] });
|
|
84
|
-
|
|
105
|
+
if (graphicalLayerRef?.value) return createVNode(Teleport, { "to": graphicalLayerRef.value }, _isSlot(barContent) ? barContent : { default: () => [barContent] });
|
|
106
|
+
return barContent;
|
|
85
107
|
};
|
|
86
108
|
}
|
|
87
109
|
});
|
|
88
110
|
//#endregion
|
|
89
|
-
export {
|
|
111
|
+
export { Bar };
|
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import { Layer
|
|
2
|
-
import { useBarContext
|
|
3
|
-
import { Rectangle
|
|
4
|
-
import { Fragment
|
|
1
|
+
import { Layer } from "../../../container/Layer.mjs";
|
|
2
|
+
import { useBarContext } from "../hooks/useBar.mjs";
|
|
3
|
+
import { Rectangle } from "../../../shape/Rectangle.mjs";
|
|
4
|
+
import { Fragment, createVNode, defineComponent } from "vue";
|
|
5
5
|
//#region src/cartesian/bar/components/BarBackground.tsx
|
|
6
|
-
var
|
|
6
|
+
var BarBackground = /* @__PURE__ */ defineComponent({
|
|
7
7
|
name: "BarBackground",
|
|
8
|
-
inheritAttrs:
|
|
9
|
-
setup(
|
|
10
|
-
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
setup(_, { attrs }) {
|
|
10
|
+
const { props, data: barData } = useBarContext();
|
|
11
11
|
return () => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
const data = barData.value;
|
|
13
|
+
const backgroundFromProps = props.background;
|
|
14
|
+
if (!backgroundFromProps || !data) return null;
|
|
15
|
+
return createVNode(Fragment, null, [data.map((entry, i) => {
|
|
16
|
+
const { value, background: backgroundFromDataEntry, tooltipPosition, ...rest } = entry;
|
|
17
|
+
if (!backgroundFromDataEntry) return null;
|
|
18
|
+
const backgroundObjectProps = typeof backgroundFromProps === "object" ? backgroundFromProps : {};
|
|
19
|
+
const barRectangleProps = {
|
|
20
|
+
option: backgroundFromProps,
|
|
21
|
+
...rest,
|
|
19
22
|
fill: "#eee",
|
|
20
|
-
...
|
|
21
|
-
...
|
|
23
|
+
...backgroundFromDataEntry,
|
|
24
|
+
...backgroundObjectProps
|
|
22
25
|
};
|
|
23
|
-
return
|
|
26
|
+
return createVNode(Layer, { "key": `background-bar-${i}` }, { default: () => [createVNode(Rectangle, barRectangleProps, null)] });
|
|
24
27
|
})]);
|
|
25
28
|
};
|
|
26
29
|
}
|
|
27
30
|
});
|
|
28
31
|
//#endregion
|
|
29
|
-
export {
|
|
32
|
+
export { BarBackground };
|
|
@@ -1,106 +1,143 @@
|
|
|
1
|
-
import { mouseLeaveItem
|
|
2
|
-
import { selectActiveTooltipDataKey
|
|
3
|
-
import { useAppDispatch
|
|
4
|
-
import { filterProps
|
|
5
|
-
import { Layer
|
|
6
|
-
import { Animate
|
|
7
|
-
import { useBarContext
|
|
8
|
-
import { Rectangle
|
|
9
|
-
import { Fragment
|
|
1
|
+
import { mouseLeaveItem, setActiveClickItemIndex, setActiveMouseOverItemIndex } from "../../../state/tooltipSlice.mjs";
|
|
2
|
+
import { selectActiveTooltipDataKey, selectActiveTooltipIndex } from "../../../state/selectors/tooltipSelectors.mjs";
|
|
3
|
+
import { useAppDispatch, useAppSelector } from "../../../state/hooks.mjs";
|
|
4
|
+
import { filterProps } from "../../../utils/VueUtils.mjs";
|
|
5
|
+
import { Layer } from "../../../container/Layer.mjs";
|
|
6
|
+
import { Animate } from "../../../animation/Animate.mjs";
|
|
7
|
+
import { useBarContext } from "../hooks/useBar.mjs";
|
|
8
|
+
import { Rectangle } from "../../../shape/Rectangle.mjs";
|
|
9
|
+
import { Fragment, createVNode, defineComponent, isVNode } from "vue";
|
|
10
10
|
//#region src/cartesian/bar/components/BarRectangles.tsx
|
|
11
|
-
function
|
|
12
|
-
return typeof
|
|
11
|
+
function _isSlot(s) {
|
|
12
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
13
13
|
}
|
|
14
|
-
var
|
|
14
|
+
var BarRectangles = /* @__PURE__ */ defineComponent({
|
|
15
15
|
name: "BarRectangles",
|
|
16
|
-
inheritAttrs:
|
|
17
|
-
setup(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
inheritAttrs: false,
|
|
17
|
+
setup(_) {
|
|
18
|
+
const dispatch = useAppDispatch();
|
|
19
|
+
const activeIndex = useAppSelector(selectActiveTooltipIndex);
|
|
20
|
+
const activeDataKey = useAppSelector(selectActiveTooltipDataKey);
|
|
21
|
+
let previousRectangles = null;
|
|
22
|
+
let animationId = 0;
|
|
23
|
+
const { props, data: barData, layout, isAnimating, shapeSlot, activeBarSlot, cellProps } = useBarContext();
|
|
24
|
+
const { dataKey, isAnimationActive, onAnimationStart, onAnimationEnd, activeBar, activeIndex: activeIndexProp } = props;
|
|
25
|
+
const onMouseEnterFromContext = (entry, index) => (e) => {
|
|
26
|
+
dispatch(setActiveMouseOverItemIndex({
|
|
27
|
+
activeDataKey: dataKey,
|
|
28
|
+
activeIndex: String(index),
|
|
22
29
|
activeCoordinate: {
|
|
23
|
-
x:
|
|
24
|
-
y:
|
|
30
|
+
x: entry.tooltipPosition.x,
|
|
31
|
+
y: entry.tooltipPosition.y
|
|
25
32
|
}
|
|
26
33
|
}));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
};
|
|
35
|
+
const onMouseLeaveFromContext = (entry, index) => (e) => {
|
|
36
|
+
dispatch(mouseLeaveItem());
|
|
37
|
+
};
|
|
38
|
+
const onClickFromContext = (entry, index) => (e) => {
|
|
39
|
+
dispatch(setActiveClickItemIndex({
|
|
40
|
+
activeDataKey: dataKey,
|
|
41
|
+
activeIndex: String(index),
|
|
33
42
|
activeCoordinate: {
|
|
34
|
-
x:
|
|
35
|
-
y:
|
|
43
|
+
x: entry.tooltipPosition.x,
|
|
44
|
+
y: entry.tooltipPosition.y
|
|
36
45
|
}
|
|
37
46
|
}));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
};
|
|
48
|
+
const baseProps = filterProps(props, false);
|
|
49
|
+
const interpolateNumber = (from, to) => (t) => from + (to - from) * t;
|
|
50
|
+
const renderRectangles = (data) => {
|
|
51
|
+
if (!data) return null;
|
|
52
|
+
return createVNode(Fragment, null, [data.map((entry, i) => {
|
|
53
|
+
let _slot;
|
|
54
|
+
const activeEnabled = activeBar !== false || activeIndexProp != null || !!activeBarSlot;
|
|
55
|
+
const isActive = activeIndexProp != null ? activeEnabled && i === activeIndexProp : activeEnabled && String(i) === activeIndex.value && (activeDataKey.value == null || dataKey === activeDataKey.value);
|
|
56
|
+
const activeBarProps = isActive && typeof activeBar === "object" ? activeBar : {};
|
|
57
|
+
const entryFill = entry.payload?.fill;
|
|
58
|
+
const cellPropsForIndex = cellProps.value?.[i];
|
|
59
|
+
const barRectangleProps = {
|
|
60
|
+
...baseProps,
|
|
61
|
+
...entryFill ? { fill: entryFill } : {},
|
|
62
|
+
...entry,
|
|
63
|
+
...cellPropsForIndex ?? {},
|
|
64
|
+
...isActive ? activeBarProps : {},
|
|
65
|
+
isActive,
|
|
66
|
+
index: i,
|
|
67
|
+
dataKey
|
|
68
|
+
};
|
|
69
|
+
const renderShape = () => {
|
|
70
|
+
if (isActive && activeBarSlot) return activeBarSlot(barRectangleProps);
|
|
71
|
+
if (shapeSlot) return shapeSlot(barRectangleProps);
|
|
72
|
+
return createVNode(Rectangle, barRectangleProps, null);
|
|
73
|
+
};
|
|
74
|
+
return createVNode(Layer, {
|
|
75
|
+
"key": `rectangle-${entry?.x}-${entry?.y}-${entry?.value}-${i}`,
|
|
76
|
+
"class": "v-charts-bar-rectangle",
|
|
77
|
+
"onMouseenter": onMouseEnterFromContext(entry, i),
|
|
78
|
+
"onMouseleave": onMouseLeaveFromContext(entry, i),
|
|
79
|
+
"onClick": onClickFromContext(entry, i)
|
|
80
|
+
}, _isSlot(_slot = renderShape()) ? _slot : { default: () => [_slot] });
|
|
81
|
+
})]);
|
|
82
|
+
};
|
|
57
83
|
return () => {
|
|
58
|
-
|
|
59
|
-
if (!
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
84
|
+
const data = barData.value;
|
|
85
|
+
if (!data) return null;
|
|
86
|
+
if (isAnimationActive && previousRectangles !== data) {
|
|
87
|
+
const prevData = previousRectangles;
|
|
88
|
+
animationId++;
|
|
89
|
+
isAnimating.value = true;
|
|
90
|
+
return createVNode(Animate, {
|
|
91
|
+
"key": animationId,
|
|
92
|
+
"transition": props.transition,
|
|
93
|
+
"isActive": isAnimationActive,
|
|
94
|
+
"onAnimationStart": onAnimationStart,
|
|
95
|
+
"onAnimationEnd": () => {
|
|
96
|
+
isAnimating.value = false;
|
|
97
|
+
onAnimationEnd?.();
|
|
69
98
|
}
|
|
70
|
-
}, { default: (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
|
|
99
|
+
}, { default: (t) => {
|
|
100
|
+
const stepData = t === 1 ? data : data.map((entry, index) => {
|
|
101
|
+
const prev = prevData?.[index];
|
|
102
|
+
if (prev && prev.stackedBarStart === entry.stackedBarStart) {
|
|
103
|
+
const interpolatorX = interpolateNumber(prev.x || 0, entry.x || 0);
|
|
104
|
+
const interpolatorY = interpolateNumber(prev.y || 0, entry.y || 0);
|
|
105
|
+
const interpolatorWidth = interpolateNumber(prev.width, entry.width);
|
|
106
|
+
const interpolatorHeight = interpolateNumber(prev.height, entry.height);
|
|
75
107
|
return {
|
|
76
|
-
...
|
|
77
|
-
x: t
|
|
78
|
-
y:
|
|
79
|
-
width:
|
|
80
|
-
height:
|
|
108
|
+
...entry,
|
|
109
|
+
x: interpolatorX(t),
|
|
110
|
+
y: interpolatorY(t),
|
|
111
|
+
width: interpolatorWidth(t),
|
|
112
|
+
height: interpolatorHeight(t)
|
|
81
113
|
};
|
|
82
114
|
}
|
|
83
|
-
if (
|
|
84
|
-
|
|
115
|
+
if (layout.value === "horizontal") {
|
|
116
|
+
const h = interpolateNumber(0, entry.height)(t);
|
|
117
|
+
const y = interpolateNumber(entry.stackedBarStart, entry.y)(t);
|
|
85
118
|
return {
|
|
86
|
-
...
|
|
87
|
-
y
|
|
88
|
-
height:
|
|
119
|
+
...entry,
|
|
120
|
+
y,
|
|
121
|
+
height: h
|
|
89
122
|
};
|
|
90
123
|
}
|
|
91
|
-
|
|
124
|
+
const w = interpolateNumber(0, entry.width)(t);
|
|
125
|
+
const x = interpolateNumber(entry.stackedBarStart, entry.x)(t);
|
|
92
126
|
return {
|
|
93
|
-
...
|
|
94
|
-
width:
|
|
95
|
-
x
|
|
127
|
+
...entry,
|
|
128
|
+
width: w,
|
|
129
|
+
x
|
|
96
130
|
};
|
|
97
131
|
});
|
|
98
|
-
|
|
132
|
+
if (t > 0) previousRectangles = stepData;
|
|
133
|
+
return createVNode("g", null, [renderRectangles(stepData)]);
|
|
99
134
|
} });
|
|
100
135
|
}
|
|
101
|
-
|
|
136
|
+
isAnimating.value = false;
|
|
137
|
+
previousRectangles = data;
|
|
138
|
+
return createVNode("g", null, [renderRectangles(data)]);
|
|
102
139
|
};
|
|
103
140
|
}
|
|
104
141
|
});
|
|
105
142
|
//#endregion
|
|
106
|
-
export {
|
|
143
|
+
export { BarRectangles };
|
|
@@ -1,41 +1,53 @@
|
|
|
1
|
-
import { uniqueId
|
|
2
|
-
import { useIsPanorama
|
|
3
|
-
import { getNormalizedStackId
|
|
4
|
-
import { useAppSelector
|
|
5
|
-
import { useChartLayout
|
|
6
|
-
import { useNeedsClip
|
|
7
|
-
import { selectBarRectangles
|
|
8
|
-
import { computed
|
|
9
|
-
import { createContext
|
|
1
|
+
import { uniqueId } from "../../../utils/data-utils.mjs";
|
|
2
|
+
import { useIsPanorama } from "../../../context/PanoramaContextProvider.mjs";
|
|
3
|
+
import { getNormalizedStackId } from "../../../utils/chart.mjs";
|
|
4
|
+
import { useAppSelector } from "../../../state/hooks.mjs";
|
|
5
|
+
import { useChartLayout } from "../../../context/chartLayoutContext.mjs";
|
|
6
|
+
import { useNeedsClip } from "../../useNeedsClip.mjs";
|
|
7
|
+
import { selectBarRectangles } from "../../../state/selectors/barSelectors.mjs";
|
|
8
|
+
import { computed, ref, shallowRef, useAttrs } from "vue";
|
|
9
|
+
import { createContext } from "motion-v";
|
|
10
10
|
//#region src/cartesian/bar/hooks/useBar.ts
|
|
11
|
-
var [
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
11
|
+
var [useBarContext, provideBarContext] = createContext("BarContext");
|
|
12
|
+
function useBar(props, shapeSlot, activeBarSlot) {
|
|
13
|
+
const isPanorama = useIsPanorama();
|
|
14
|
+
const attrs = useAttrs();
|
|
15
|
+
const layout = useChartLayout();
|
|
16
|
+
const { needClip } = useNeedsClip(props.xAxisId, props.yAxisId);
|
|
17
|
+
const barSettings = computed(() => ({
|
|
18
|
+
barSize: props.barSize,
|
|
19
|
+
data: props.data,
|
|
20
|
+
dataKey: props.dataKey,
|
|
21
|
+
maxBarSize: props.maxBarSize,
|
|
22
|
+
minPointSize: props.minPointSize,
|
|
23
|
+
stackId: getNormalizedStackId(props.stackId)
|
|
24
|
+
}));
|
|
25
|
+
const rects = useAppSelector((state) => selectBarRectangles(state, props.xAxisId, props.yAxisId, isPanorama, barSettings.value));
|
|
26
|
+
const shouldRender = computed(() => {
|
|
27
|
+
return (layout.value === "vertical" || layout.value === "horizontal") && !props.hide;
|
|
28
|
+
});
|
|
29
|
+
const clipPathId = uniqueId("v-charts-bar-");
|
|
30
|
+
const isAnimating = ref(false);
|
|
31
|
+
const cellPropsRef = shallowRef([]);
|
|
32
|
+
provideBarContext({
|
|
33
|
+
clipPathId,
|
|
34
|
+
layout,
|
|
35
|
+
props,
|
|
36
|
+
attrs,
|
|
37
|
+
data: rects,
|
|
38
|
+
isAnimating,
|
|
39
|
+
shapeSlot,
|
|
40
|
+
activeBarSlot,
|
|
41
|
+
cellProps: cellPropsRef
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
shouldRender,
|
|
45
|
+
needClip,
|
|
46
|
+
clipPathId,
|
|
47
|
+
barData: rects,
|
|
48
|
+
isAnimating,
|
|
49
|
+
cellProps: cellPropsRef
|
|
38
50
|
};
|
|
39
51
|
}
|
|
40
52
|
//#endregion
|
|
41
|
-
export {
|
|
53
|
+
export { useBar, useBarContext };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/cartesian/bar/type.ts
|
|
2
|
-
var
|
|
2
|
+
var BarVueProps = {
|
|
3
3
|
class: {
|
|
4
4
|
type: String,
|
|
5
5
|
default: void 0
|
|
@@ -15,7 +15,7 @@ var e = {
|
|
|
15
15
|
Number,
|
|
16
16
|
Function
|
|
17
17
|
],
|
|
18
|
-
required:
|
|
18
|
+
required: true
|
|
19
19
|
},
|
|
20
20
|
fill: {
|
|
21
21
|
type: String,
|
|
@@ -49,11 +49,11 @@ var e = {
|
|
|
49
49
|
maxBarSize: { type: Number },
|
|
50
50
|
hide: {
|
|
51
51
|
type: Boolean,
|
|
52
|
-
default:
|
|
52
|
+
default: false
|
|
53
53
|
},
|
|
54
54
|
background: {
|
|
55
55
|
type: [Boolean, Object],
|
|
56
|
-
default:
|
|
56
|
+
default: false
|
|
57
57
|
},
|
|
58
58
|
radius: {
|
|
59
59
|
type: [Number, Array],
|
|
@@ -69,7 +69,7 @@ var e = {
|
|
|
69
69
|
},
|
|
70
70
|
isAnimationActive: {
|
|
71
71
|
type: Boolean,
|
|
72
|
-
default:
|
|
72
|
+
default: true
|
|
73
73
|
},
|
|
74
74
|
activeBar: {
|
|
75
75
|
type: [
|
|
@@ -77,7 +77,7 @@ var e = {
|
|
|
77
77
|
Boolean,
|
|
78
78
|
Function
|
|
79
79
|
],
|
|
80
|
-
default:
|
|
80
|
+
default: false
|
|
81
81
|
},
|
|
82
82
|
activeIndex: {
|
|
83
83
|
type: Number,
|
|
@@ -120,12 +120,12 @@ var e = {
|
|
|
120
120
|
},
|
|
121
121
|
needClip: {
|
|
122
122
|
type: Boolean,
|
|
123
|
-
default:
|
|
123
|
+
default: false
|
|
124
124
|
},
|
|
125
125
|
label: {
|
|
126
126
|
type: [Boolean, Object],
|
|
127
|
-
default:
|
|
127
|
+
default: false
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
//#endregion
|
|
131
|
-
export {
|
|
131
|
+
export { BarVueProps };
|