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,36 +1,40 @@
|
|
|
1
|
-
import { isNullish
|
|
2
|
-
import { useViewBox
|
|
3
|
-
import { LabelVueProps
|
|
4
|
-
import { usePolarLabelViewBox
|
|
5
|
-
import { getAttrsOfCartesianLabel
|
|
6
|
-
import
|
|
7
|
-
import { createVNode
|
|
1
|
+
import { isNullish } from "../../utils/validate.mjs";
|
|
2
|
+
import { useViewBox } from "../../context/chartLayoutContext.mjs";
|
|
3
|
+
import { LabelVueProps } from "./types.mjs";
|
|
4
|
+
import { usePolarLabelViewBox } from "../../context/polarLabelViewBoxContext.mjs";
|
|
5
|
+
import { getAttrsOfCartesianLabel, getAttrsOfPolarLabel, isPolar, renderRadialLabel } from "./utils.mjs";
|
|
6
|
+
import Text_default from "../Text.mjs";
|
|
7
|
+
import { createVNode, defineComponent, mergeProps } from "vue";
|
|
8
8
|
//#region src/components/label/Label.tsx
|
|
9
|
-
var
|
|
9
|
+
var Label = /* @__PURE__ */ defineComponent({
|
|
10
10
|
name: "Label",
|
|
11
|
-
props:
|
|
11
|
+
props: LabelVueProps,
|
|
12
12
|
slots: Object,
|
|
13
|
-
setup(
|
|
14
|
-
|
|
13
|
+
setup(props, { slots, attrs }) {
|
|
14
|
+
const viewBoxFromContext = useViewBox();
|
|
15
|
+
const polarLabelViewBox = usePolarLabelViewBox();
|
|
15
16
|
return () => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const { viewBox: viewBoxFromProps, value, position, textBreakAll, formatter } = props;
|
|
18
|
+
const viewBox = viewBoxFromProps || polarLabelViewBox.value || viewBoxFromContext.value;
|
|
19
|
+
if (!viewBox || isNullish(value) && !slots.content) return null;
|
|
20
|
+
const isPolarLabel = isPolar(viewBox);
|
|
21
|
+
if (slots.content) return slots.content({
|
|
22
|
+
...props,
|
|
23
|
+
viewBox
|
|
22
24
|
});
|
|
23
|
-
let
|
|
24
|
-
if (typeof
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
let label = value;
|
|
26
|
+
if (typeof formatter === "function") label = formatter(label);
|
|
27
|
+
if (isPolarLabel && (position === "insideStart" || position === "insideEnd" || position === "end")) return renderRadialLabel(props, position, label, attrs, viewBox);
|
|
28
|
+
const positionAttrs = isPolarLabel ? getAttrsOfPolarLabel(props, viewBox) : getAttrsOfCartesianLabel(props, viewBox);
|
|
29
|
+
const textAnchor = attrs.textAnchor != null && (attrs.textAnchor === "start" || attrs.textAnchor === "middle" || attrs.textAnchor === "end") ? attrs.textAnchor : positionAttrs.textAnchor;
|
|
30
|
+
return createVNode(Text_default, mergeProps({ "class": ["v-charts-label", props.class] }, attrs, positionAttrs, {
|
|
31
|
+
"textAnchor": textAnchor,
|
|
32
|
+
"angle": props.angle,
|
|
33
|
+
"breakAll": textBreakAll,
|
|
34
|
+
"value": label
|
|
31
35
|
}), null);
|
|
32
36
|
};
|
|
33
37
|
}
|
|
34
38
|
});
|
|
35
39
|
//#endregion
|
|
36
|
-
export {
|
|
40
|
+
export { Label };
|
|
@@ -1,49 +1,55 @@
|
|
|
1
|
-
import { isNullish
|
|
2
|
-
import { getValueByDataKey
|
|
3
|
-
import { Layer
|
|
4
|
-
import { LabelListVueProps
|
|
5
|
-
import { parseViewBox
|
|
6
|
-
import { Label
|
|
7
|
-
import { useLabelLayerRef
|
|
8
|
-
import { useCartesianLabelListData
|
|
9
|
-
import { Teleport
|
|
1
|
+
import { isNullish } from "../../utils/validate.mjs";
|
|
2
|
+
import { getValueByDataKey } from "../../utils/chart.mjs";
|
|
3
|
+
import { Layer } from "../../container/Layer.mjs";
|
|
4
|
+
import { LabelListVueProps } from "./types.mjs";
|
|
5
|
+
import { parseViewBox } from "./utils.mjs";
|
|
6
|
+
import { Label } from "./Label.mjs";
|
|
7
|
+
import { useLabelLayerRef } from "../../context/labelLayerContext.mjs";
|
|
8
|
+
import { useCartesianLabelListData } from "../../context/cartesianLabelListContext.mjs";
|
|
9
|
+
import { Teleport, createVNode, defineComponent, isVNode, mergeProps } from "vue";
|
|
10
10
|
//#region src/components/label/LabelList.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
|
|
15
|
-
props:
|
|
16
|
-
setup(
|
|
17
|
-
|
|
14
|
+
var LabelList = /* @__PURE__ */ defineComponent({
|
|
15
|
+
props: LabelListVueProps,
|
|
16
|
+
setup(props, { attrs, slots }) {
|
|
17
|
+
const labelLayerRef = useLabelLayerRef(null);
|
|
18
|
+
const contextData = useCartesianLabelListData(null);
|
|
18
19
|
return () => {
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
let _slot;
|
|
21
|
+
const { dataKey, valueAccessor, clockWise, id, ...others } = props;
|
|
22
|
+
const data = props.data ?? contextData?.value;
|
|
23
|
+
if (!data || !data.length) return null;
|
|
24
|
+
const content = createVNode(Layer, { "class": "v-charts-label-list" }, _isSlot(_slot = data.map((entry, index) => {
|
|
25
|
+
const value = isNullish(dataKey) ? valueAccessor(entry, index) : getValueByDataKey(entry && entry.payload, dataKey);
|
|
26
|
+
const idProps = isNullish(id) ? void 0 : `${id}-${index}`;
|
|
27
|
+
const viewBox = parseViewBox(isNullish(clockWise) ? entry : {
|
|
28
|
+
...entry,
|
|
29
|
+
clockWise
|
|
25
30
|
});
|
|
26
|
-
if (
|
|
27
|
-
...
|
|
28
|
-
...
|
|
29
|
-
...
|
|
30
|
-
value
|
|
31
|
-
index
|
|
32
|
-
key: `label-${
|
|
31
|
+
if (slots.label) return slots.label({
|
|
32
|
+
...others,
|
|
33
|
+
...attrs,
|
|
34
|
+
...viewBox,
|
|
35
|
+
value,
|
|
36
|
+
index,
|
|
37
|
+
key: `label-${index}`
|
|
33
38
|
});
|
|
34
|
-
|
|
35
|
-
return
|
|
36
|
-
id:
|
|
37
|
-
parentViewBox:
|
|
38
|
-
value:
|
|
39
|
-
viewBox:
|
|
40
|
-
key: `label-${
|
|
41
|
-
index:
|
|
39
|
+
const entryFill = entry.fill != null && !("fill" in others) && !("fill" in attrs) ? entry.fill : void 0;
|
|
40
|
+
return createVNode(Label, mergeProps(others, attrs, entryFill != null ? { fill: entryFill } : {}, {
|
|
41
|
+
"id": idProps,
|
|
42
|
+
"parentViewBox": entry.parentViewBox,
|
|
43
|
+
"value": value,
|
|
44
|
+
"viewBox": viewBox,
|
|
45
|
+
"key": `label-${index}`,
|
|
46
|
+
"index": index
|
|
42
47
|
}), null);
|
|
43
|
-
})) ?
|
|
44
|
-
|
|
48
|
+
})) ? _slot : { default: () => [_slot] });
|
|
49
|
+
if (labelLayerRef?.value) return createVNode(Teleport, { "to": labelLayerRef.value }, _isSlot(content) ? content : { default: () => [content] });
|
|
50
|
+
return content;
|
|
45
51
|
};
|
|
46
52
|
}
|
|
47
53
|
});
|
|
48
54
|
//#endregion
|
|
49
|
-
export {
|
|
55
|
+
export { LabelList };
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { classProp } from "../../types/common.mjs";
|
|
2
|
+
import { last } from "es-toolkit/compat";
|
|
3
|
+
//#region src/components/label/types.ts
|
|
4
|
+
var defaultAccessor = (entry) => Array.isArray(entry.value) ? last(entry.value) : entry.value;
|
|
5
|
+
var LabelListVueProps = {
|
|
3
6
|
id: { type: String },
|
|
4
7
|
data: { type: Array },
|
|
5
8
|
valueAccessor: {
|
|
6
9
|
type: Function,
|
|
7
|
-
default:
|
|
10
|
+
default: defaultAccessor
|
|
8
11
|
},
|
|
9
12
|
clockWise: { type: Boolean },
|
|
10
13
|
dataKey: { type: [String, Function] },
|
|
@@ -12,10 +15,11 @@ var t = {
|
|
|
12
15
|
position: { type: String },
|
|
13
16
|
offset: { type: Number },
|
|
14
17
|
angle: { type: Number }
|
|
15
|
-
}
|
|
18
|
+
};
|
|
19
|
+
var LabelVueProps = {
|
|
16
20
|
id: { type: String },
|
|
17
21
|
class: {
|
|
18
|
-
|
|
22
|
+
...classProp,
|
|
19
23
|
default: ""
|
|
20
24
|
},
|
|
21
25
|
viewBox: { type: Object },
|
|
@@ -32,4 +36,4 @@ var t = {
|
|
|
32
36
|
index: { type: Number }
|
|
33
37
|
};
|
|
34
38
|
//#endregion
|
|
35
|
-
export {
|
|
39
|
+
export { LabelListVueProps, LabelVueProps };
|
|
@@ -1,233 +1,265 @@
|
|
|
1
|
-
import { isNumber
|
|
2
|
-
import { uniqueId
|
|
3
|
-
import { getPercentValue
|
|
4
|
-
import { createVNode
|
|
1
|
+
import { isNumber, isPercent } from "../../utils/validate.mjs";
|
|
2
|
+
import { uniqueId } from "../../utils/data-utils.mjs";
|
|
3
|
+
import { getPercentValue, mathSign } from "../../utils/data.mjs";
|
|
4
|
+
import { createVNode, mergeProps } from "vue";
|
|
5
5
|
//#region src/components/label/utils.tsx
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
if (
|
|
10
|
-
if (
|
|
11
|
-
x
|
|
12
|
-
y
|
|
13
|
-
width
|
|
14
|
-
height
|
|
6
|
+
function parseViewBox(props) {
|
|
7
|
+
const { cx, cy, angle, startAngle, endAngle, r, radius, innerRadius, outerRadius, x, y, top, left, width, height, clockWise, labelViewBox } = props;
|
|
8
|
+
if (labelViewBox) return labelViewBox;
|
|
9
|
+
if (isNumber(width) && isNumber(height)) {
|
|
10
|
+
if (isNumber(x) && isNumber(y)) return {
|
|
11
|
+
x,
|
|
12
|
+
y,
|
|
13
|
+
width,
|
|
14
|
+
height
|
|
15
15
|
};
|
|
16
|
-
if (
|
|
17
|
-
x:
|
|
18
|
-
y:
|
|
19
|
-
width
|
|
20
|
-
height
|
|
16
|
+
if (isNumber(top) && isNumber(left)) return {
|
|
17
|
+
x: top,
|
|
18
|
+
y: left,
|
|
19
|
+
width,
|
|
20
|
+
height
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
if (
|
|
24
|
-
x
|
|
25
|
-
y
|
|
23
|
+
if (isNumber(x) && isNumber(y)) return {
|
|
24
|
+
x,
|
|
25
|
+
y,
|
|
26
26
|
width: 0,
|
|
27
27
|
height: 0
|
|
28
28
|
};
|
|
29
|
-
if (
|
|
30
|
-
cx
|
|
31
|
-
cy
|
|
32
|
-
startAngle:
|
|
33
|
-
endAngle:
|
|
34
|
-
innerRadius:
|
|
35
|
-
outerRadius:
|
|
36
|
-
clockWise
|
|
29
|
+
if (isNumber(cx) && isNumber(cy)) return {
|
|
30
|
+
cx,
|
|
31
|
+
cy,
|
|
32
|
+
startAngle: startAngle || angle || 0,
|
|
33
|
+
endAngle: endAngle || angle || 0,
|
|
34
|
+
innerRadius: innerRadius || 0,
|
|
35
|
+
outerRadius: outerRadius || radius || r || 0,
|
|
36
|
+
clockWise
|
|
37
37
|
};
|
|
38
|
-
if (
|
|
38
|
+
if (props.viewBox) return props.viewBox;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
return "cx" in
|
|
40
|
+
function isPolar(viewBox) {
|
|
41
|
+
return "cx" in viewBox && isNumber(viewBox.cx);
|
|
42
42
|
}
|
|
43
|
-
var
|
|
44
|
-
function
|
|
43
|
+
var RADIAN = Math.PI / 180;
|
|
44
|
+
function polarToCartesian(cx, cy, radius, angle) {
|
|
45
45
|
return {
|
|
46
|
-
x:
|
|
47
|
-
y:
|
|
46
|
+
x: cx + Math.cos(-RADIAN * angle) * radius,
|
|
47
|
+
y: cy + Math.sin(-RADIAN * angle) * radius
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
return
|
|
50
|
+
function getDeltaAngle(startAngle, endAngle) {
|
|
51
|
+
return mathSign(endAngle - startAngle) * Math.min(Math.abs(endAngle - startAngle), 360);
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
function renderRadialLabel(labelProps, position, label, attrs, viewBox) {
|
|
54
|
+
const { offset = 5, class: className, id: labelId } = labelProps;
|
|
55
|
+
const { cx, cy, innerRadius, outerRadius, startAngle, endAngle, clockWise } = viewBox;
|
|
56
|
+
const radius = (innerRadius + outerRadius) / 2;
|
|
57
|
+
const deltaAngle = getDeltaAngle(startAngle, endAngle);
|
|
58
|
+
const sign = deltaAngle >= 0 ? 1 : -1;
|
|
59
|
+
let labelAngle;
|
|
60
|
+
let direction;
|
|
61
|
+
switch (position) {
|
|
56
62
|
case "insideStart":
|
|
57
|
-
|
|
63
|
+
labelAngle = startAngle + sign * offset;
|
|
64
|
+
direction = clockWise;
|
|
58
65
|
break;
|
|
59
66
|
case "insideEnd":
|
|
60
|
-
|
|
67
|
+
labelAngle = endAngle - sign * offset;
|
|
68
|
+
direction = !clockWise;
|
|
61
69
|
break;
|
|
62
70
|
case "end":
|
|
63
|
-
|
|
71
|
+
labelAngle = endAngle + sign * offset;
|
|
72
|
+
direction = clockWise;
|
|
64
73
|
break;
|
|
65
|
-
default: throw Error(`Unsupported position ${
|
|
74
|
+
default: throw new Error(`Unsupported position ${position}`);
|
|
66
75
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
76
|
+
direction = deltaAngle <= 0 ? direction : !direction;
|
|
77
|
+
const startPoint = polarToCartesian(cx, cy, radius, labelAngle);
|
|
78
|
+
const endPoint = polarToCartesian(cx, cy, radius, labelAngle + (direction ? 1 : -1) * 359);
|
|
79
|
+
const path = `M${startPoint.x},${startPoint.y} A${radius},${radius},0,1,${direction ? 0 : 1},${endPoint.x},${endPoint.y}`;
|
|
80
|
+
const id = labelId == null ? uniqueId("v-charts-radial-line-") : labelId;
|
|
81
|
+
return createVNode("text", mergeProps(attrs, {
|
|
70
82
|
"dominant-baseline": "central",
|
|
71
|
-
class: ["v-charts-radial-bar-label",
|
|
72
|
-
}), [
|
|
73
|
-
id:
|
|
74
|
-
d:
|
|
75
|
-
}, null)]),
|
|
83
|
+
"class": ["v-charts-radial-bar-label", className]
|
|
84
|
+
}), [createVNode("defs", null, [createVNode("path", {
|
|
85
|
+
"id": id,
|
|
86
|
+
"d": path
|
|
87
|
+
}, null)]), createVNode("textPath", { "xlink:href": `#${id}` }, [label])]);
|
|
76
88
|
}
|
|
77
|
-
function
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
89
|
+
function getAttrsOfPolarLabel(props, viewBox) {
|
|
90
|
+
const { offset, position } = props;
|
|
91
|
+
const { cx, cy, innerRadius, outerRadius, startAngle, endAngle } = viewBox ?? props.viewBox;
|
|
92
|
+
const midAngle = (startAngle + endAngle) / 2;
|
|
93
|
+
if (position === "outside") {
|
|
94
|
+
const { x, y } = polarToCartesian(cx, cy, outerRadius + offset, midAngle);
|
|
81
95
|
return {
|
|
82
|
-
x
|
|
83
|
-
y
|
|
84
|
-
textAnchor:
|
|
96
|
+
x,
|
|
97
|
+
y,
|
|
98
|
+
textAnchor: x >= cx ? "start" : "end",
|
|
85
99
|
verticalAnchor: "middle"
|
|
86
100
|
};
|
|
87
101
|
}
|
|
88
|
-
if (
|
|
89
|
-
x:
|
|
90
|
-
y:
|
|
102
|
+
if (position === "center") return {
|
|
103
|
+
x: cx,
|
|
104
|
+
y: cy,
|
|
91
105
|
textAnchor: "middle",
|
|
92
106
|
verticalAnchor: "middle"
|
|
93
107
|
};
|
|
94
|
-
if (
|
|
95
|
-
x:
|
|
96
|
-
y:
|
|
108
|
+
if (position === "centerTop") return {
|
|
109
|
+
x: cx,
|
|
110
|
+
y: cy,
|
|
97
111
|
textAnchor: "middle",
|
|
98
112
|
verticalAnchor: "start"
|
|
99
113
|
};
|
|
100
|
-
if (
|
|
101
|
-
x:
|
|
102
|
-
y:
|
|
114
|
+
if (position === "centerBottom") return {
|
|
115
|
+
x: cx,
|
|
116
|
+
y: cy,
|
|
103
117
|
textAnchor: "middle",
|
|
104
118
|
verticalAnchor: "end"
|
|
105
119
|
};
|
|
106
|
-
|
|
120
|
+
const { x, y } = polarToCartesian(cx, cy, (innerRadius + outerRadius) / 2, midAngle);
|
|
107
121
|
return {
|
|
108
|
-
x
|
|
109
|
-
y
|
|
122
|
+
x,
|
|
123
|
+
y,
|
|
110
124
|
textAnchor: "middle",
|
|
111
125
|
verticalAnchor: "middle"
|
|
112
126
|
};
|
|
113
127
|
}
|
|
114
|
-
function
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
128
|
+
function getAttrsOfCartesianLabel(props, viewBox) {
|
|
129
|
+
const { parentViewBox, offset, position } = props;
|
|
130
|
+
const { x, y, width, height } = viewBox;
|
|
131
|
+
const verticalSign = height >= 0 ? 1 : -1;
|
|
132
|
+
const verticalOffset = verticalSign * offset;
|
|
133
|
+
const verticalEnd = verticalSign > 0 ? "end" : "start";
|
|
134
|
+
const verticalStart = verticalSign > 0 ? "start" : "end";
|
|
135
|
+
const horizontalSign = width >= 0 ? 1 : -1;
|
|
136
|
+
const horizontalOffset = horizontalSign * offset;
|
|
137
|
+
const horizontalEnd = horizontalSign > 0 ? "end" : "start";
|
|
138
|
+
const horizontalStart = horizontalSign > 0 ? "start" : "end";
|
|
139
|
+
if (position === "top") return {
|
|
140
|
+
x: x + width / 2,
|
|
141
|
+
y: y - verticalSign * offset,
|
|
119
142
|
textAnchor: "middle",
|
|
120
|
-
verticalAnchor:
|
|
121
|
-
...
|
|
122
|
-
height: Math.max(
|
|
123
|
-
width
|
|
143
|
+
verticalAnchor: verticalEnd,
|
|
144
|
+
...parentViewBox ? {
|
|
145
|
+
height: Math.max(y - parentViewBox.y, 0),
|
|
146
|
+
width
|
|
124
147
|
} : {}
|
|
125
148
|
};
|
|
126
|
-
if (
|
|
127
|
-
x:
|
|
128
|
-
y:
|
|
149
|
+
if (position === "bottom") return {
|
|
150
|
+
x: x + width / 2,
|
|
151
|
+
y: y + height + verticalOffset,
|
|
129
152
|
textAnchor: "middle",
|
|
130
|
-
verticalAnchor:
|
|
131
|
-
...
|
|
132
|
-
height: Math.max(
|
|
133
|
-
width
|
|
153
|
+
verticalAnchor: verticalStart,
|
|
154
|
+
...parentViewBox ? {
|
|
155
|
+
height: Math.max(parentViewBox.y + parentViewBox.height - (y + height), 0),
|
|
156
|
+
width
|
|
134
157
|
} : {}
|
|
135
158
|
};
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
x:
|
|
139
|
-
y:
|
|
140
|
-
textAnchor:
|
|
159
|
+
if (position === "left") {
|
|
160
|
+
const attrs = {
|
|
161
|
+
x: x - horizontalOffset,
|
|
162
|
+
y: y + height / 2,
|
|
163
|
+
textAnchor: horizontalEnd,
|
|
141
164
|
verticalAnchor: "middle"
|
|
142
165
|
};
|
|
143
166
|
return {
|
|
144
|
-
...
|
|
145
|
-
...
|
|
146
|
-
width: Math.max(
|
|
147
|
-
height
|
|
167
|
+
...attrs,
|
|
168
|
+
...parentViewBox ? {
|
|
169
|
+
width: Math.max(attrs.x - parentViewBox.x, 0),
|
|
170
|
+
height
|
|
148
171
|
} : {}
|
|
149
172
|
};
|
|
150
173
|
}
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
x:
|
|
154
|
-
y:
|
|
155
|
-
textAnchor:
|
|
174
|
+
if (position === "right") {
|
|
175
|
+
const attrs = {
|
|
176
|
+
x: x + width + horizontalOffset,
|
|
177
|
+
y: y + height / 2,
|
|
178
|
+
textAnchor: horizontalStart,
|
|
156
179
|
verticalAnchor: "middle"
|
|
157
180
|
};
|
|
158
181
|
return {
|
|
159
|
-
...
|
|
160
|
-
...
|
|
161
|
-
width: Math.max(
|
|
162
|
-
height
|
|
182
|
+
...attrs,
|
|
183
|
+
...parentViewBox ? {
|
|
184
|
+
width: Math.max(parentViewBox.x + parentViewBox.width - attrs.x, 0),
|
|
185
|
+
height
|
|
163
186
|
} : {}
|
|
164
187
|
};
|
|
165
188
|
}
|
|
166
|
-
|
|
167
|
-
width
|
|
168
|
-
height
|
|
189
|
+
const sizeAttrs = parentViewBox ? {
|
|
190
|
+
width,
|
|
191
|
+
height
|
|
169
192
|
} : {};
|
|
170
|
-
|
|
171
|
-
x:
|
|
172
|
-
y:
|
|
173
|
-
textAnchor:
|
|
193
|
+
if (position === "insideLeft") return {
|
|
194
|
+
x: x + horizontalOffset,
|
|
195
|
+
y: y + height / 2,
|
|
196
|
+
textAnchor: horizontalStart,
|
|
174
197
|
verticalAnchor: "middle",
|
|
175
|
-
...
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
198
|
+
...sizeAttrs
|
|
199
|
+
};
|
|
200
|
+
if (position === "insideRight") return {
|
|
201
|
+
x: x + width - horizontalOffset,
|
|
202
|
+
y: y + height / 2,
|
|
203
|
+
textAnchor: horizontalEnd,
|
|
180
204
|
verticalAnchor: "middle",
|
|
181
|
-
...
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
205
|
+
...sizeAttrs
|
|
206
|
+
};
|
|
207
|
+
if (position === "insideTop") return {
|
|
208
|
+
x: x + width / 2,
|
|
209
|
+
y: y + verticalOffset,
|
|
185
210
|
textAnchor: "middle",
|
|
186
|
-
verticalAnchor:
|
|
187
|
-
...
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
211
|
+
verticalAnchor: verticalStart,
|
|
212
|
+
...sizeAttrs
|
|
213
|
+
};
|
|
214
|
+
if (position === "insideBottom") return {
|
|
215
|
+
x: x + width / 2,
|
|
216
|
+
y: y + height - verticalOffset,
|
|
191
217
|
textAnchor: "middle",
|
|
192
|
-
verticalAnchor:
|
|
193
|
-
...
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
verticalAnchor: verticalEnd,
|
|
219
|
+
...sizeAttrs
|
|
220
|
+
};
|
|
221
|
+
if (position === "insideTopLeft") return {
|
|
222
|
+
x: x + horizontalOffset,
|
|
223
|
+
y: y + verticalOffset,
|
|
224
|
+
textAnchor: horizontalStart,
|
|
225
|
+
verticalAnchor: verticalStart,
|
|
226
|
+
...sizeAttrs
|
|
227
|
+
};
|
|
228
|
+
if (position === "insideTopRight") return {
|
|
229
|
+
x: x + width - horizontalOffset,
|
|
230
|
+
y: y + verticalOffset,
|
|
231
|
+
textAnchor: horizontalEnd,
|
|
232
|
+
verticalAnchor: verticalStart,
|
|
233
|
+
...sizeAttrs
|
|
234
|
+
};
|
|
235
|
+
if (position === "insideBottomLeft") return {
|
|
236
|
+
x: x + horizontalOffset,
|
|
237
|
+
y: y + height - verticalOffset,
|
|
238
|
+
textAnchor: horizontalStart,
|
|
239
|
+
verticalAnchor: verticalEnd,
|
|
240
|
+
...sizeAttrs
|
|
241
|
+
};
|
|
242
|
+
if (position === "insideBottomRight") return {
|
|
243
|
+
x: x + width - horizontalOffset,
|
|
244
|
+
y: y + height - verticalOffset,
|
|
245
|
+
textAnchor: horizontalEnd,
|
|
246
|
+
verticalAnchor: verticalEnd,
|
|
247
|
+
...sizeAttrs
|
|
248
|
+
};
|
|
249
|
+
if (!!position && typeof position === "object" && (isNumber(position.x) || isPercent(position.x)) && (isNumber(position.y) || isPercent(position.y))) return {
|
|
250
|
+
x: x + getPercentValue(position.x, width),
|
|
251
|
+
y: y + getPercentValue(position.y, height),
|
|
221
252
|
textAnchor: "end",
|
|
222
253
|
verticalAnchor: "end",
|
|
223
|
-
...
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
254
|
+
...sizeAttrs
|
|
255
|
+
};
|
|
256
|
+
return {
|
|
257
|
+
x: x + width / 2,
|
|
258
|
+
y: y + height / 2,
|
|
227
259
|
textAnchor: "middle",
|
|
228
260
|
verticalAnchor: "middle",
|
|
229
|
-
...
|
|
261
|
+
...sizeAttrs
|
|
230
262
|
};
|
|
231
263
|
}
|
|
232
264
|
//#endregion
|
|
233
|
-
export {
|
|
265
|
+
export { getAttrsOfCartesianLabel, getAttrsOfPolarLabel, isPolar, parseViewBox, renderRadialLabel };
|