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,145 +1,161 @@
|
|
|
1
|
-
import { selectChartOffset
|
|
2
|
-
import { polarToCartesian
|
|
3
|
-
import { mouseLeaveItem
|
|
4
|
-
import { useAppDispatch
|
|
5
|
-
import { Layer
|
|
6
|
-
import { Animate
|
|
7
|
-
import { SetPolarGraphicalItem
|
|
8
|
-
import { SetLegendPayload
|
|
9
|
-
import { SetTooltipEntrySettings
|
|
10
|
-
import { Sector
|
|
11
|
-
import { computePieSectors
|
|
12
|
-
import { PieVueProps
|
|
13
|
-
import { computed
|
|
1
|
+
import { selectChartOffset } from "../../state/selectors/selectChartOffset.mjs";
|
|
2
|
+
import { polarToCartesian } from "../../utils/polar.mjs";
|
|
3
|
+
import { mouseLeaveItem, setActiveMouseOverItemIndex } from "../../state/tooltipSlice.mjs";
|
|
4
|
+
import { useAppDispatch, useAppSelector } from "../../state/hooks.mjs";
|
|
5
|
+
import { Layer } from "../../container/Layer.mjs";
|
|
6
|
+
import { Animate } from "../../animation/Animate.mjs";
|
|
7
|
+
import { SetPolarGraphicalItem } from "../../state/SetGraphicalItem.mjs";
|
|
8
|
+
import { SetLegendPayload } from "../../state/SetLegendPayload.mjs";
|
|
9
|
+
import { SetTooltipEntrySettings } from "../../state/SetTooltipEntrySettings.mjs";
|
|
10
|
+
import { Sector } from "../../shape/Sector.mjs";
|
|
11
|
+
import { computePieSectors, selectDisplayedData, selectPieLegend, selectSynchronisedPieSettings } from "../../state/selectors/pieSelectors.mjs";
|
|
12
|
+
import { PieVueProps } from "./type.mjs";
|
|
13
|
+
import { computed, createVNode, defineComponent, mergeProps, ref, watch } from "vue";
|
|
14
14
|
//#region src/polar/pie/Pie.tsx
|
|
15
|
-
var
|
|
15
|
+
var LABEL_OFFSET = 20;
|
|
16
|
+
var Pie = /* @__PURE__ */ defineComponent({
|
|
16
17
|
name: "Pie",
|
|
17
|
-
props:
|
|
18
|
-
inheritAttrs:
|
|
18
|
+
props: PieVueProps,
|
|
19
|
+
inheritAttrs: false,
|
|
19
20
|
slots: Object,
|
|
20
|
-
setup(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
setup(props, { attrs, slots }) {
|
|
22
|
+
const dispatch = useAppDispatch();
|
|
23
|
+
const isControlled = computed(() => props.activeIndex !== -1);
|
|
24
|
+
const activeIndex = ref(props.activeIndex);
|
|
25
|
+
watch(() => props.activeIndex, (val) => {
|
|
26
|
+
activeIndex.value = val;
|
|
24
27
|
});
|
|
25
|
-
|
|
26
|
-
data:
|
|
27
|
-
dataKey:
|
|
28
|
-
nameKey:
|
|
29
|
-
cx:
|
|
30
|
-
cy:
|
|
31
|
-
innerRadius:
|
|
32
|
-
outerRadius:
|
|
33
|
-
startAngle:
|
|
34
|
-
endAngle:
|
|
35
|
-
paddingAngle:
|
|
36
|
-
minAngle:
|
|
37
|
-
fill:
|
|
38
|
-
legendType:
|
|
39
|
-
tooltipType:
|
|
28
|
+
const pieSettings = computed(() => ({
|
|
29
|
+
data: props.data,
|
|
30
|
+
dataKey: props.dataKey,
|
|
31
|
+
nameKey: props.nameKey,
|
|
32
|
+
cx: props.cx,
|
|
33
|
+
cy: props.cy,
|
|
34
|
+
innerRadius: props.innerRadius,
|
|
35
|
+
outerRadius: props.outerRadius,
|
|
36
|
+
startAngle: props.startAngle,
|
|
37
|
+
endAngle: props.endAngle,
|
|
38
|
+
paddingAngle: props.paddingAngle,
|
|
39
|
+
minAngle: props.minAngle,
|
|
40
|
+
fill: props.fill,
|
|
41
|
+
legendType: props.legendType,
|
|
42
|
+
tooltipType: props.tooltipType,
|
|
40
43
|
presentationProps: {}
|
|
41
44
|
}));
|
|
42
|
-
|
|
45
|
+
SetPolarGraphicalItem(computed(() => ({
|
|
43
46
|
type: "pie",
|
|
44
|
-
data:
|
|
45
|
-
dataKey:
|
|
46
|
-
hide:
|
|
47
|
+
data: props.data ?? [],
|
|
48
|
+
dataKey: props.dataKey,
|
|
49
|
+
hide: props.hide,
|
|
47
50
|
angleAxisId: 0,
|
|
48
51
|
radiusAxisId: 0
|
|
49
52
|
})));
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
const displayedData = useAppSelector((state) => selectDisplayedData(state, pieSettings.value));
|
|
54
|
+
const synchronisedSettings = useAppSelector((state) => selectSynchronisedPieSettings(state, pieSettings.value));
|
|
55
|
+
const offset = useAppSelector((state) => selectChartOffset(state));
|
|
56
|
+
const legendPayload = useAppSelector((state) => selectPieLegend(state, pieSettings.value));
|
|
57
|
+
SetLegendPayload(computed(() => legendPayload.value ?? []));
|
|
58
|
+
const sectors = computed(() => {
|
|
59
|
+
if (synchronisedSettings.value == null || displayedData.value == null) return;
|
|
60
|
+
return computePieSectors({
|
|
61
|
+
offset: offset.value,
|
|
62
|
+
pieSettings: pieSettings.value,
|
|
63
|
+
displayedData: displayedData.value
|
|
57
64
|
});
|
|
58
65
|
});
|
|
59
|
-
|
|
60
|
-
fn: (
|
|
61
|
-
args:
|
|
62
|
-
dataDefinedOnItem:
|
|
63
|
-
positions:
|
|
66
|
+
SetTooltipEntrySettings({
|
|
67
|
+
fn: (v) => v,
|
|
68
|
+
args: computed(() => ({
|
|
69
|
+
dataDefinedOnItem: displayedData.value ?? [],
|
|
70
|
+
positions: sectors.value?.map((s) => s.tooltipPosition),
|
|
64
71
|
settings: {
|
|
65
|
-
dataKey:
|
|
66
|
-
nameKey:
|
|
67
|
-
name: String(
|
|
68
|
-
hide:
|
|
69
|
-
type:
|
|
70
|
-
color:
|
|
71
|
-
fill:
|
|
72
|
-
stroke:
|
|
72
|
+
dataKey: props.dataKey,
|
|
73
|
+
nameKey: props.nameKey,
|
|
74
|
+
name: String(props.dataKey ?? ""),
|
|
75
|
+
hide: props.hide,
|
|
76
|
+
type: props.tooltipType,
|
|
77
|
+
color: props.fill,
|
|
78
|
+
fill: props.fill,
|
|
79
|
+
stroke: props.stroke,
|
|
73
80
|
unit: ""
|
|
74
81
|
}
|
|
75
82
|
}))
|
|
76
83
|
});
|
|
77
|
-
function
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
function handleSectorEnter(sector, index) {
|
|
85
|
+
if (!isControlled.value) activeIndex.value = index;
|
|
86
|
+
dispatch(setActiveMouseOverItemIndex({
|
|
87
|
+
activeIndex: String(index),
|
|
88
|
+
activeDataKey: props.dataKey,
|
|
89
|
+
activeCoordinate: sector.tooltipPosition
|
|
82
90
|
}));
|
|
83
91
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
92
|
+
function handleSectorLeave() {
|
|
93
|
+
if (!isControlled.value) activeIndex.value = -1;
|
|
94
|
+
dispatch(mouseLeaveItem());
|
|
86
95
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
"
|
|
96
|
+
function renderLabel(sector, index) {
|
|
97
|
+
const edgePoint = polarToCartesian(sector.cx, sector.cy, sector.outerRadius, sector.midAngle);
|
|
98
|
+
const pos = polarToCartesian(sector.cx, sector.cy, sector.outerRadius + LABEL_OFFSET, sector.midAngle);
|
|
99
|
+
const anchor = pos.x > sector.cx ? "start" : pos.x < sector.cx ? "end" : "middle";
|
|
100
|
+
return createVNode("g", { "key": `label-${index}` }, [createVNode("line", {
|
|
101
|
+
"x1": edgePoint.x,
|
|
102
|
+
"y1": edgePoint.y,
|
|
103
|
+
"x2": pos.x,
|
|
104
|
+
"y2": pos.y,
|
|
105
|
+
"stroke": sector.fill,
|
|
106
|
+
"fill": "none"
|
|
107
|
+
}, null), createVNode("text", {
|
|
108
|
+
"x": pos.x,
|
|
109
|
+
"y": pos.y,
|
|
110
|
+
"text-anchor": anchor,
|
|
100
111
|
"dominant-baseline": "middle",
|
|
101
|
-
fill:
|
|
102
|
-
}, [String(
|
|
112
|
+
"fill": sector.fill
|
|
113
|
+
}, [String(sector.value)])]);
|
|
103
114
|
}
|
|
104
115
|
return () => {
|
|
105
|
-
|
|
106
|
-
if (!
|
|
107
|
-
|
|
108
|
-
return
|
|
109
|
-
isActive:
|
|
110
|
-
from: 0,
|
|
111
|
-
to: 1,
|
|
112
|
-
transition: { duration: 1.5 }
|
|
113
|
-
}, { default: (
|
|
114
|
-
let
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
116
|
+
const sectorList = sectors.value;
|
|
117
|
+
if (!sectorList || sectorList.length === 0) return null;
|
|
118
|
+
const stroke = attrs.stroke ?? props.stroke;
|
|
119
|
+
return createVNode(Layer, { "class": ["v-charts-pie", props.class] }, { default: () => [createVNode(Animate, {
|
|
120
|
+
"isActive": props.isAnimationActive,
|
|
121
|
+
"from": 0,
|
|
122
|
+
"to": 1,
|
|
123
|
+
"transition": { duration: 1.5 }
|
|
124
|
+
}, { default: (progress) => {
|
|
125
|
+
let curAngle = sectorList[0]?.startAngle ?? 0;
|
|
126
|
+
const sectorNodes = sectorList.map((sector, i) => {
|
|
127
|
+
const paddingAngle = i > 0 ? sector.paddingAngle : 0;
|
|
128
|
+
const deltaAngle = (sector.endAngle - sector.startAngle) * progress;
|
|
129
|
+
const animatedStartAngle = curAngle + paddingAngle;
|
|
130
|
+
const animatedEndAngle = curAngle + deltaAngle + paddingAngle;
|
|
131
|
+
curAngle = animatedEndAngle;
|
|
132
|
+
const content = slots.shape ? slots.shape({
|
|
133
|
+
...sector,
|
|
134
|
+
startAngle: animatedStartAngle,
|
|
135
|
+
endAngle: animatedEndAngle,
|
|
136
|
+
stroke,
|
|
137
|
+
isActive: activeIndex.value === i
|
|
138
|
+
}) : createVNode(Sector, mergeProps(attrs, {
|
|
139
|
+
"cx": sector.cx,
|
|
140
|
+
"cy": sector.cy,
|
|
141
|
+
"innerRadius": sector.innerRadius,
|
|
142
|
+
"outerRadius": sector.outerRadius,
|
|
143
|
+
"startAngle": animatedStartAngle,
|
|
144
|
+
"endAngle": animatedEndAngle,
|
|
145
|
+
"fill": sector.fill,
|
|
146
|
+
"stroke": stroke
|
|
132
147
|
}), null);
|
|
133
|
-
return
|
|
134
|
-
key: `sector-${i}`,
|
|
135
|
-
onMouseenter: () =>
|
|
136
|
-
onMouseleave:
|
|
137
|
-
}, [
|
|
148
|
+
return createVNode("g", {
|
|
149
|
+
"key": `sector-${i}`,
|
|
150
|
+
"onMouseenter": () => handleSectorEnter(sector, i),
|
|
151
|
+
"onMouseleave": handleSectorLeave
|
|
152
|
+
}, [content]);
|
|
138
153
|
});
|
|
139
|
-
|
|
154
|
+
if (progress >= 1 && props.label) sectorNodes.push(...sectorList.map(renderLabel));
|
|
155
|
+
return sectorNodes;
|
|
140
156
|
} })] });
|
|
141
157
|
};
|
|
142
158
|
}
|
|
143
159
|
});
|
|
144
160
|
//#endregion
|
|
145
|
-
export {
|
|
161
|
+
export { Pie };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { classProp } from "../../types/common.mjs";
|
|
1
2
|
//#region src/polar/pie/type.ts
|
|
2
|
-
var
|
|
3
|
+
var PieVueProps = {
|
|
3
4
|
data: {
|
|
4
5
|
type: Array,
|
|
5
6
|
default: void 0
|
|
@@ -10,7 +11,7 @@ var e = {
|
|
|
10
11
|
Number,
|
|
11
12
|
Function
|
|
12
13
|
],
|
|
13
|
-
required:
|
|
14
|
+
required: true
|
|
14
15
|
},
|
|
15
16
|
nameKey: {
|
|
16
17
|
type: [
|
|
@@ -74,7 +75,7 @@ var e = {
|
|
|
74
75
|
},
|
|
75
76
|
hide: {
|
|
76
77
|
type: Boolean,
|
|
77
|
-
default:
|
|
78
|
+
default: false
|
|
78
79
|
},
|
|
79
80
|
activeIndex: {
|
|
80
81
|
type: Number,
|
|
@@ -82,16 +83,13 @@ var e = {
|
|
|
82
83
|
},
|
|
83
84
|
isAnimationActive: {
|
|
84
85
|
type: Boolean,
|
|
85
|
-
default:
|
|
86
|
+
default: true
|
|
86
87
|
},
|
|
87
88
|
label: {
|
|
88
89
|
type: Boolean,
|
|
89
|
-
default:
|
|
90
|
+
default: false
|
|
90
91
|
},
|
|
91
|
-
|
|
92
|
-
type: String,
|
|
93
|
-
default: void 0
|
|
94
|
-
}
|
|
92
|
+
class: classProp
|
|
95
93
|
};
|
|
96
94
|
//#endregion
|
|
97
|
-
export {
|
|
95
|
+
export { PieVueProps };
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import { RADIAN
|
|
2
|
-
import { selectPolarViewBox
|
|
3
|
-
import { useAppDispatch
|
|
4
|
-
import
|
|
5
|
-
import { addAngleAxis
|
|
6
|
-
import { selectPolarAxisTicks
|
|
7
|
-
import { createVNode
|
|
1
|
+
import { RADIAN, polarToCartesian } from "../../utils/polar.mjs";
|
|
2
|
+
import { selectPolarViewBox } from "../../state/selectors/polarAxisSelectors.mjs";
|
|
3
|
+
import { useAppDispatch, useAppSelector } from "../../state/hooks.mjs";
|
|
4
|
+
import Text_default from "../../components/Text.mjs";
|
|
5
|
+
import { addAngleAxis, removeAngleAxis } from "../../state/polarAxisSlice.mjs";
|
|
6
|
+
import { selectPolarAxisTicks } from "../../state/selectors/polarScaleSelectors.mjs";
|
|
7
|
+
import { createVNode, defineComponent, onUnmounted, watchEffect } from "vue";
|
|
8
8
|
//#region src/polar/radar/PolarAngleAxis.tsx
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
var eps = 1e-5;
|
|
10
|
+
var COS_45 = Math.cos(45 * RADIAN);
|
|
11
|
+
function getTickTextAnchor(coordinate, orientation) {
|
|
12
|
+
const cos = Math.cos(-coordinate * RADIAN);
|
|
13
|
+
if (cos > eps) return orientation === "outer" ? "start" : "end";
|
|
14
|
+
if (cos < -eps) return orientation === "outer" ? "end" : "start";
|
|
15
|
+
return "middle";
|
|
13
16
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
function getTickVerticalAnchor(coordinate) {
|
|
18
|
+
const cos = Math.cos(-coordinate * RADIAN);
|
|
19
|
+
const sin = Math.sin(-coordinate * RADIAN);
|
|
20
|
+
if (Math.abs(cos) <= COS_45) return sin > 0 ? "start" : "end";
|
|
21
|
+
return "middle";
|
|
17
22
|
}
|
|
18
|
-
var
|
|
23
|
+
var PolarAngleAxis = /* @__PURE__ */ defineComponent({
|
|
19
24
|
name: "PolarAngleAxis",
|
|
20
25
|
props: {
|
|
21
26
|
angleAxisId: {
|
|
@@ -32,11 +37,11 @@ var _ = /* @__PURE__ */ u({
|
|
|
32
37
|
},
|
|
33
38
|
tick: {
|
|
34
39
|
type: Boolean,
|
|
35
|
-
default:
|
|
40
|
+
default: true
|
|
36
41
|
},
|
|
37
42
|
tickLine: {
|
|
38
43
|
type: Boolean,
|
|
39
|
-
default:
|
|
44
|
+
default: true
|
|
40
45
|
},
|
|
41
46
|
tickSize: {
|
|
42
47
|
type: Number,
|
|
@@ -44,7 +49,7 @@ var _ = /* @__PURE__ */ u({
|
|
|
44
49
|
},
|
|
45
50
|
axisLine: {
|
|
46
51
|
type: Boolean,
|
|
47
|
-
default:
|
|
52
|
+
default: true
|
|
48
53
|
},
|
|
49
54
|
axisLineType: {
|
|
50
55
|
type: String,
|
|
@@ -80,82 +85,96 @@ var _ = /* @__PURE__ */ u({
|
|
|
80
85
|
}
|
|
81
86
|
},
|
|
82
87
|
slots: Object,
|
|
83
|
-
setup(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
setup(props, { slots }) {
|
|
89
|
+
const dispatch = useAppDispatch();
|
|
90
|
+
let prevSettings = null;
|
|
91
|
+
watchEffect(() => {
|
|
92
|
+
const settings = {
|
|
93
|
+
id: props.angleAxisId,
|
|
94
|
+
type: props.type,
|
|
95
|
+
dataKey: props.dataKey,
|
|
90
96
|
scale: "auto",
|
|
91
|
-
allowDuplicatedCategory:
|
|
92
|
-
allowDataOverflow:
|
|
93
|
-
reversed:
|
|
94
|
-
includeHidden:
|
|
95
|
-
domain:
|
|
97
|
+
allowDuplicatedCategory: true,
|
|
98
|
+
allowDataOverflow: false,
|
|
99
|
+
reversed: false,
|
|
100
|
+
includeHidden: false,
|
|
101
|
+
domain: props.domain,
|
|
96
102
|
unit: void 0,
|
|
97
103
|
name: void 0,
|
|
98
|
-
allowDecimals:
|
|
99
|
-
tickCount:
|
|
100
|
-
ticks:
|
|
101
|
-
tick:
|
|
104
|
+
allowDecimals: false,
|
|
105
|
+
tickCount: props.tickCount,
|
|
106
|
+
ticks: props.ticks,
|
|
107
|
+
tick: props.tick
|
|
102
108
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
m &&= (p(s(m)), null);
|
|
109
|
+
dispatch(addAngleAxis(settings));
|
|
110
|
+
prevSettings = settings;
|
|
106
111
|
});
|
|
107
|
-
|
|
112
|
+
onUnmounted(() => {
|
|
113
|
+
if (prevSettings) {
|
|
114
|
+
dispatch(removeAngleAxis(prevSettings));
|
|
115
|
+
prevSettings = null;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const polarViewBox = useAppSelector((state) => selectPolarViewBox(state));
|
|
119
|
+
const ticks = useAppSelector((state) => selectPolarAxisTicks(state, "angleAxis", props.angleAxisId, false));
|
|
108
120
|
return () => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
const viewBox = polarViewBox.value;
|
|
122
|
+
const tickItems = ticks.value;
|
|
123
|
+
if (viewBox == null || tickItems == null || tickItems.length === 0) return null;
|
|
124
|
+
const { cx, cy, outerRadius: radius, startAngle: vbStart, endAngle: vbEnd } = viewBox;
|
|
125
|
+
const { orientation, tickSize, axisLine, axisLineType, tickLine, tick, tickFormatter, stroke } = props;
|
|
126
|
+
const filteredTicks = Math.abs((vbEnd ?? 0) - (vbStart ?? 0)) === 360 && tickItems.length > 1 && Math.abs(tickItems[tickItems.length - 1].coordinate - tickItems[0].coordinate) % 360 === 0 ? tickItems.slice(0, -1) : tickItems;
|
|
127
|
+
return createVNode("g", { "class": "v-charts-polar-angle-axis" }, [axisLine && (axisLineType === "circle" ? createVNode("circle", {
|
|
128
|
+
"cx": cx,
|
|
129
|
+
"cy": cy,
|
|
130
|
+
"r": radius,
|
|
131
|
+
"fill": "none",
|
|
132
|
+
"stroke": stroke
|
|
133
|
+
}, null) : createVNode("polygon", {
|
|
134
|
+
"points": filteredTicks.map((t) => {
|
|
135
|
+
const p = polarToCartesian(cx, cy, radius, t.coordinate);
|
|
136
|
+
return `${p.x},${p.y}`;
|
|
122
137
|
}).join(" "),
|
|
123
|
-
fill: "none",
|
|
124
|
-
stroke:
|
|
125
|
-
}, null)),
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
138
|
+
"fill": "none",
|
|
139
|
+
"stroke": stroke
|
|
140
|
+
}, null)), createVNode("g", { "class": "v-charts-polar-angle-axis-ticks" }, [filteredTicks.map((entry, i) => {
|
|
141
|
+
const p1 = polarToCartesian(cx, cy, radius, entry.coordinate);
|
|
142
|
+
const p2 = polarToCartesian(cx, cy, radius + (orientation === "inner" ? -1 : 1) * tickSize, entry.coordinate);
|
|
143
|
+
const textAnchor = getTickTextAnchor(entry.coordinate, orientation);
|
|
144
|
+
const verticalAnchor = getTickVerticalAnchor(entry.coordinate);
|
|
145
|
+
const value = tickFormatter ? tickFormatter(entry.value, i) : entry.value;
|
|
146
|
+
return createVNode("g", {
|
|
147
|
+
"key": `tick-${entry.coordinate}`,
|
|
148
|
+
"class": "v-charts-polar-angle-axis-tick"
|
|
149
|
+
}, [tickLine && createVNode("line", {
|
|
150
|
+
"class": "v-charts-polar-angle-axis-tick-line",
|
|
151
|
+
"x1": p1.x,
|
|
152
|
+
"y1": p1.y,
|
|
153
|
+
"x2": p2.x,
|
|
154
|
+
"y2": p2.y,
|
|
155
|
+
"stroke": stroke,
|
|
156
|
+
"fill": "none"
|
|
157
|
+
}, null), tick && (slots.tick ? slots.tick({
|
|
158
|
+
x: p2.x,
|
|
159
|
+
y: p2.y,
|
|
160
|
+
value,
|
|
161
|
+
index: i,
|
|
162
|
+
textAnchor,
|
|
163
|
+
payload: entry,
|
|
164
|
+
cx,
|
|
165
|
+
cy
|
|
166
|
+
}) : createVNode(Text_default, {
|
|
167
|
+
"class": "v-charts-polar-angle-axis-tick-value",
|
|
168
|
+
"x": p2.x,
|
|
169
|
+
"y": p2.y,
|
|
170
|
+
"textAnchor": textAnchor,
|
|
171
|
+
"verticalAnchor": verticalAnchor,
|
|
172
|
+
"fill": stroke,
|
|
173
|
+
"value": String(value)
|
|
155
174
|
}, null))]);
|
|
156
175
|
})])]);
|
|
157
176
|
};
|
|
158
177
|
}
|
|
159
178
|
});
|
|
160
179
|
//#endregion
|
|
161
|
-
export {
|
|
180
|
+
export { PolarAngleAxis };
|