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,17 +1,18 @@
|
|
|
1
|
-
import { polarToCartesian
|
|
2
|
-
import { selectPolarViewBox
|
|
3
|
-
import { useAppSelector
|
|
4
|
-
import { selectPolarGridAngles
|
|
5
|
-
import { computed
|
|
1
|
+
import { polarToCartesian } from "../../utils/polar.mjs";
|
|
2
|
+
import { selectPolarViewBox } from "../../state/selectors/polarAxisSelectors.mjs";
|
|
3
|
+
import { useAppSelector } from "../../state/hooks.mjs";
|
|
4
|
+
import { selectPolarGridAngles, selectPolarGridRadii } from "../../state/selectors/polarGridSelectors.mjs";
|
|
5
|
+
import { computed, createVNode, defineComponent } from "vue";
|
|
6
6
|
//#region src/polar/radar/PolarGrid.tsx
|
|
7
|
-
function
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})
|
|
7
|
+
function getPolygonPath(radius, cx, cy, polarAngles) {
|
|
8
|
+
let path = "";
|
|
9
|
+
polarAngles.forEach((angle, i) => {
|
|
10
|
+
const point = polarToCartesian(cx, cy, radius, angle);
|
|
11
|
+
path += i === 0 ? `M ${point.x},${point.y}` : `L ${point.x},${point.y}`;
|
|
12
|
+
});
|
|
13
|
+
return `${path}Z`;
|
|
13
14
|
}
|
|
14
|
-
var
|
|
15
|
+
var PolarGrid = /* @__PURE__ */ defineComponent({
|
|
15
16
|
name: "PolarGrid",
|
|
16
17
|
props: {
|
|
17
18
|
angleAxisId: {
|
|
@@ -28,7 +29,7 @@ var l = /* @__PURE__ */ s({
|
|
|
28
29
|
},
|
|
29
30
|
radialLines: {
|
|
30
31
|
type: Boolean,
|
|
31
|
-
default:
|
|
32
|
+
default: true
|
|
32
33
|
},
|
|
33
34
|
stroke: {
|
|
34
35
|
type: String,
|
|
@@ -47,56 +48,68 @@ var l = /* @__PURE__ */ s({
|
|
|
47
48
|
default: void 0
|
|
48
49
|
}
|
|
49
50
|
},
|
|
50
|
-
inheritAttrs:
|
|
51
|
-
setup(
|
|
52
|
-
|
|
51
|
+
inheritAttrs: false,
|
|
52
|
+
setup(props, { attrs }) {
|
|
53
|
+
const polarViewBox = useAppSelector((state) => selectPolarViewBox(state));
|
|
54
|
+
const polarAngles = useAppSelector((state) => selectPolarGridAngles(state, props.angleAxisId));
|
|
55
|
+
const polarRadiiFromRedux = useAppSelector((state) => selectPolarGridRadii(state, props.radiusAxisId));
|
|
56
|
+
const polarRadii = computed(() => {
|
|
57
|
+
if (Array.isArray(props.polarRadius)) return props.polarRadius;
|
|
58
|
+
return polarRadiiFromRedux.value;
|
|
59
|
+
});
|
|
53
60
|
return () => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
stroke:
|
|
85
|
-
|
|
86
|
-
"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
61
|
+
const viewBox = polarViewBox.value;
|
|
62
|
+
const angles = polarAngles.value;
|
|
63
|
+
const radii = polarRadii.value;
|
|
64
|
+
if (viewBox == null || angles == null || radii == null || viewBox.outerRadius <= 0) return null;
|
|
65
|
+
const { cx, cy, innerRadius } = viewBox;
|
|
66
|
+
const { stroke, gridType, fill, strokeWidth } = props;
|
|
67
|
+
const shapeClass = attrs.class;
|
|
68
|
+
const renderBackground = fill && fill !== "none";
|
|
69
|
+
return createVNode("g", { "class": "v-charts-polar-grid" }, [createVNode("g", { "class": "v-charts-polar-grid-concentric" }, [renderBackground && (gridType === "circle" ? createVNode("circle", {
|
|
70
|
+
"class": ["v-charts-polar-grid-concentric-circle", shapeClass],
|
|
71
|
+
"cx": cx,
|
|
72
|
+
"cy": cy,
|
|
73
|
+
"r": Math.max(...radii),
|
|
74
|
+
"stroke": stroke,
|
|
75
|
+
"fill": fill,
|
|
76
|
+
"stroke-width": strokeWidth
|
|
77
|
+
}, null) : createVNode("path", {
|
|
78
|
+
"class": ["v-charts-polar-grid-concentric-polygon", shapeClass],
|
|
79
|
+
"d": getPolygonPath(Math.max(...radii), cx, cy, angles),
|
|
80
|
+
"stroke": stroke,
|
|
81
|
+
"fill": fill,
|
|
82
|
+
"stroke-width": strokeWidth
|
|
83
|
+
}, null)), radii.map((radius, i) => gridType === "circle" ? createVNode("circle", {
|
|
84
|
+
"key": `circle-${i}`,
|
|
85
|
+
"class": ["v-charts-polar-grid-concentric-circle", shapeClass],
|
|
86
|
+
"cx": cx,
|
|
87
|
+
"cy": cy,
|
|
88
|
+
"r": radius,
|
|
89
|
+
"stroke": stroke,
|
|
90
|
+
"fill": "none",
|
|
91
|
+
"stroke-width": strokeWidth
|
|
92
|
+
}, null) : createVNode("path", {
|
|
93
|
+
"key": `polygon-${i}`,
|
|
94
|
+
"class": ["v-charts-polar-grid-concentric-polygon", shapeClass],
|
|
95
|
+
"d": getPolygonPath(radius, cx, cy, angles),
|
|
96
|
+
"stroke": stroke,
|
|
97
|
+
"fill": "none",
|
|
98
|
+
"stroke-width": strokeWidth
|
|
99
|
+
}, null))]), props.radialLines && angles.length > 0 && createVNode("g", { "class": "v-charts-polar-grid-angle" }, [angles.map((angle) => {
|
|
100
|
+
const start = polarToCartesian(cx, cy, innerRadius, angle);
|
|
101
|
+
const end = polarToCartesian(cx, cy, viewBox.outerRadius, angle);
|
|
102
|
+
return createVNode("line", {
|
|
103
|
+
"key": `line-${angle}`,
|
|
104
|
+
"x1": start.x,
|
|
105
|
+
"y1": start.y,
|
|
106
|
+
"x2": end.x,
|
|
107
|
+
"y2": end.y,
|
|
108
|
+
"stroke": stroke
|
|
96
109
|
}, null);
|
|
97
110
|
})])]);
|
|
98
111
|
};
|
|
99
112
|
}
|
|
100
113
|
});
|
|
101
114
|
//#endregion
|
|
102
|
-
export {
|
|
115
|
+
export { PolarGrid };
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import { isCategoricalAxis
|
|
2
|
-
import { polarToCartesian
|
|
3
|
-
import { selectPolarViewBox
|
|
4
|
-
import { useAppDispatch
|
|
5
|
-
import { useChartLayout
|
|
6
|
-
import { POLAR_LABEL_VIEW_BOX_KEY
|
|
7
|
-
import
|
|
8
|
-
import { addRadiusAxis
|
|
9
|
-
import { selectPolarAxisTicks
|
|
10
|
-
import { computed
|
|
1
|
+
import { isCategoricalAxis } from "../../utils/validate.mjs";
|
|
2
|
+
import { polarToCartesian } from "../../utils/polar.mjs";
|
|
3
|
+
import { selectPolarViewBox } from "../../state/selectors/polarAxisSelectors.mjs";
|
|
4
|
+
import { useAppDispatch, useAppSelector } from "../../state/hooks.mjs";
|
|
5
|
+
import { useChartLayout } from "../../context/chartLayoutContext.mjs";
|
|
6
|
+
import { POLAR_LABEL_VIEW_BOX_KEY } from "../../context/polarLabelViewBoxContext.mjs";
|
|
7
|
+
import Text_default from "../../components/Text.mjs";
|
|
8
|
+
import { addRadiusAxis, removeRadiusAxis } from "../../state/polarAxisSlice.mjs";
|
|
9
|
+
import { selectPolarAxisTicks } from "../../state/selectors/polarScaleSelectors.mjs";
|
|
10
|
+
import { computed, createVNode, defineComponent, onUnmounted, provide, watchEffect } from "vue";
|
|
11
11
|
//#region src/polar/radar/PolarRadiusAxis.tsx
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Resolve 'auto' type based on chart layout, matching Recharts behavior.
|
|
14
|
+
* In a radial layout, radiusAxis is categorical; in centric, it's numerical.
|
|
15
|
+
*/
|
|
16
|
+
function resolveAxisType(type, layout, axisType) {
|
|
17
|
+
if (type !== "auto") return type;
|
|
18
|
+
return isCategoricalAxis(layout, axisType) ? "category" : "number";
|
|
14
19
|
}
|
|
15
|
-
var
|
|
20
|
+
var PolarRadiusAxis = /* @__PURE__ */ defineComponent({
|
|
16
21
|
name: "PolarRadiusAxis",
|
|
17
22
|
props: {
|
|
18
23
|
radiusAxisId: {
|
|
@@ -33,11 +38,11 @@ var v = /* @__PURE__ */ p({
|
|
|
33
38
|
},
|
|
34
39
|
tick: {
|
|
35
40
|
type: Boolean,
|
|
36
|
-
default:
|
|
41
|
+
default: true
|
|
37
42
|
},
|
|
38
43
|
axisLine: {
|
|
39
44
|
type: Boolean,
|
|
40
|
-
default:
|
|
45
|
+
default: true
|
|
41
46
|
},
|
|
42
47
|
orientation: {
|
|
43
48
|
type: String,
|
|
@@ -69,69 +74,89 @@ var v = /* @__PURE__ */ p({
|
|
|
69
74
|
},
|
|
70
75
|
allowDecimals: {
|
|
71
76
|
type: Boolean,
|
|
72
|
-
default:
|
|
77
|
+
default: false
|
|
73
78
|
}
|
|
74
79
|
},
|
|
75
|
-
setup(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
setup(props, { slots }) {
|
|
81
|
+
const dispatch = useAppDispatch();
|
|
82
|
+
const layout = useChartLayout();
|
|
83
|
+
let prevSettings = null;
|
|
84
|
+
watchEffect(() => {
|
|
85
|
+
const resolvedType = resolveAxisType(props.type, layout.value, "radiusAxis");
|
|
86
|
+
const settings = {
|
|
87
|
+
id: props.radiusAxisId,
|
|
88
|
+
type: resolvedType,
|
|
89
|
+
dataKey: props.dataKey,
|
|
82
90
|
scale: "auto",
|
|
83
|
-
allowDuplicatedCategory:
|
|
84
|
-
allowDataOverflow:
|
|
85
|
-
reversed:
|
|
86
|
-
includeHidden:
|
|
87
|
-
domain:
|
|
91
|
+
allowDuplicatedCategory: true,
|
|
92
|
+
allowDataOverflow: props.domain != null,
|
|
93
|
+
reversed: false,
|
|
94
|
+
includeHidden: false,
|
|
95
|
+
domain: props.domain ?? [0, "auto"],
|
|
88
96
|
unit: void 0,
|
|
89
97
|
name: void 0,
|
|
90
|
-
allowDecimals:
|
|
91
|
-
tickCount:
|
|
92
|
-
ticks:
|
|
93
|
-
tick:
|
|
98
|
+
allowDecimals: props.allowDecimals,
|
|
99
|
+
tickCount: props.tickCount,
|
|
100
|
+
ticks: props.ticks,
|
|
101
|
+
tick: props.tick
|
|
94
102
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
b &&= (v(l(b)), null);
|
|
103
|
+
dispatch(addRadiusAxis(settings));
|
|
104
|
+
prevSettings = settings;
|
|
98
105
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
106
|
+
onUnmounted(() => {
|
|
107
|
+
if (prevSettings) {
|
|
108
|
+
dispatch(removeRadiusAxis(prevSettings));
|
|
109
|
+
prevSettings = null;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
const polarViewBox = useAppSelector((state) => selectPolarViewBox(state));
|
|
113
|
+
const ticks = useAppSelector((state) => selectPolarAxisTicks(state, "radiusAxis", props.radiusAxisId, false));
|
|
114
|
+
provide(POLAR_LABEL_VIEW_BOX_KEY, computed(() => polarViewBox.value));
|
|
115
|
+
return () => {
|
|
116
|
+
const viewBox = polarViewBox.value;
|
|
117
|
+
const tickItems = ticks.value;
|
|
118
|
+
const hasChildren = !!slots.default;
|
|
119
|
+
const showTicks = props.tick && tickItems != null && tickItems.length > 0;
|
|
120
|
+
if (viewBox == null || !showTicks && !props.axisLine && !hasChildren) return null;
|
|
121
|
+
const { cx, cy } = viewBox;
|
|
122
|
+
const { angle, orientation, axisLine, tickFormatter, stroke } = props;
|
|
123
|
+
const textAnchor = orientation === "left" ? "end" : orientation === "right" ? "start" : "middle";
|
|
124
|
+
return createVNode("g", { "class": "v-charts-polar-radius-axis" }, [
|
|
125
|
+
axisLine && showTicks && (() => {
|
|
126
|
+
const coords = tickItems.map((t) => t.coordinate);
|
|
127
|
+
const minR = Math.min(...coords);
|
|
128
|
+
const maxR = Math.max(...coords);
|
|
129
|
+
const p0 = polarToCartesian(cx, cy, minR, angle);
|
|
130
|
+
const p1 = polarToCartesian(cx, cy, maxR, angle);
|
|
131
|
+
return createVNode("line", {
|
|
132
|
+
"class": "v-charts-polar-radius-axis-line",
|
|
133
|
+
"x1": p0.x,
|
|
134
|
+
"y1": p0.y,
|
|
135
|
+
"x2": p1.x,
|
|
136
|
+
"y2": p1.y,
|
|
137
|
+
"stroke": stroke,
|
|
138
|
+
"fill": "none"
|
|
115
139
|
}, null);
|
|
116
140
|
})(),
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
141
|
+
showTicks && createVNode("g", { "class": "v-charts-polar-radius-axis-ticks" }, [tickItems.map((entry, i) => {
|
|
142
|
+
const coord = polarToCartesian(cx, cy, entry.coordinate, angle);
|
|
143
|
+
const value = tickFormatter ? tickFormatter(entry.value, i) : entry.value;
|
|
144
|
+
return createVNode(Text_default, {
|
|
145
|
+
"key": `tick-${entry.coordinate}`,
|
|
146
|
+
"class": "v-charts-polar-radius-axis-tick-value",
|
|
147
|
+
"x": coord.x,
|
|
148
|
+
"y": coord.y,
|
|
149
|
+
"textAnchor": textAnchor,
|
|
150
|
+
"verticalAnchor": "middle",
|
|
151
|
+
"fill": stroke,
|
|
152
|
+
"angle": 90 - angle,
|
|
153
|
+
"value": String(value)
|
|
129
154
|
}, null);
|
|
130
155
|
})]),
|
|
131
|
-
|
|
156
|
+
slots.default?.()
|
|
132
157
|
]);
|
|
133
158
|
};
|
|
134
159
|
}
|
|
135
160
|
});
|
|
136
161
|
//#endregion
|
|
137
|
-
export {
|
|
162
|
+
export { PolarRadiusAxis };
|