vccs 0.0.1 → 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/LICENSE +21 -0
- package/dist/animation/Animate.d.ts +72 -0
- package/dist/cartesian/GraphicalItemClipPath.d.ts +31 -0
- package/dist/cartesian/area/ActivePoints.d.ts +77 -0
- package/dist/cartesian/area/Area.d.ts +17 -0
- package/dist/cartesian/area/ClipRect.d.ts +1 -0
- package/dist/cartesian/area/RenderArea.d.ts +16 -0
- package/dist/cartesian/area/__stories__/config.d.ts +31 -0
- package/dist/cartesian/area/hooks/useArea.d.ts +27 -0
- package/dist/cartesian/area/index.d.ts +2 -0
- package/dist/cartesian/area/type.d.ts +173 -0
- package/dist/cartesian/area/utils.d.ts +19 -0
- package/dist/cartesian/axis/XAxis.d.ts +189 -0
- package/dist/cartesian/axis/YAxis.d.ts +192 -0
- package/dist/cartesian/axis/index.d.ts +2 -0
- package/dist/cartesian/axis/type.d.ts +57 -0
- package/dist/cartesian/bar/Bar.d.ts +2 -0
- package/dist/cartesian/bar/components/BarBackground.d.ts +1 -0
- package/dist/cartesian/bar/components/BarRectangles.d.ts +1 -0
- package/dist/cartesian/bar/hooks/useBar.d.ts +23 -0
- package/dist/cartesian/bar/index.d.ts +1 -0
- package/dist/cartesian/bar/type.d.ts +166 -0
- package/dist/cartesian/bar/utils.d.ts +31 -0
- package/dist/cartesian/brush/Brush.d.ts +2 -0
- package/dist/cartesian/brush/components/Background.d.ts +15 -0
- package/dist/cartesian/brush/components/BrushText.d.ts +27 -0
- package/dist/cartesian/brush/components/Panorama.d.ts +65 -0
- package/dist/cartesian/brush/components/Slide.d.ts +20 -0
- package/dist/cartesian/brush/components/Traveller.d.ts +13 -0
- package/dist/cartesian/brush/components/TravellerLayer.d.ts +22 -0
- package/dist/cartesian/brush/hooks/useBrushHandlers.d.ts +25 -0
- package/dist/cartesian/brush/hooks/useBrushSetting.d.ts +6 -0
- package/dist/cartesian/brush/hooks/useBrushState.d.ts +29 -0
- package/dist/cartesian/brush/index.d.ts +2 -0
- package/dist/cartesian/brush/type.d.ts +103 -0
- package/dist/cartesian/brush/utils.d.ts +15 -0
- package/dist/cartesian/cartesian-axis/CartesianAxis.d.ts +209 -0
- package/dist/cartesian/cartesian-axis/const.d.ts +24 -0
- package/dist/cartesian/cartesian-axis/index.d.ts +1 -0
- package/dist/cartesian/cartesian-axis/use-axis-line.d.ts +7 -0
- package/dist/cartesian/cartesian-grid/Background.d.ts +18 -0
- package/dist/cartesian/cartesian-grid/CartesianGrid.d.ts +75 -0
- package/dist/cartesian/cartesian-grid/HorizontalGridLines.d.ts +37 -0
- package/dist/cartesian/cartesian-grid/HorizontalStripes.d.ts +20 -0
- package/dist/cartesian/cartesian-grid/VerticalGridLines.d.ts +26 -0
- package/dist/cartesian/cartesian-grid/VerticalStripes.d.ts +20 -0
- package/dist/cartesian/cartesian-grid/const.d.ts +6 -0
- package/dist/cartesian/cartesian-grid/index.d.ts +1 -0
- package/dist/cartesian/cartesian-grid/type.d.ts +145 -0
- package/dist/cartesian/cartesian-grid/utils.d.ts +5 -0
- package/dist/cartesian/error-bar/ErrorBar.d.ts +68 -0
- package/dist/cartesian/error-bar/ErrorBarContext.d.ts +27 -0
- package/dist/cartesian/error-bar/index.d.ts +2 -0
- 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 +106 -0
- package/dist/cartesian/funnel/utils.d.ts +12 -0
- package/dist/cartesian/index.d.ts +12 -0
- package/dist/cartesian/line/ActivePoints.d.ts +77 -0
- package/dist/cartesian/line/Line.d.ts +87 -0
- package/dist/cartesian/line/StaticLine.d.ts +16 -0
- package/dist/cartesian/line/hooks/useLine.d.ts +28 -0
- package/dist/cartesian/line/index.d.ts +3 -0
- package/dist/cartesian/line/type.d.ts +180 -0
- package/dist/cartesian/line/utils.d.ts +13 -0
- package/dist/cartesian/reference-area/ReferenceArea.d.ts +191 -0
- package/dist/cartesian/reference-area/index.d.ts +1 -0
- package/dist/cartesian/reference-line/ReferenceLine.d.ts +139 -0
- package/dist/cartesian/reference-line/index.d.ts +1 -0
- package/dist/cartesian/scatter/Scatter.d.ts +165 -0
- package/dist/cartesian/scatter/hooks/useScatter.d.ts +18 -0
- package/dist/cartesian/scatter/index.d.ts +1 -0
- package/dist/cartesian/type.d.ts +21 -0
- package/dist/cartesian/useNeedsClip.d.ts +6 -0
- package/dist/cartesian/utils/get-ticks.d.ts +16 -0
- package/dist/cartesian/z-axis/ZAxis.d.ts +81 -0
- package/dist/cartesian/z-axis/index.d.ts +1 -0
- package/dist/chart/AreaChart.d.ts +1 -0
- package/dist/chart/BarChart.d.ts +1 -0
- package/dist/chart/ComposedChart.d.ts +1 -0
- package/dist/chart/FunnelChart.d.ts +1 -0
- package/dist/chart/LegendPortalContext.d.ts +3 -0
- package/dist/chart/LineChart.d.ts +1 -0
- package/dist/chart/PieChart.d.ts +1 -0
- package/dist/chart/RadarChart.d.ts +1 -0
- package/dist/chart/RadialBarChart.d.ts +1 -0
- package/dist/chart/RechartsWrapper.d.ts +99 -0
- package/dist/chart/ScatterChart.d.ts +1 -0
- package/dist/chart/Surface.d.ts +40 -0
- package/dist/chart/TooltipPortalContext.d.ts +2 -0
- package/dist/chart/const.d.ts +6 -0
- package/dist/chart/generateCategoricalChart.d.ts +118 -0
- package/dist/chart/index.d.ts +9 -0
- package/dist/chart/provideClipPathId.d.ts +12 -0
- package/dist/components/Cell.d.ts +18 -0
- package/dist/components/DefaultLegendContent.d.ts +18 -0
- package/dist/components/Text.d.ts +149 -0
- package/dist/components/Tooltip.d.ts +250 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/label/Label.d.ts +81 -0
- package/dist/components/label/LabelList.d.ts +63 -0
- package/dist/components/label/index.d.ts +2 -0
- package/dist/components/label/types.d.ts +88 -0
- package/dist/components/label/utils.d.ts +24 -0
- package/dist/components/legend/Legend.d.ts +4 -0
- package/dist/components/legend/LegendSymbol.d.ts +27 -0
- package/dist/components/legend/hooks/useLegend.d.ts +19 -0
- package/dist/components/legend/hooks/useLegendContent.d.ts +36 -0
- package/dist/components/legend/index.d.ts +2 -0
- package/dist/components/legend/type.d.ts +54 -0
- package/dist/components/legend/utils.d.ts +18 -0
- package/dist/components/types.d.ts +9 -0
- package/dist/components/utils.d.ts +4 -0
- package/dist/container/ClipPath.d.ts +12 -0
- package/dist/container/Layer.d.ts +2 -0
- package/dist/container/ResponsiveContainer.d.ts +50 -0
- package/dist/container/RootSurface.d.ts +17 -0
- package/dist/container/Surface.d.ts +25 -0
- package/dist/container/index.d.ts +1 -0
- package/dist/container/useSizeContext.d.ts +11 -0
- package/dist/context/ChartDataContextProvider.d.ts +17 -0
- package/dist/context/PanoramaContextProvider.d.ts +22 -0
- package/dist/context/accessibilityContext.d.ts +1 -0
- package/dist/context/cartesianLabelListContext.d.ts +3 -0
- package/dist/context/chartLayoutContext.d.ts +8 -0
- package/dist/context/cursorLayerContext.d.ts +2 -0
- package/dist/context/graphicalLayerContext.d.ts +2 -0
- package/dist/context/labelLayerContext.d.ts +2 -0
- package/dist/context/polarLabelViewBoxContext.d.ts +4 -0
- package/dist/context/useTooltipAxis.d.ts +2 -0
- package/dist/es/animation/Animate.mjs +89 -0
- package/dist/es/cartesian/GraphicalItemClipPath.mjs +37 -0
- package/dist/es/cartesian/area/ActivePoints.mjs +78 -0
- package/dist/es/cartesian/area/Area.mjs +52 -0
- package/dist/es/cartesian/area/ClipRect.mjs +125 -0
- package/dist/es/cartesian/area/RenderArea.mjs +185 -0
- package/dist/es/cartesian/area/hooks/useArea.mjs +81 -0
- package/dist/es/cartesian/area/type.mjs +136 -0
- package/dist/es/cartesian/area/utils.mjs +79 -0
- package/dist/es/cartesian/axis/XAxis.mjs +203 -0
- package/dist/es/cartesian/axis/YAxis.mjs +192 -0
- package/dist/es/cartesian/bar/Bar.mjs +111 -0
- package/dist/es/cartesian/bar/components/BarBackground.mjs +32 -0
- package/dist/es/cartesian/bar/components/BarRectangles.mjs +143 -0
- package/dist/es/cartesian/bar/hooks/useBar.mjs +53 -0
- package/dist/es/cartesian/bar/type.mjs +131 -0
- package/dist/es/cartesian/bar/utils.mjs +111 -0
- package/dist/es/cartesian/cartesian-axis/CartesianAxis.mjs +296 -0
- package/dist/es/cartesian/cartesian-grid/Background.mjs +33 -0
- package/dist/es/cartesian/cartesian-grid/CartesianGrid.mjs +174 -0
- package/dist/es/cartesian/cartesian-grid/HorizontalGridLines.mjs +50 -0
- package/dist/es/cartesian/cartesian-grid/HorizontalStripes.mjs +43 -0
- package/dist/es/cartesian/cartesian-grid/VerticalGridLines.mjs +45 -0
- package/dist/es/cartesian/cartesian-grid/VerticalStripes.mjs +43 -0
- package/dist/es/cartesian/cartesian-grid/const.mjs +336 -0
- package/dist/es/cartesian/cartesian-grid/utils.mjs +22 -0
- package/dist/es/cartesian/error-bar/ErrorBar.mjs +143 -0
- package/dist/es/cartesian/error-bar/ErrorBarContext.mjs +20 -0
- 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 +79 -0
- package/dist/es/cartesian/line/Line.mjs +50 -0
- package/dist/es/cartesian/line/StaticLine.mjs +217 -0
- package/dist/es/cartesian/line/hooks/useLine.mjs +69 -0
- package/dist/es/cartesian/line/type.mjs +112 -0
- package/dist/es/cartesian/line/utils.mjs +34 -0
- package/dist/es/cartesian/reference-area/ReferenceArea.mjs +163 -0
- package/dist/es/cartesian/reference-line/ReferenceLine.mjs +165 -0
- package/dist/es/cartesian/scatter/Scatter.mjs +280 -0
- package/dist/es/cartesian/scatter/hooks/useScatter.mjs +23 -0
- package/dist/es/cartesian/useNeedsClip.mjs +23 -0
- package/dist/es/cartesian/utils/get-ticks.mjs +118 -0
- package/dist/es/cartesian/z-axis/ZAxis.mjs +72 -0
- package/dist/es/chart/AreaChart.mjs +9 -0
- package/dist/es/chart/BarChart.mjs +10 -0
- package/dist/es/chart/ComposedChart.mjs +10 -0
- package/dist/es/chart/FunnelChart.mjs +11 -0
- package/dist/es/chart/LegendPortalContext.mjs +5 -0
- package/dist/es/chart/LineChart.mjs +10 -0
- package/dist/es/chart/PieChart.mjs +16 -0
- package/dist/es/chart/RadarChart.mjs +16 -0
- package/dist/es/chart/RadialBarChart.mjs +16 -0
- package/dist/es/chart/RechartsWrapper.mjs +160 -0
- package/dist/es/chart/ScatterChart.mjs +10 -0
- package/dist/es/chart/Surface.mjs +5 -0
- package/dist/es/chart/Surface.vue_vue_type_script_setup_true_lang.mjs +72 -0
- package/dist/es/chart/TooltipPortalContext.mjs +5 -0
- package/dist/es/chart/const.mjs +7 -0
- package/dist/es/chart/generateCategoricalChart.mjs +175 -0
- package/dist/es/chart/provideClipPathId.mjs +15 -0
- package/dist/es/components/Cell.mjs +23 -0
- package/dist/es/components/Text.mjs +5 -0
- package/dist/es/components/Text.vue_vue_type_script_setup_true_lang.mjs +191 -0
- package/dist/es/components/Tooltip.mjs +463 -0
- package/dist/es/components/label/Label.mjs +40 -0
- package/dist/es/components/label/LabelList.mjs +55 -0
- package/dist/es/components/label/types.mjs +38 -0
- package/dist/es/components/label/utils.mjs +265 -0
- package/dist/es/components/legend/Legend.mjs +93 -0
- package/dist/es/components/legend/LegendSymbol.mjs +62 -0
- package/dist/es/components/legend/hooks/useLegend.mjs +72 -0
- package/dist/es/components/legend/hooks/useLegendContent.mjs +68 -0
- package/dist/es/components/legend/type.mjs +41 -0
- package/dist/es/components/legend/utils.mjs +25 -0
- package/dist/es/components/utils.mjs +44 -0
- package/dist/es/container/ClipPath.mjs +25 -0
- package/dist/es/container/Layer.mjs +14 -0
- package/dist/es/container/ResponsiveContainer.mjs +5 -0
- package/dist/es/container/ResponsiveContainer.vue_vue_type_script_setup_true_lang.mjs +144 -0
- package/dist/es/container/Surface.mjs +62 -0
- package/dist/es/container/useSizeContext.mjs +5 -0
- package/dist/es/context/ChartDataContextProvider.mjs +27 -0
- package/dist/es/context/PanoramaContextProvider.mjs +24 -0
- package/dist/es/context/accessibilityContext.mjs +5 -0
- package/dist/es/context/cartesianLabelListContext.mjs +5 -0
- package/dist/es/context/chartLayoutContext.mjs +49 -0
- package/dist/es/context/cursorLayerContext.mjs +5 -0
- package/dist/es/context/graphicalLayerContext.mjs +5 -0
- package/dist/es/context/labelLayerContext.mjs +5 -0
- package/dist/es/context/polarLabelViewBoxContext.mjs +8 -0
- package/dist/es/context/useTooltipAxis.mjs +17 -0
- package/dist/es/events/useChartSynchronisation.mjs +113 -0
- package/dist/es/hooks/useIsAnimating.mjs +28 -0
- package/dist/es/hooks/useSetupGraphicalItem.mjs +66 -0
- package/dist/es/index.mjs +46 -0
- package/dist/es/polar/pie/Pie.mjs +161 -0
- package/dist/es/polar/pie/type.mjs +97 -0
- package/dist/es/polar/radar/PolarAngleAxis.mjs +180 -0
- package/dist/es/polar/radar/PolarGrid.mjs +115 -0
- package/dist/es/polar/radar/PolarRadiusAxis.mjs +162 -0
- package/dist/es/polar/radar/Radar.mjs +284 -0
- package/dist/es/polar/radial-bar/RadialBar.mjs +197 -0
- package/dist/es/polar/radial-bar/type.mjs +97 -0
- package/dist/es/shape/Cross.mjs +16 -0
- package/dist/es/shape/Curve.mjs +86 -0
- package/dist/es/shape/Dot.mjs +24 -0
- package/dist/es/shape/Rectangle.mjs +83 -0
- package/dist/es/shape/Sector.mjs +156 -0
- package/dist/es/shape/Symbols.mjs +52 -0
- package/dist/es/shape/Trapezoid.mjs +52 -0
- package/dist/es/state/ReportChartProps.mjs +64 -0
- package/dist/es/state/ReportMainChartProps.mjs +46 -0
- package/dist/es/state/ReportPolarOptions.mjs +56 -0
- package/dist/es/state/SetGraphicalItem.mjs +49 -0
- package/dist/es/state/SetLegendPayload.mjs +20 -0
- package/dist/es/state/SetTooltipEntrySettings.mjs +19 -0
- package/dist/es/state/brushSlice.mjs +26 -0
- package/dist/es/state/cartesianAxisSlice.mjs +39 -0
- package/dist/es/state/chartDataSlice.mjs +33 -0
- package/dist/es/state/externalEventsMiddleware.mjs +30 -0
- package/dist/es/state/graphicalItemsSlice.mjs +47 -0
- package/dist/es/state/hooks.mjs +6 -0
- package/dist/es/state/keyboardEventsMiddleware.mjs +63 -0
- package/dist/es/state/layoutSlice.mjs +39 -0
- package/dist/es/state/legendSlice.mjs +40 -0
- package/dist/es/state/mouseEventsMiddleware.mjs +41 -0
- package/dist/es/state/optionsSlice.mjs +25 -0
- package/dist/es/state/polarAxisSlice.mjs +28 -0
- package/dist/es/state/polarOptionsSlice.mjs +13 -0
- package/dist/es/state/reduxDevtoolsJsonStringifyReplacer.mjs +8 -0
- package/dist/es/state/referenceElementsSlice.mjs +36 -0
- package/dist/es/state/rootPropsSlice.mjs +32 -0
- package/dist/es/state/selectors/areaSelectors.mjs +77 -0
- package/dist/es/state/selectors/axisSelectors.mjs +879 -0
- package/dist/es/state/selectors/barSelectors.mjs +241 -0
- package/dist/es/state/selectors/brushSelectors.mjs +18 -0
- package/dist/es/state/selectors/combiners/combineActiveLabel.mjs +9 -0
- package/dist/es/state/selectors/combiners/combineActiveTooltipIndex.mjs +43 -0
- package/dist/es/state/selectors/combiners/combineAxisRangeWithReverse.mjs +8 -0
- package/dist/es/state/selectors/combiners/combineCoordinateForDefaultIndex.mjs +21 -0
- package/dist/es/state/selectors/combiners/combineTooltipInteractionState.mjs +37 -0
- package/dist/es/state/selectors/combiners/combineTooltipPayloadConfigurations.mjs +13 -0
- package/dist/es/state/selectors/common.mjs +4 -0
- package/dist/es/state/selectors/containerSelectors.mjs +7 -0
- package/dist/es/state/selectors/dataSelectors.mjs +35 -0
- package/dist/es/state/selectors/funnelSelectors.mjs +38 -0
- package/dist/es/state/selectors/legendSelectors.mjs +10 -0
- package/dist/es/state/selectors/lineSelectors.mjs +64 -0
- package/dist/es/state/selectors/pickAxisId.mjs +4 -0
- package/dist/es/state/selectors/pickAxisType.mjs +4 -0
- package/dist/es/state/selectors/pieSelectors.mjs +132 -0
- package/dist/es/state/selectors/polarAxisSelectors.mjs +167 -0
- package/dist/es/state/selectors/polarGridSelectors.mjs +19 -0
- package/dist/es/state/selectors/polarScaleSelectors.mjs +55 -0
- package/dist/es/state/selectors/polarSelectors.mjs +81 -0
- package/dist/es/state/selectors/radarSelectors.mjs +133 -0
- package/dist/es/state/selectors/radialBarSelectors.mjs +259 -0
- package/dist/es/state/selectors/rootPropsSelectors.mjs +14 -0
- package/dist/es/state/selectors/scatterSelectors.mjs +134 -0
- package/dist/es/state/selectors/selectActivePropsFromChartPointer.mjs +20 -0
- package/dist/es/state/selectors/selectAllAxes.mjs +10 -0
- package/dist/es/state/selectors/selectChartOffset.mjs +69 -0
- package/dist/es/state/selectors/selectChartOffsetInternal.mjs +66 -0
- package/dist/es/state/selectors/selectTooltipEventType.mjs +22 -0
- package/dist/es/state/selectors/selectTooltipPayloadSearcher.mjs +6 -0
- package/dist/es/state/selectors/selectTooltipSettings.mjs +4 -0
- package/dist/es/state/selectors/selectTooltipState.mjs +4 -0
- package/dist/es/state/selectors/selectors.mjs +104 -0
- package/dist/es/state/selectors/tooltipSelectors.mjs +269 -0
- package/dist/es/state/selectors/touchSelectors.mjs +19 -0
- package/dist/es/state/store.mjs +55 -0
- package/dist/es/state/tooltipSlice.mjs +102 -0
- package/dist/es/state/touchEventsMiddleware.mjs +44 -0
- package/dist/es/state/utils/useReportScale.mjs +19 -0
- package/dist/es/synchronisation/syncSelectors.mjs +6 -0
- package/dist/es/synchronisation/useChartSynchronisation.mjs +38 -0
- package/dist/es/types/event.mjs +166 -0
- package/dist/es/utils/ReduceCSSCalc.mjs +114 -0
- package/dist/es/utils/VueUtils.mjs +39 -0
- package/dist/es/utils/attrs.mjs +69 -0
- package/dist/es/utils/cartesian.mjs +54 -0
- package/dist/es/utils/chart.mjs +366 -0
- package/dist/es/utils/const.mjs +32 -0
- package/dist/es/utils/createContext.mjs +31 -0
- package/dist/es/utils/data-utils.mjs +13 -0
- package/dist/es/utils/data.mjs +41 -0
- package/dist/es/utils/events.mjs +7 -0
- package/dist/es/utils/getLinearRegression.mjs +34 -0
- package/dist/es/utils/grid.mjs +23 -0
- package/dist/es/utils/isDomainSpecifiedByUser.mjs +116 -0
- package/dist/es/utils/legend.mjs +19 -0
- package/dist/es/utils/log.mjs +14 -0
- package/dist/es/utils/payload/getUniqPayload.mjs +9 -0
- package/dist/es/utils/polar.mjs +59 -0
- package/dist/es/utils/props.mjs +20 -0
- package/dist/es/utils/resolveDefaultProps.mjs +26 -0
- package/dist/es/utils/scale/getNiceTickValues.mjs +137 -0
- package/dist/es/utils/scale/utils/arithmetic.mjs +54 -0
- package/dist/es/utils/scale/utils/utils.mjs +53 -0
- package/dist/es/utils/style.mjs +30 -0
- package/dist/es/utils/tick.mjs +42 -0
- package/dist/es/utils/tooltip/translate.mjs +73 -0
- package/dist/es/utils/validate.mjs +42 -0
- package/dist/events/useChartSynchronisation.d.ts +8 -0
- package/dist/hooks/useIsAnimating.d.ts +14 -0
- package/dist/hooks/useSetupGraphicalItem.d.ts +7 -0
- package/dist/index.d.ts +6 -0
- package/dist/polar/index.d.ts +3 -0
- package/dist/polar/pie/Pie.d.ts +2 -0
- package/dist/polar/pie/index.d.ts +2 -0
- package/dist/polar/pie/type.d.ts +88 -0
- package/dist/polar/radar/PolarAngleAxis.d.ts +145 -0
- package/dist/polar/radar/PolarGrid.d.ts +77 -0
- package/dist/polar/radar/PolarRadiusAxis.d.ts +125 -0
- package/dist/polar/radar/Radar.d.ts +160 -0
- package/dist/polar/radar/index.d.ts +4 -0
- package/dist/polar/radial-bar/RadialBar.d.ts +2 -0
- package/dist/polar/radial-bar/index.d.ts +2 -0
- package/dist/polar/radial-bar/type.d.ts +96 -0
- package/dist/shape/Cross.d.ts +10 -0
- package/dist/shape/Curve.d.ts +42 -0
- package/dist/shape/Dot.d.ts +18 -0
- package/dist/shape/Rectangle.d.ts +33 -0
- package/dist/shape/Sector.d.ts +48 -0
- package/dist/shape/Symbols.d.ts +15 -0
- package/dist/shape/Trapezoid.d.ts +31 -0
- package/dist/shape/index.d.ts +9 -0
- package/dist/shape/types.d.ts +20 -0
- package/dist/state/ReportBar.d.ts +1 -0
- package/dist/state/ReportChartProps.d.ts +88 -0
- package/dist/state/ReportMainChartProps.d.ts +37 -0
- package/dist/state/ReportPolarOptions.d.ts +59 -0
- package/dist/state/SetGraphicalItem.d.ts +9 -0
- package/dist/state/SetLegendPayload.d.ts +3 -0
- package/dist/state/SetTooltipEntrySettings.d.ts +8 -0
- package/dist/state/brushSlice.d.ts +18 -0
- package/dist/state/cartesianAxisSlice.d.ts +88 -0
- package/dist/state/chartDataSlice.d.ts +44 -0
- package/dist/state/externalEventsMiddleware.d.ts +17 -0
- package/dist/state/graphicalItemsSlice.d.ts +108 -0
- package/dist/state/hooks.d.ts +54 -0
- package/dist/state/keyboardEventsMiddleware.d.ts +3 -0
- package/dist/state/layoutSlice.d.ts +15 -0
- package/dist/state/legendSlice.d.ts +26 -0
- package/dist/state/mouseEventsMiddleware.d.ts +5 -0
- package/dist/state/optionsSlice.d.ts +27 -0
- package/dist/state/polarAxisSlice.d.ts +10 -0
- package/dist/state/polarOptionsSlice.d.ts +10 -0
- package/dist/state/reduxDevtoolsJsonStringifyReplacer.d.ts +1 -0
- package/dist/state/referenceElementsSlice.d.ts +40 -0
- package/dist/state/rootPropsSlice.d.ts +26 -0
- package/dist/state/selectors/areaSelectors.d.ts +24 -0
- package/dist/state/selectors/axisSelectors.d.ts +1828 -0
- package/dist/state/selectors/barSelectors.d.ts +944 -0
- package/dist/state/selectors/brushSelectors.d.ts +10 -0
- package/dist/state/selectors/combiners/combineActiveLabel.d.ts +3 -0
- package/dist/state/selectors/combiners/combineActiveTooltipIndex.d.ts +5 -0
- package/dist/state/selectors/combiners/combineAxisRangeWithReverse.d.ts +3 -0
- package/dist/state/selectors/combiners/combineCoordinateForDefaultIndex.d.ts +3 -0
- package/dist/state/selectors/combiners/combineTooltipInteractionState.d.ts +3 -0
- package/dist/state/selectors/combiners/combineTooltipPayloadConfigurations.d.ts +3 -0
- package/dist/state/selectors/common.d.ts +2 -0
- package/dist/state/selectors/containerSelectors.d.ts +6 -0
- package/dist/state/selectors/dataSelectors.d.ts +23 -0
- package/dist/state/selectors/funnelSelectors.d.ts +69 -0
- package/dist/state/selectors/legendSelectors.d.ts +7 -0
- package/dist/state/selectors/lineSelectors.d.ts +123 -0
- package/dist/state/selectors/pickAxisId.d.ts +3 -0
- package/dist/state/selectors/pickAxisType.d.ts +2 -0
- package/dist/state/selectors/pieSelectors.d.ts +55 -0
- package/dist/state/selectors/polarAxisSelectors.d.ts +49 -0
- package/dist/state/selectors/polarGridSelectors.d.ts +118 -0
- package/dist/state/selectors/polarScaleSelectors.d.ts +9 -0
- package/dist/state/selectors/polarSelectors.d.ts +70 -0
- package/dist/state/selectors/radarSelectors.d.ts +76 -0
- package/dist/state/selectors/radialBarSelectors.d.ts +61 -0
- package/dist/state/selectors/rootPropsSelectors.d.ts +11 -0
- package/dist/state/selectors/scatterSelectors.d.ts +21 -0
- package/dist/state/selectors/selectActivePropsFromChartPointer.d.ts +382 -0
- package/dist/state/selectors/selectAllAxes.d.ts +4 -0
- package/dist/state/selectors/selectChartOffset.d.ts +116 -0
- package/dist/state/selectors/selectChartOffsetInternal.d.ts +9 -0
- package/dist/state/selectors/selectTooltipEventType.d.ts +8 -0
- package/dist/state/selectors/selectTooltipPayloadSearcher.d.ts +3 -0
- package/dist/state/selectors/selectTooltipSettings.d.ts +3 -0
- package/dist/state/selectors/selectTooltipState.d.ts +3 -0
- package/dist/state/selectors/selectors.d.ts +184 -0
- package/dist/state/selectors/tooltipSelectors.d.ts +581 -0
- package/dist/state/selectors/touchSelectors.d.ts +4 -0
- package/dist/state/store.d.ts +74 -0
- package/dist/state/tooltipSlice.d.ts +204 -0
- package/dist/state/touchEventsMiddleware.d.ts +2 -0
- package/dist/state/utils/useReportScale.d.ts +1 -0
- package/dist/synchronisation/syncSelectors.d.ts +3 -0
- package/dist/synchronisation/useChartSynchronisation.d.ts +11 -0
- package/dist/types/area.d.ts +8 -0
- package/dist/types/axis.d.ts +127 -0
- package/dist/types/bar.d.ts +51 -0
- package/dist/types/categorical.d.ts +36 -0
- package/dist/types/common.d.ts +129 -0
- package/dist/types/event.d.ts +16 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/legend.d.ts +1 -0
- package/dist/types/offset.d.ts +8 -0
- package/dist/types/radar.d.ts +28 -0
- package/dist/types/scale.d.ts +11 -0
- package/dist/types/tick.d.ts +55 -0
- package/dist/types/tooltip.d.ts +33 -0
- package/dist/utils/ReduceCSSCalc.d.ts +2 -0
- package/dist/utils/VueUtils.d.ts +11 -0
- package/dist/utils/attrs.d.ts +46 -0
- package/dist/utils/cartesian.d.ts +20 -0
- package/dist/utils/chart.d.ts +99 -0
- package/dist/utils/const.d.ts +30 -0
- package/dist/utils/context.d.ts +8 -0
- package/dist/utils/createContext.d.ts +8 -0
- package/dist/utils/data-utils.d.ts +4 -0
- package/dist/utils/data.d.ts +13 -0
- package/dist/utils/events.d.ts +12 -0
- package/dist/utils/getLinearRegression.d.ts +15 -0
- package/dist/utils/getRelativeCoordinate.d.ts +11 -0
- package/dist/utils/grid.d.ts +37 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/isDomainSpecifiedByUser.d.ts +47 -0
- package/dist/utils/legend.d.ts +3 -0
- package/dist/utils/log.d.ts +1 -0
- package/dist/utils/payload/getUniqPayload.d.ts +4 -0
- package/dist/utils/polar.d.ts +21 -0
- package/dist/utils/props.d.ts +15 -0
- package/dist/utils/resolveDefaultProps.d.ts +52 -0
- package/dist/utils/scale/getNiceTickValues.d.ts +61 -0
- package/dist/utils/scale/utils/arithmetic.d.ts +50 -0
- package/dist/utils/scale/utils/utils.d.ts +9 -0
- package/dist/utils/style.d.ts +12 -0
- package/dist/utils/tick.d.ts +19 -0
- package/dist/utils/tooltip/translate.d.ts +47 -0
- package/dist/utils/types.d.ts +14 -0
- package/dist/utils/validate.d.ts +25 -0
- package/package.json +27 -10
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
//#region src/components/label/LabelList.tsx
|
|
11
|
+
function _isSlot(s) {
|
|
12
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
13
|
+
}
|
|
14
|
+
var LabelList = /* @__PURE__ */ defineComponent({
|
|
15
|
+
props: LabelListVueProps,
|
|
16
|
+
setup(props, { attrs, slots }) {
|
|
17
|
+
const labelLayerRef = useLabelLayerRef(null);
|
|
18
|
+
const contextData = useCartesianLabelListData(null);
|
|
19
|
+
return () => {
|
|
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
|
|
30
|
+
});
|
|
31
|
+
if (slots.label) return slots.label({
|
|
32
|
+
...others,
|
|
33
|
+
...attrs,
|
|
34
|
+
...viewBox,
|
|
35
|
+
value,
|
|
36
|
+
index,
|
|
37
|
+
key: `label-${index}`
|
|
38
|
+
});
|
|
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
|
|
47
|
+
}), null);
|
|
48
|
+
})) ? _slot : { default: () => [_slot] });
|
|
49
|
+
if (labelLayerRef?.value) return createVNode(Teleport, { "to": labelLayerRef.value }, _isSlot(content) ? content : { default: () => [content] });
|
|
50
|
+
return content;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
//#endregion
|
|
55
|
+
export { LabelList };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { last } from "es-toolkit/compat";
|
|
2
|
+
//#region src/components/label/types.ts
|
|
3
|
+
var defaultAccessor = (entry) => Array.isArray(entry.value) ? last(entry.value) : entry.value;
|
|
4
|
+
var LabelListVueProps = {
|
|
5
|
+
id: { type: String },
|
|
6
|
+
data: { type: Array },
|
|
7
|
+
valueAccessor: {
|
|
8
|
+
type: Function,
|
|
9
|
+
default: defaultAccessor
|
|
10
|
+
},
|
|
11
|
+
clockWise: { type: Boolean },
|
|
12
|
+
dataKey: { type: [String, Function] },
|
|
13
|
+
textBreakAll: { type: Boolean },
|
|
14
|
+
position: { type: String },
|
|
15
|
+
offset: { type: Number },
|
|
16
|
+
angle: { type: Number }
|
|
17
|
+
};
|
|
18
|
+
var LabelVueProps = {
|
|
19
|
+
id: { type: String },
|
|
20
|
+
class: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: ""
|
|
23
|
+
},
|
|
24
|
+
viewBox: { type: Object },
|
|
25
|
+
parentViewBox: { type: Object },
|
|
26
|
+
value: { type: [Number, String] },
|
|
27
|
+
formatter: { type: Function },
|
|
28
|
+
offset: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: 5
|
|
31
|
+
},
|
|
32
|
+
position: { type: [String, Object] },
|
|
33
|
+
textBreakAll: { type: Boolean },
|
|
34
|
+
angle: { type: Number },
|
|
35
|
+
index: { type: Number }
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { LabelListVueProps, LabelVueProps };
|
|
@@ -0,0 +1,265 @@
|
|
|
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
|
+
//#region src/components/label/utils.tsx
|
|
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
|
+
};
|
|
16
|
+
if (isNumber(top) && isNumber(left)) return {
|
|
17
|
+
x: top,
|
|
18
|
+
y: left,
|
|
19
|
+
width,
|
|
20
|
+
height
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (isNumber(x) && isNumber(y)) return {
|
|
24
|
+
x,
|
|
25
|
+
y,
|
|
26
|
+
width: 0,
|
|
27
|
+
height: 0
|
|
28
|
+
};
|
|
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
|
+
};
|
|
38
|
+
if (props.viewBox) return props.viewBox;
|
|
39
|
+
}
|
|
40
|
+
function isPolar(viewBox) {
|
|
41
|
+
return "cx" in viewBox && isNumber(viewBox.cx);
|
|
42
|
+
}
|
|
43
|
+
var RADIAN = Math.PI / 180;
|
|
44
|
+
function polarToCartesian(cx, cy, radius, angle) {
|
|
45
|
+
return {
|
|
46
|
+
x: cx + Math.cos(-RADIAN * angle) * radius,
|
|
47
|
+
y: cy + Math.sin(-RADIAN * angle) * radius
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function getDeltaAngle(startAngle, endAngle) {
|
|
51
|
+
return mathSign(endAngle - startAngle) * Math.min(Math.abs(endAngle - startAngle), 360);
|
|
52
|
+
}
|
|
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) {
|
|
62
|
+
case "insideStart":
|
|
63
|
+
labelAngle = startAngle + sign * offset;
|
|
64
|
+
direction = clockWise;
|
|
65
|
+
break;
|
|
66
|
+
case "insideEnd":
|
|
67
|
+
labelAngle = endAngle - sign * offset;
|
|
68
|
+
direction = !clockWise;
|
|
69
|
+
break;
|
|
70
|
+
case "end":
|
|
71
|
+
labelAngle = endAngle + sign * offset;
|
|
72
|
+
direction = clockWise;
|
|
73
|
+
break;
|
|
74
|
+
default: throw new Error(`Unsupported position ${position}`);
|
|
75
|
+
}
|
|
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, {
|
|
82
|
+
"dominant-baseline": "central",
|
|
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])]);
|
|
88
|
+
}
|
|
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);
|
|
95
|
+
return {
|
|
96
|
+
x,
|
|
97
|
+
y,
|
|
98
|
+
textAnchor: x >= cx ? "start" : "end",
|
|
99
|
+
verticalAnchor: "middle"
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (position === "center") return {
|
|
103
|
+
x: cx,
|
|
104
|
+
y: cy,
|
|
105
|
+
textAnchor: "middle",
|
|
106
|
+
verticalAnchor: "middle"
|
|
107
|
+
};
|
|
108
|
+
if (position === "centerTop") return {
|
|
109
|
+
x: cx,
|
|
110
|
+
y: cy,
|
|
111
|
+
textAnchor: "middle",
|
|
112
|
+
verticalAnchor: "start"
|
|
113
|
+
};
|
|
114
|
+
if (position === "centerBottom") return {
|
|
115
|
+
x: cx,
|
|
116
|
+
y: cy,
|
|
117
|
+
textAnchor: "middle",
|
|
118
|
+
verticalAnchor: "end"
|
|
119
|
+
};
|
|
120
|
+
const { x, y } = polarToCartesian(cx, cy, (innerRadius + outerRadius) / 2, midAngle);
|
|
121
|
+
return {
|
|
122
|
+
x,
|
|
123
|
+
y,
|
|
124
|
+
textAnchor: "middle",
|
|
125
|
+
verticalAnchor: "middle"
|
|
126
|
+
};
|
|
127
|
+
}
|
|
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,
|
|
142
|
+
textAnchor: "middle",
|
|
143
|
+
verticalAnchor: verticalEnd,
|
|
144
|
+
...parentViewBox ? {
|
|
145
|
+
height: Math.max(y - parentViewBox.y, 0),
|
|
146
|
+
width
|
|
147
|
+
} : {}
|
|
148
|
+
};
|
|
149
|
+
if (position === "bottom") return {
|
|
150
|
+
x: x + width / 2,
|
|
151
|
+
y: y + height + verticalOffset,
|
|
152
|
+
textAnchor: "middle",
|
|
153
|
+
verticalAnchor: verticalStart,
|
|
154
|
+
...parentViewBox ? {
|
|
155
|
+
height: Math.max(parentViewBox.y + parentViewBox.height - (y + height), 0),
|
|
156
|
+
width
|
|
157
|
+
} : {}
|
|
158
|
+
};
|
|
159
|
+
if (position === "left") {
|
|
160
|
+
const attrs = {
|
|
161
|
+
x: x - horizontalOffset,
|
|
162
|
+
y: y + height / 2,
|
|
163
|
+
textAnchor: horizontalEnd,
|
|
164
|
+
verticalAnchor: "middle"
|
|
165
|
+
};
|
|
166
|
+
return {
|
|
167
|
+
...attrs,
|
|
168
|
+
...parentViewBox ? {
|
|
169
|
+
width: Math.max(attrs.x - parentViewBox.x, 0),
|
|
170
|
+
height
|
|
171
|
+
} : {}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
if (position === "right") {
|
|
175
|
+
const attrs = {
|
|
176
|
+
x: x + width + horizontalOffset,
|
|
177
|
+
y: y + height / 2,
|
|
178
|
+
textAnchor: horizontalStart,
|
|
179
|
+
verticalAnchor: "middle"
|
|
180
|
+
};
|
|
181
|
+
return {
|
|
182
|
+
...attrs,
|
|
183
|
+
...parentViewBox ? {
|
|
184
|
+
width: Math.max(parentViewBox.x + parentViewBox.width - attrs.x, 0),
|
|
185
|
+
height
|
|
186
|
+
} : {}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const sizeAttrs = parentViewBox ? {
|
|
190
|
+
width,
|
|
191
|
+
height
|
|
192
|
+
} : {};
|
|
193
|
+
if (position === "insideLeft") return {
|
|
194
|
+
x: x + horizontalOffset,
|
|
195
|
+
y: y + height / 2,
|
|
196
|
+
textAnchor: horizontalStart,
|
|
197
|
+
verticalAnchor: "middle",
|
|
198
|
+
...sizeAttrs
|
|
199
|
+
};
|
|
200
|
+
if (position === "insideRight") return {
|
|
201
|
+
x: x + width - horizontalOffset,
|
|
202
|
+
y: y + height / 2,
|
|
203
|
+
textAnchor: horizontalEnd,
|
|
204
|
+
verticalAnchor: "middle",
|
|
205
|
+
...sizeAttrs
|
|
206
|
+
};
|
|
207
|
+
if (position === "insideTop") return {
|
|
208
|
+
x: x + width / 2,
|
|
209
|
+
y: y + verticalOffset,
|
|
210
|
+
textAnchor: "middle",
|
|
211
|
+
verticalAnchor: verticalStart,
|
|
212
|
+
...sizeAttrs
|
|
213
|
+
};
|
|
214
|
+
if (position === "insideBottom") return {
|
|
215
|
+
x: x + width / 2,
|
|
216
|
+
y: y + height - verticalOffset,
|
|
217
|
+
textAnchor: "middle",
|
|
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),
|
|
252
|
+
textAnchor: "end",
|
|
253
|
+
verticalAnchor: "end",
|
|
254
|
+
...sizeAttrs
|
|
255
|
+
};
|
|
256
|
+
return {
|
|
257
|
+
x: x + width / 2,
|
|
258
|
+
y: y + height / 2,
|
|
259
|
+
textAnchor: "middle",
|
|
260
|
+
verticalAnchor: "middle",
|
|
261
|
+
...sizeAttrs
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
//#endregion
|
|
265
|
+
export { getAttrsOfCartesianLabel, getAttrsOfPolarLabel, isPolar, parseViewBox, renderRadialLabel };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { LegendVueProps } from "./type.mjs";
|
|
2
|
+
import { useLegend } from "./hooks/useLegend.mjs";
|
|
3
|
+
import { useLegendContent } from "./hooks/useLegendContent.mjs";
|
|
4
|
+
import Surface from "../../container/Surface.mjs";
|
|
5
|
+
import { LegendSymbol } from "./LegendSymbol.mjs";
|
|
6
|
+
import { Teleport, createVNode, defineComponent, isVNode, watchEffect } from "vue";
|
|
7
|
+
//#region src/components/legend/Legend.tsx
|
|
8
|
+
function _isSlot(s) {
|
|
9
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
10
|
+
}
|
|
11
|
+
var Legend_default = /* @__PURE__ */ defineComponent({
|
|
12
|
+
name: "Legend",
|
|
13
|
+
props: LegendVueProps,
|
|
14
|
+
setup(props, { slots }) {
|
|
15
|
+
const { legendRef, processedPayload, outerStyle, legendPortal, syncSettings, syncSize } = useLegend(props);
|
|
16
|
+
const { getItemStyle, getSvgStyle, formatValue, handleClick, handleMouseEnter, handleMouseLeave } = useLegendContent(props);
|
|
17
|
+
watchEffect(() => {
|
|
18
|
+
syncSettings();
|
|
19
|
+
syncSize();
|
|
20
|
+
});
|
|
21
|
+
const renderDefaultContent = () => {
|
|
22
|
+
if (!processedPayload.value || processedPayload.value.length === 0) return null;
|
|
23
|
+
const { layout = "horizontal", align = "center", iconSize = 14 } = props;
|
|
24
|
+
const finalStyle = {
|
|
25
|
+
padding: 0,
|
|
26
|
+
margin: 0,
|
|
27
|
+
textAlign: layout === "horizontal" ? align : "left"
|
|
28
|
+
};
|
|
29
|
+
return createVNode("ul", {
|
|
30
|
+
"class": "v-charts-default-legend",
|
|
31
|
+
"style": finalStyle
|
|
32
|
+
}, [processedPayload.value.map((entry, index) => {
|
|
33
|
+
if (entry.type === "none") return null;
|
|
34
|
+
return createVNode("li", {
|
|
35
|
+
"key": `legend-item-${index}`,
|
|
36
|
+
"class": "v-charts-legend-item",
|
|
37
|
+
"style": getItemStyle(layout),
|
|
38
|
+
"tabindex": 0,
|
|
39
|
+
"role": "button",
|
|
40
|
+
"aria-label": `Toggle ${formatValue(entry)} series`,
|
|
41
|
+
"onClick": () => handleClick(entry, index),
|
|
42
|
+
"onKeydown": (e) => {
|
|
43
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
handleClick(entry, index);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"onMouseenter": () => handleMouseEnter(entry, index),
|
|
49
|
+
"onMouseleave": () => handleMouseLeave(entry, index)
|
|
50
|
+
}, [createVNode(Surface, {
|
|
51
|
+
"width": iconSize,
|
|
52
|
+
"height": iconSize,
|
|
53
|
+
"viewBox": {
|
|
54
|
+
x: 0,
|
|
55
|
+
y: 0,
|
|
56
|
+
width: 32,
|
|
57
|
+
height: 32
|
|
58
|
+
},
|
|
59
|
+
"style": getSvgStyle(),
|
|
60
|
+
"aria-label": `${formatValue(entry)} legend icon`
|
|
61
|
+
}, { default: () => [createVNode(LegendSymbol, {
|
|
62
|
+
"type": props.iconType ?? entry.type,
|
|
63
|
+
"color": entry.inactive ? "#a3a3a3" : entry.color,
|
|
64
|
+
"size": iconSize,
|
|
65
|
+
"data": entry
|
|
66
|
+
}, null)] }), createVNode("span", {
|
|
67
|
+
"class": "v-charts-legend-item-text",
|
|
68
|
+
"style": { color: entry.inactive ? "#a3a3a3" : entry.color }
|
|
69
|
+
}, [formatValue(entry)])]);
|
|
70
|
+
})]);
|
|
71
|
+
};
|
|
72
|
+
const renderContent = () => {
|
|
73
|
+
if (!processedPayload.value || processedPayload.value.length === 0) return null;
|
|
74
|
+
const contentProps = {
|
|
75
|
+
...props,
|
|
76
|
+
payload: processedPayload.value
|
|
77
|
+
};
|
|
78
|
+
if (slots.content) return slots.content(contentProps);
|
|
79
|
+
return renderDefaultContent();
|
|
80
|
+
};
|
|
81
|
+
return () => {
|
|
82
|
+
if (legendPortal.value == null) return null;
|
|
83
|
+
const legendElement = createVNode("div", {
|
|
84
|
+
"class": "v-charts-legend-wrapper",
|
|
85
|
+
"style": outerStyle.value,
|
|
86
|
+
"ref": legendRef
|
|
87
|
+
}, [renderContent()]);
|
|
88
|
+
return createVNode("foreignObject", null, [createVNode(Teleport, { "to": legendPortal.value }, _isSlot(legendElement) ? legendElement : { default: () => [legendElement] })]);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
//#endregion
|
|
93
|
+
export { Legend_default as default };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Symbols } from "../../shape/Symbols.mjs";
|
|
2
|
+
import { createVNode, defineComponent } from "vue";
|
|
3
|
+
var LegendSymbol = /* @__PURE__ */ defineComponent({
|
|
4
|
+
name: "LegendSymbol",
|
|
5
|
+
props: {
|
|
6
|
+
type: String,
|
|
7
|
+
color: String,
|
|
8
|
+
size: {
|
|
9
|
+
type: Number,
|
|
10
|
+
default: 14
|
|
11
|
+
},
|
|
12
|
+
data: { type: Object }
|
|
13
|
+
},
|
|
14
|
+
setup(props) {
|
|
15
|
+
return () => {
|
|
16
|
+
const { type, color, data } = props;
|
|
17
|
+
if (type === "none") return null;
|
|
18
|
+
const halfSize = 32 / 2;
|
|
19
|
+
const thirdSize = 32 / 3;
|
|
20
|
+
const sixthSize = 32 / 6;
|
|
21
|
+
switch (type) {
|
|
22
|
+
case "line": return createVNode("path", {
|
|
23
|
+
"stroke-width": 4,
|
|
24
|
+
"fill": "none",
|
|
25
|
+
"stroke": color,
|
|
26
|
+
"d": `M0,${halfSize}h${thirdSize}
|
|
27
|
+
A${sixthSize},${sixthSize},0,1,1,${2 * thirdSize},${halfSize}
|
|
28
|
+
H32M${2 * thirdSize},${halfSize}
|
|
29
|
+
A${sixthSize},${sixthSize},0,1,1,${thirdSize},${halfSize}`,
|
|
30
|
+
"class": "v-charts-legend-icon"
|
|
31
|
+
}, null);
|
|
32
|
+
case "plainline": return createVNode("line", {
|
|
33
|
+
"stroke-width": 4,
|
|
34
|
+
"fill": "none",
|
|
35
|
+
"stroke": color,
|
|
36
|
+
"stroke-dasharray": data?.payload?.strokeDasharray,
|
|
37
|
+
"x1": 0,
|
|
38
|
+
"y1": halfSize,
|
|
39
|
+
"x2": 32,
|
|
40
|
+
"y2": halfSize,
|
|
41
|
+
"class": "v-charts-legend-icon"
|
|
42
|
+
}, null);
|
|
43
|
+
case "rect": return createVNode("path", {
|
|
44
|
+
"stroke": "none",
|
|
45
|
+
"fill": color,
|
|
46
|
+
"d": `M0,${32 / 8}h32v${96 / 4}h-32z`,
|
|
47
|
+
"class": "v-charts-legend-icon"
|
|
48
|
+
}, null);
|
|
49
|
+
default: return createVNode(Symbols, {
|
|
50
|
+
"fill": color,
|
|
51
|
+
"cx": halfSize,
|
|
52
|
+
"cy": halfSize,
|
|
53
|
+
"size": 32,
|
|
54
|
+
"sizeType": "diameter",
|
|
55
|
+
"type": type
|
|
56
|
+
}, null);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
//#endregion
|
|
62
|
+
export { LegendSymbol };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { selectLegendPayload } from "../../../state/selectors/legendSelectors.mjs";
|
|
2
|
+
import { useAppDispatch, useAppSelector } from "../../../state/hooks.mjs";
|
|
3
|
+
import { useChartHeight, useChartWidth, useMargin } from "../../../context/chartLayoutContext.mjs";
|
|
4
|
+
import { setLegendSettings, setLegendSize } from "../../../state/legendSlice.mjs";
|
|
5
|
+
import { useLegendPortal } from "../../../chart/LegendPortalContext.mjs";
|
|
6
|
+
import { getUniqPayload } from "../../../utils/payload/getUniqPayload.mjs";
|
|
7
|
+
import { defaultUniqBy, getDefaultPosition, getWidthOrHeight } from "../utils.mjs";
|
|
8
|
+
import { computed, ref } from "vue";
|
|
9
|
+
import { sortBy } from "es-toolkit/compat";
|
|
10
|
+
import { useElementBounding } from "@vueuse/core";
|
|
11
|
+
//#region src/components/legend/hooks/useLegend.ts
|
|
12
|
+
function useLegend(props) {
|
|
13
|
+
const dispatch = useAppDispatch();
|
|
14
|
+
const contextPayload = useAppSelector(selectLegendPayload);
|
|
15
|
+
const legendPortalFromContext = useLegendPortal();
|
|
16
|
+
const margin = useMargin();
|
|
17
|
+
const chartWidth = useChartWidth();
|
|
18
|
+
const chartHeight = useChartHeight();
|
|
19
|
+
const legendRef = ref();
|
|
20
|
+
const { width: boundingWidth, height: boundingHeight } = useElementBounding(legendRef);
|
|
21
|
+
const maxWidth = computed(() => chartWidth.value - (margin.value.left || 0) - (margin.value.right || 0));
|
|
22
|
+
const widthOrHeight = computed(() => getWidthOrHeight(props.layout, props.height, props.width, maxWidth.value));
|
|
23
|
+
const boundingBox = computed(() => ({
|
|
24
|
+
width: boundingWidth.value,
|
|
25
|
+
height: boundingHeight.value
|
|
26
|
+
}));
|
|
27
|
+
const processedPayload = computed(() => {
|
|
28
|
+
if (!contextPayload.value || contextPayload.value.length === 0) return [];
|
|
29
|
+
let finalPayload = getUniqPayload(contextPayload.value, props.payloadUniqBy, defaultUniqBy);
|
|
30
|
+
if (props.itemSorter) {
|
|
31
|
+
if (typeof props.itemSorter === "string") finalPayload = sortBy(finalPayload, props.itemSorter);
|
|
32
|
+
else if (typeof props.itemSorter === "function") finalPayload = sortBy(finalPayload, props.itemSorter);
|
|
33
|
+
}
|
|
34
|
+
return Array.from(finalPayload);
|
|
35
|
+
});
|
|
36
|
+
const outerStyle = computed(() => {
|
|
37
|
+
if (props.portal) return props.wrapperStyle || {};
|
|
38
|
+
const baseStyle = {
|
|
39
|
+
position: "absolute",
|
|
40
|
+
width: widthOrHeight.value?.width ? `${widthOrHeight.value.width}px` : props.width ? `${props.width}px` : "auto",
|
|
41
|
+
height: widthOrHeight.value?.height ? `${widthOrHeight.value.height}px` : props.height ? `${props.height}px` : "auto"
|
|
42
|
+
};
|
|
43
|
+
const positionStyle = getDefaultPosition(props.wrapperStyle, props, margin.value, chartWidth.value, chartHeight.value, boundingBox.value);
|
|
44
|
+
return Object.assign({}, baseStyle, positionStyle, props.wrapperStyle || {});
|
|
45
|
+
});
|
|
46
|
+
const legendPortal = computed(() => props.portal ?? legendPortalFromContext?.value);
|
|
47
|
+
const syncSettings = () => {
|
|
48
|
+
dispatch(setLegendSettings({
|
|
49
|
+
layout: props.layout,
|
|
50
|
+
align: props.align,
|
|
51
|
+
verticalAlign: props.verticalAlign
|
|
52
|
+
}));
|
|
53
|
+
};
|
|
54
|
+
const syncSize = () => {
|
|
55
|
+
dispatch(setLegendSize({
|
|
56
|
+
width: boundingBox.value.width,
|
|
57
|
+
height: boundingBox.value.height
|
|
58
|
+
}));
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
legendRef,
|
|
62
|
+
boundingBox,
|
|
63
|
+
widthOrHeight,
|
|
64
|
+
processedPayload,
|
|
65
|
+
outerStyle,
|
|
66
|
+
legendPortal,
|
|
67
|
+
syncSettings,
|
|
68
|
+
syncSize
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { useLegend };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//#region src/components/legend/hooks/useLegendContent.ts
|
|
2
|
+
function useLegendContent(props) {
|
|
3
|
+
const getWrapperStyle = (layout = "horizontal", align = "center", verticalAlign = "bottom") => {
|
|
4
|
+
return {
|
|
5
|
+
display: "flex",
|
|
6
|
+
flexDirection: layout === "horizontal" ? "row" : "column",
|
|
7
|
+
justifyContent: align === "left" ? "flex-start" : align === "right" ? "flex-end" : "center",
|
|
8
|
+
alignItems: verticalAlign === "top" ? "flex-start" : verticalAlign === "bottom" ? "flex-end" : "center",
|
|
9
|
+
flexWrap: "wrap",
|
|
10
|
+
gap: "8px",
|
|
11
|
+
...props.wrapperStyle || {}
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
const getContentStyle = (layout = "horizontal") => {
|
|
15
|
+
return {
|
|
16
|
+
display: "flex",
|
|
17
|
+
flexDirection: layout === "horizontal" ? "row" : "column",
|
|
18
|
+
gap: layout === "horizontal" ? "16px" : "8px",
|
|
19
|
+
...props.contentStyle || {}
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const getItemStyle = (layout = "horizontal") => {
|
|
23
|
+
return {
|
|
24
|
+
display: layout === "horizontal" ? "inline-block" : "block",
|
|
25
|
+
marginRight: "10px"
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const getViewBox = () => {
|
|
29
|
+
return {
|
|
30
|
+
x: 0,
|
|
31
|
+
y: 0,
|
|
32
|
+
width: 32,
|
|
33
|
+
height: 32
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const getSvgStyle = () => {
|
|
37
|
+
return {
|
|
38
|
+
display: "inline-block",
|
|
39
|
+
verticalAlign: "middle",
|
|
40
|
+
marginRight: "4px"
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const formatValue = (entry) => {
|
|
44
|
+
return props.formatter ? props.formatter(entry.value, entry) : entry.value;
|
|
45
|
+
};
|
|
46
|
+
const handleClick = (entry, index) => {
|
|
47
|
+
props.onClick?.(entry, index);
|
|
48
|
+
};
|
|
49
|
+
const handleMouseEnter = (entry, index) => {
|
|
50
|
+
props.onMouseEnter?.(entry, index);
|
|
51
|
+
};
|
|
52
|
+
const handleMouseLeave = (entry, index) => {
|
|
53
|
+
props.onMouseLeave?.(entry, index);
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
getWrapperStyle,
|
|
57
|
+
getContentStyle,
|
|
58
|
+
getItemStyle,
|
|
59
|
+
getViewBox,
|
|
60
|
+
getSvgStyle,
|
|
61
|
+
formatValue,
|
|
62
|
+
handleClick,
|
|
63
|
+
handleMouseEnter,
|
|
64
|
+
handleMouseLeave
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { useLegendContent };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/components/legend/type.ts
|
|
2
|
+
var LegendVueProps = {
|
|
3
|
+
layout: {
|
|
4
|
+
type: String,
|
|
5
|
+
default: "horizontal"
|
|
6
|
+
},
|
|
7
|
+
align: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: "center"
|
|
10
|
+
},
|
|
11
|
+
verticalAlign: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: "bottom"
|
|
14
|
+
},
|
|
15
|
+
width: Number,
|
|
16
|
+
height: Number,
|
|
17
|
+
iconSize: {
|
|
18
|
+
type: Number,
|
|
19
|
+
default: 14
|
|
20
|
+
},
|
|
21
|
+
iconType: String,
|
|
22
|
+
wrapperStyle: Object,
|
|
23
|
+
contentStyle: Object,
|
|
24
|
+
itemStyle: Object,
|
|
25
|
+
formatter: Function,
|
|
26
|
+
onClick: Function,
|
|
27
|
+
onMouseEnter: Function,
|
|
28
|
+
onMouseLeave: Function,
|
|
29
|
+
margin: Object,
|
|
30
|
+
chartWidth: Number,
|
|
31
|
+
chartHeight: Number,
|
|
32
|
+
payloadUniqBy: [Boolean, Function],
|
|
33
|
+
itemSorter: {
|
|
34
|
+
type: [String, Function],
|
|
35
|
+
default: "value"
|
|
36
|
+
},
|
|
37
|
+
portal: Object,
|
|
38
|
+
onBBoxUpdate: Function
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { LegendVueProps };
|