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,29 +1,32 @@
|
|
|
1
|
-
import { Layer
|
|
2
|
-
import { useBarContext
|
|
3
|
-
import { Rectangle
|
|
4
|
-
import { Fragment
|
|
1
|
+
import { Layer } from "../../../container/Layer.mjs";
|
|
2
|
+
import { useBarContext } from "../hooks/useBar.mjs";
|
|
3
|
+
import { Rectangle } from "../../../shape/Rectangle.mjs";
|
|
4
|
+
import { Fragment, createVNode, defineComponent } from "vue";
|
|
5
5
|
//#region src/cartesian/bar/components/BarBackground.tsx
|
|
6
|
-
var
|
|
6
|
+
var BarBackground = /* @__PURE__ */ defineComponent({
|
|
7
7
|
name: "BarBackground",
|
|
8
|
-
inheritAttrs:
|
|
9
|
-
setup(
|
|
10
|
-
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
setup(_, { attrs }) {
|
|
10
|
+
const { props, data: barData } = useBarContext();
|
|
11
11
|
return () => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
const data = barData.value;
|
|
13
|
+
const backgroundFromProps = props.background;
|
|
14
|
+
if (!backgroundFromProps || !data) return null;
|
|
15
|
+
return createVNode(Fragment, null, [data.map((entry, i) => {
|
|
16
|
+
const { value, background: backgroundFromDataEntry, tooltipPosition, ...rest } = entry;
|
|
17
|
+
if (!backgroundFromDataEntry) return null;
|
|
18
|
+
const backgroundObjectProps = typeof backgroundFromProps === "object" ? backgroundFromProps : {};
|
|
19
|
+
const barRectangleProps = {
|
|
20
|
+
option: backgroundFromProps,
|
|
21
|
+
...rest,
|
|
19
22
|
fill: "#eee",
|
|
20
|
-
...
|
|
21
|
-
...
|
|
23
|
+
...backgroundFromDataEntry,
|
|
24
|
+
...backgroundObjectProps
|
|
22
25
|
};
|
|
23
|
-
return
|
|
26
|
+
return createVNode(Layer, { "key": `background-bar-${i}` }, { default: () => [createVNode(Rectangle, barRectangleProps, null)] });
|
|
24
27
|
})]);
|
|
25
28
|
};
|
|
26
29
|
}
|
|
27
30
|
});
|
|
28
31
|
//#endregion
|
|
29
|
-
export {
|
|
32
|
+
export { BarBackground };
|
|
@@ -1,106 +1,143 @@
|
|
|
1
|
-
import { mouseLeaveItem
|
|
2
|
-
import { selectActiveTooltipDataKey
|
|
3
|
-
import { useAppDispatch
|
|
4
|
-
import { filterProps
|
|
5
|
-
import { Layer
|
|
6
|
-
import { Animate
|
|
7
|
-
import { useBarContext
|
|
8
|
-
import { Rectangle
|
|
9
|
-
import { Fragment
|
|
1
|
+
import { mouseLeaveItem, setActiveClickItemIndex, setActiveMouseOverItemIndex } from "../../../state/tooltipSlice.mjs";
|
|
2
|
+
import { selectActiveTooltipDataKey, selectActiveTooltipIndex } from "../../../state/selectors/tooltipSelectors.mjs";
|
|
3
|
+
import { useAppDispatch, useAppSelector } from "../../../state/hooks.mjs";
|
|
4
|
+
import { filterProps } from "../../../utils/VueUtils.mjs";
|
|
5
|
+
import { Layer } from "../../../container/Layer.mjs";
|
|
6
|
+
import { Animate } from "../../../animation/Animate.mjs";
|
|
7
|
+
import { useBarContext } from "../hooks/useBar.mjs";
|
|
8
|
+
import { Rectangle } from "../../../shape/Rectangle.mjs";
|
|
9
|
+
import { Fragment, createVNode, defineComponent, isVNode } from "vue";
|
|
10
10
|
//#region src/cartesian/bar/components/BarRectangles.tsx
|
|
11
|
-
function
|
|
12
|
-
return typeof
|
|
11
|
+
function _isSlot(s) {
|
|
12
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
13
13
|
}
|
|
14
|
-
var
|
|
14
|
+
var BarRectangles = /* @__PURE__ */ defineComponent({
|
|
15
15
|
name: "BarRectangles",
|
|
16
|
-
inheritAttrs:
|
|
17
|
-
setup(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
inheritAttrs: false,
|
|
17
|
+
setup(_) {
|
|
18
|
+
const dispatch = useAppDispatch();
|
|
19
|
+
const activeIndex = useAppSelector(selectActiveTooltipIndex);
|
|
20
|
+
const activeDataKey = useAppSelector(selectActiveTooltipDataKey);
|
|
21
|
+
let previousRectangles = null;
|
|
22
|
+
let animationId = 0;
|
|
23
|
+
const { props, data: barData, layout, isAnimating, shapeSlot, activeBarSlot, cellProps } = useBarContext();
|
|
24
|
+
const { dataKey, isAnimationActive, onAnimationStart, onAnimationEnd, activeBar, activeIndex: activeIndexProp } = props;
|
|
25
|
+
const onMouseEnterFromContext = (entry, index) => (e) => {
|
|
26
|
+
dispatch(setActiveMouseOverItemIndex({
|
|
27
|
+
activeDataKey: dataKey,
|
|
28
|
+
activeIndex: String(index),
|
|
22
29
|
activeCoordinate: {
|
|
23
|
-
x:
|
|
24
|
-
y:
|
|
30
|
+
x: entry.tooltipPosition.x,
|
|
31
|
+
y: entry.tooltipPosition.y
|
|
25
32
|
}
|
|
26
33
|
}));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
};
|
|
35
|
+
const onMouseLeaveFromContext = (entry, index) => (e) => {
|
|
36
|
+
dispatch(mouseLeaveItem());
|
|
37
|
+
};
|
|
38
|
+
const onClickFromContext = (entry, index) => (e) => {
|
|
39
|
+
dispatch(setActiveClickItemIndex({
|
|
40
|
+
activeDataKey: dataKey,
|
|
41
|
+
activeIndex: String(index),
|
|
33
42
|
activeCoordinate: {
|
|
34
|
-
x:
|
|
35
|
-
y:
|
|
43
|
+
x: entry.tooltipPosition.x,
|
|
44
|
+
y: entry.tooltipPosition.y
|
|
36
45
|
}
|
|
37
46
|
}));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
};
|
|
48
|
+
const baseProps = filterProps(props, false);
|
|
49
|
+
const interpolateNumber = (from, to) => (t) => from + (to - from) * t;
|
|
50
|
+
const renderRectangles = (data) => {
|
|
51
|
+
if (!data) return null;
|
|
52
|
+
return createVNode(Fragment, null, [data.map((entry, i) => {
|
|
53
|
+
let _slot;
|
|
54
|
+
const activeEnabled = activeBar !== false || activeIndexProp != null || !!activeBarSlot;
|
|
55
|
+
const isActive = activeIndexProp != null ? activeEnabled && i === activeIndexProp : activeEnabled && String(i) === activeIndex.value && (activeDataKey.value == null || dataKey === activeDataKey.value);
|
|
56
|
+
const activeBarProps = isActive && typeof activeBar === "object" ? activeBar : {};
|
|
57
|
+
const entryFill = entry.payload?.fill;
|
|
58
|
+
const cellPropsForIndex = cellProps.value?.[i];
|
|
59
|
+
const barRectangleProps = {
|
|
60
|
+
...baseProps,
|
|
61
|
+
...entryFill ? { fill: entryFill } : {},
|
|
62
|
+
...entry,
|
|
63
|
+
...cellPropsForIndex ?? {},
|
|
64
|
+
...isActive ? activeBarProps : {},
|
|
65
|
+
isActive,
|
|
66
|
+
index: i,
|
|
67
|
+
dataKey
|
|
68
|
+
};
|
|
69
|
+
const renderShape = () => {
|
|
70
|
+
if (isActive && activeBarSlot) return activeBarSlot(barRectangleProps);
|
|
71
|
+
if (shapeSlot) return shapeSlot(barRectangleProps);
|
|
72
|
+
return createVNode(Rectangle, barRectangleProps, null);
|
|
73
|
+
};
|
|
74
|
+
return createVNode(Layer, {
|
|
75
|
+
"key": `rectangle-${entry?.x}-${entry?.y}-${entry?.value}-${i}`,
|
|
76
|
+
"class": "v-charts-bar-rectangle",
|
|
77
|
+
"onMouseenter": onMouseEnterFromContext(entry, i),
|
|
78
|
+
"onMouseleave": onMouseLeaveFromContext(entry, i),
|
|
79
|
+
"onClick": onClickFromContext(entry, i)
|
|
80
|
+
}, _isSlot(_slot = renderShape()) ? _slot : { default: () => [_slot] });
|
|
81
|
+
})]);
|
|
82
|
+
};
|
|
57
83
|
return () => {
|
|
58
|
-
|
|
59
|
-
if (!
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
84
|
+
const data = barData.value;
|
|
85
|
+
if (!data) return null;
|
|
86
|
+
if (isAnimationActive && previousRectangles !== data) {
|
|
87
|
+
const prevData = previousRectangles;
|
|
88
|
+
animationId++;
|
|
89
|
+
isAnimating.value = true;
|
|
90
|
+
return createVNode(Animate, {
|
|
91
|
+
"key": animationId,
|
|
92
|
+
"transition": props.transition,
|
|
93
|
+
"isActive": isAnimationActive,
|
|
94
|
+
"onAnimationStart": onAnimationStart,
|
|
95
|
+
"onAnimationEnd": () => {
|
|
96
|
+
isAnimating.value = false;
|
|
97
|
+
onAnimationEnd?.();
|
|
69
98
|
}
|
|
70
|
-
}, { default: (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
|
|
99
|
+
}, { default: (t) => {
|
|
100
|
+
const stepData = t === 1 ? data : data.map((entry, index) => {
|
|
101
|
+
const prev = prevData?.[index];
|
|
102
|
+
if (prev && prev.stackedBarStart === entry.stackedBarStart) {
|
|
103
|
+
const interpolatorX = interpolateNumber(prev.x || 0, entry.x || 0);
|
|
104
|
+
const interpolatorY = interpolateNumber(prev.y || 0, entry.y || 0);
|
|
105
|
+
const interpolatorWidth = interpolateNumber(prev.width, entry.width);
|
|
106
|
+
const interpolatorHeight = interpolateNumber(prev.height, entry.height);
|
|
75
107
|
return {
|
|
76
|
-
...
|
|
77
|
-
x: t
|
|
78
|
-
y:
|
|
79
|
-
width:
|
|
80
|
-
height:
|
|
108
|
+
...entry,
|
|
109
|
+
x: interpolatorX(t),
|
|
110
|
+
y: interpolatorY(t),
|
|
111
|
+
width: interpolatorWidth(t),
|
|
112
|
+
height: interpolatorHeight(t)
|
|
81
113
|
};
|
|
82
114
|
}
|
|
83
|
-
if (
|
|
84
|
-
|
|
115
|
+
if (layout.value === "horizontal") {
|
|
116
|
+
const h = interpolateNumber(0, entry.height)(t);
|
|
117
|
+
const y = interpolateNumber(entry.stackedBarStart, entry.y)(t);
|
|
85
118
|
return {
|
|
86
|
-
...
|
|
87
|
-
y
|
|
88
|
-
height:
|
|
119
|
+
...entry,
|
|
120
|
+
y,
|
|
121
|
+
height: h
|
|
89
122
|
};
|
|
90
123
|
}
|
|
91
|
-
|
|
124
|
+
const w = interpolateNumber(0, entry.width)(t);
|
|
125
|
+
const x = interpolateNumber(entry.stackedBarStart, entry.x)(t);
|
|
92
126
|
return {
|
|
93
|
-
...
|
|
94
|
-
width:
|
|
95
|
-
x
|
|
127
|
+
...entry,
|
|
128
|
+
width: w,
|
|
129
|
+
x
|
|
96
130
|
};
|
|
97
131
|
});
|
|
98
|
-
|
|
132
|
+
if (t > 0) previousRectangles = stepData;
|
|
133
|
+
return createVNode("g", null, [renderRectangles(stepData)]);
|
|
99
134
|
} });
|
|
100
135
|
}
|
|
101
|
-
|
|
136
|
+
isAnimating.value = false;
|
|
137
|
+
previousRectangles = data;
|
|
138
|
+
return createVNode("g", null, [renderRectangles(data)]);
|
|
102
139
|
};
|
|
103
140
|
}
|
|
104
141
|
});
|
|
105
142
|
//#endregion
|
|
106
|
-
export {
|
|
143
|
+
export { BarRectangles };
|
|
@@ -1,41 +1,53 @@
|
|
|
1
|
-
import { uniqueId
|
|
2
|
-
import { useIsPanorama
|
|
3
|
-
import { getNormalizedStackId
|
|
4
|
-
import { useAppSelector
|
|
5
|
-
import { useChartLayout
|
|
6
|
-
import { useNeedsClip
|
|
7
|
-
import { selectBarRectangles
|
|
8
|
-
import { computed
|
|
9
|
-
import { createContext
|
|
1
|
+
import { uniqueId } from "../../../utils/data-utils.mjs";
|
|
2
|
+
import { useIsPanorama } from "../../../context/PanoramaContextProvider.mjs";
|
|
3
|
+
import { getNormalizedStackId } from "../../../utils/chart.mjs";
|
|
4
|
+
import { useAppSelector } from "../../../state/hooks.mjs";
|
|
5
|
+
import { useChartLayout } from "../../../context/chartLayoutContext.mjs";
|
|
6
|
+
import { useNeedsClip } from "../../useNeedsClip.mjs";
|
|
7
|
+
import { selectBarRectangles } from "../../../state/selectors/barSelectors.mjs";
|
|
8
|
+
import { computed, ref, shallowRef, useAttrs } from "vue";
|
|
9
|
+
import { createContext } from "motion-v";
|
|
10
10
|
//#region src/cartesian/bar/hooks/useBar.ts
|
|
11
|
-
var [
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
11
|
+
var [useBarContext, provideBarContext] = createContext("BarContext");
|
|
12
|
+
function useBar(props, shapeSlot, activeBarSlot) {
|
|
13
|
+
const isPanorama = useIsPanorama();
|
|
14
|
+
const attrs = useAttrs();
|
|
15
|
+
const layout = useChartLayout();
|
|
16
|
+
const { needClip } = useNeedsClip(props.xAxisId, props.yAxisId);
|
|
17
|
+
const barSettings = computed(() => ({
|
|
18
|
+
barSize: props.barSize,
|
|
19
|
+
data: props.data,
|
|
20
|
+
dataKey: props.dataKey,
|
|
21
|
+
maxBarSize: props.maxBarSize,
|
|
22
|
+
minPointSize: props.minPointSize,
|
|
23
|
+
stackId: getNormalizedStackId(props.stackId)
|
|
24
|
+
}));
|
|
25
|
+
const rects = useAppSelector((state) => selectBarRectangles(state, props.xAxisId, props.yAxisId, isPanorama, barSettings.value));
|
|
26
|
+
const shouldRender = computed(() => {
|
|
27
|
+
return (layout.value === "vertical" || layout.value === "horizontal") && !props.hide;
|
|
28
|
+
});
|
|
29
|
+
const clipPathId = uniqueId("v-charts-bar-");
|
|
30
|
+
const isAnimating = ref(false);
|
|
31
|
+
const cellPropsRef = shallowRef([]);
|
|
32
|
+
provideBarContext({
|
|
33
|
+
clipPathId,
|
|
34
|
+
layout,
|
|
35
|
+
props,
|
|
36
|
+
attrs,
|
|
37
|
+
data: rects,
|
|
38
|
+
isAnimating,
|
|
39
|
+
shapeSlot,
|
|
40
|
+
activeBarSlot,
|
|
41
|
+
cellProps: cellPropsRef
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
shouldRender,
|
|
45
|
+
needClip,
|
|
46
|
+
clipPathId,
|
|
47
|
+
barData: rects,
|
|
48
|
+
isAnimating,
|
|
49
|
+
cellProps: cellPropsRef
|
|
38
50
|
};
|
|
39
51
|
}
|
|
40
52
|
//#endregion
|
|
41
|
-
export {
|
|
53
|
+
export { useBar, useBarContext };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import { classProp } from "../../types/common.mjs";
|
|
1
2
|
//#region src/cartesian/bar/type.ts
|
|
2
|
-
var
|
|
3
|
-
class:
|
|
4
|
-
type: String,
|
|
5
|
-
default: void 0
|
|
6
|
-
},
|
|
3
|
+
var BarVueProps = {
|
|
4
|
+
class: classProp,
|
|
7
5
|
barSize: { type: [String, Number] },
|
|
8
6
|
data: {
|
|
9
7
|
type: Array,
|
|
@@ -15,7 +13,7 @@ var e = {
|
|
|
15
13
|
Number,
|
|
16
14
|
Function
|
|
17
15
|
],
|
|
18
|
-
required:
|
|
16
|
+
required: true
|
|
19
17
|
},
|
|
20
18
|
fill: {
|
|
21
19
|
type: String,
|
|
@@ -49,11 +47,11 @@ var e = {
|
|
|
49
47
|
maxBarSize: { type: Number },
|
|
50
48
|
hide: {
|
|
51
49
|
type: Boolean,
|
|
52
|
-
default:
|
|
50
|
+
default: false
|
|
53
51
|
},
|
|
54
52
|
background: {
|
|
55
53
|
type: [Boolean, Object],
|
|
56
|
-
default:
|
|
54
|
+
default: false
|
|
57
55
|
},
|
|
58
56
|
radius: {
|
|
59
57
|
type: [Number, Array],
|
|
@@ -69,7 +67,7 @@ var e = {
|
|
|
69
67
|
},
|
|
70
68
|
isAnimationActive: {
|
|
71
69
|
type: Boolean,
|
|
72
|
-
default:
|
|
70
|
+
default: true
|
|
73
71
|
},
|
|
74
72
|
activeBar: {
|
|
75
73
|
type: [
|
|
@@ -77,7 +75,7 @@ var e = {
|
|
|
77
75
|
Boolean,
|
|
78
76
|
Function
|
|
79
77
|
],
|
|
80
|
-
default:
|
|
78
|
+
default: false
|
|
81
79
|
},
|
|
82
80
|
activeIndex: {
|
|
83
81
|
type: Number,
|
|
@@ -99,18 +97,6 @@ var e = {
|
|
|
99
97
|
type: [String, Number],
|
|
100
98
|
default: 0
|
|
101
99
|
},
|
|
102
|
-
animationBegin: {
|
|
103
|
-
type: Number,
|
|
104
|
-
default: 0
|
|
105
|
-
},
|
|
106
|
-
animationDuration: {
|
|
107
|
-
type: Number,
|
|
108
|
-
default: 1500
|
|
109
|
-
},
|
|
110
|
-
animationEasing: {
|
|
111
|
-
type: String,
|
|
112
|
-
default: "ease"
|
|
113
|
-
},
|
|
114
100
|
transition: {
|
|
115
101
|
type: Object,
|
|
116
102
|
default: {
|
|
@@ -120,12 +106,12 @@ var e = {
|
|
|
120
106
|
},
|
|
121
107
|
needClip: {
|
|
122
108
|
type: Boolean,
|
|
123
|
-
default:
|
|
109
|
+
default: false
|
|
124
110
|
},
|
|
125
111
|
label: {
|
|
126
112
|
type: [Boolean, Object],
|
|
127
|
-
default:
|
|
113
|
+
default: false
|
|
128
114
|
}
|
|
129
115
|
};
|
|
130
116
|
//#endregion
|
|
131
|
-
export {
|
|
117
|
+
export { BarVueProps };
|
|
@@ -1,84 +1,111 @@
|
|
|
1
|
-
import { isNullish
|
|
2
|
-
import { mathSign
|
|
3
|
-
import { getBaseValueOfBar
|
|
4
|
-
import { toRaw
|
|
5
|
-
import { isNaN
|
|
6
|
-
import { invariant
|
|
1
|
+
import { isNullish, isNumber } from "../../utils/validate.mjs";
|
|
2
|
+
import { mathSign } from "../../utils/data.mjs";
|
|
3
|
+
import { getBaseValueOfBar, getCateCoordinateOfBar, getValueByDataKey, truncateByDomain } from "../../utils/chart.mjs";
|
|
4
|
+
import { toRaw } from "vue";
|
|
5
|
+
import { isNaN } from "es-toolkit/compat";
|
|
6
|
+
import { invariant } from "es-toolkit";
|
|
7
7
|
//#region src/cartesian/bar/utils.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Safely gets minPointSize from the minPointSize prop if it is a function
|
|
10
|
+
* @param minPointSize minPointSize as passed to the Bar component
|
|
11
|
+
* @param defaultValue default minPointSize
|
|
12
|
+
* @returns minPointSize
|
|
13
|
+
*/
|
|
14
|
+
function minPointSizeCallback(minPointSize, defaultValue = 0) {
|
|
15
|
+
return (value, index) => {
|
|
16
|
+
if (isNumber(minPointSize)) return minPointSize;
|
|
17
|
+
const isValueNumberOrNil = isNumber(value) || isNullish(value);
|
|
18
|
+
if (isValueNumberOrNil) return minPointSize(value, index);
|
|
19
|
+
invariant(isValueNumberOrNil, `minPointSize callback function received a value with type of ${typeof value}. Currently only numbers or null/undefined are supported.`);
|
|
20
|
+
return defaultValue;
|
|
13
21
|
};
|
|
14
22
|
}
|
|
15
|
-
var
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
x:
|
|
19
|
-
y:
|
|
20
|
-
width:
|
|
21
|
-
height:
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
23
|
+
var defaultMinPointSize = 0;
|
|
24
|
+
function computeBarRectangles({ layout, barSettings: { dataKey, minPointSize: minPointSizeProp }, pos, bandSize, xAxis, yAxis, xAxisTicks, yAxisTicks, stackedData, displayedData, offset }) {
|
|
25
|
+
const parentViewBox = {
|
|
26
|
+
x: offset.left,
|
|
27
|
+
y: offset.top,
|
|
28
|
+
width: offset.width,
|
|
29
|
+
height: offset.height
|
|
30
|
+
};
|
|
31
|
+
const numericAxis = layout === "horizontal" ? yAxis : xAxis;
|
|
32
|
+
const stackedDomain = stackedData ? numericAxis.scale.domain() : null;
|
|
33
|
+
const baseValue = getBaseValueOfBar({ numericAxis });
|
|
34
|
+
const stackedBarStart = numericAxis.scale(baseValue);
|
|
35
|
+
return displayedData.map((rawEntry, index) => {
|
|
36
|
+
const entry = toRaw(rawEntry);
|
|
37
|
+
let value, x, y, width, height, background;
|
|
38
|
+
if (stackedData) value = truncateByDomain(stackedData[index], stackedDomain);
|
|
39
|
+
else {
|
|
40
|
+
value = getValueByDataKey(entry, dataKey);
|
|
41
|
+
if (!Array.isArray(value)) value = [baseValue, value];
|
|
42
|
+
}
|
|
43
|
+
const minPointSize = minPointSizeCallback(minPointSizeProp, defaultMinPointSize)(value[1], index);
|
|
44
|
+
if (layout === "horizontal") {
|
|
45
|
+
const [baseValueScale, currentValueScale] = [yAxis.scale(value[0]), yAxis.scale(value[1])];
|
|
46
|
+
x = getCateCoordinateOfBar({
|
|
47
|
+
axis: xAxis,
|
|
48
|
+
ticks: xAxisTicks,
|
|
49
|
+
bandSize,
|
|
50
|
+
offset: pos.offset,
|
|
51
|
+
entry,
|
|
52
|
+
index
|
|
53
|
+
});
|
|
54
|
+
y = currentValueScale ?? baseValueScale ?? void 0;
|
|
55
|
+
width = pos.size;
|
|
56
|
+
const computedHeight = baseValueScale - currentValueScale;
|
|
57
|
+
height = isNaN(computedHeight) ? 0 : computedHeight;
|
|
58
|
+
background = {
|
|
59
|
+
x,
|
|
60
|
+
y: offset.top,
|
|
61
|
+
width,
|
|
62
|
+
height: offset.height
|
|
63
|
+
};
|
|
64
|
+
if (Math.abs(minPointSize) > 0 && Math.abs(height) < Math.abs(minPointSize)) {
|
|
65
|
+
const delta = mathSign(height || minPointSize) * (Math.abs(minPointSize) - Math.abs(height));
|
|
66
|
+
y -= delta;
|
|
67
|
+
height += delta;
|
|
46
68
|
}
|
|
47
69
|
} else {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
const [baseValueScale, currentValueScale] = [xAxis.scale(value[0]), xAxis.scale(value[1])];
|
|
71
|
+
x = baseValueScale;
|
|
72
|
+
y = getCateCoordinateOfBar({
|
|
73
|
+
axis: yAxis,
|
|
74
|
+
ticks: yAxisTicks,
|
|
75
|
+
bandSize,
|
|
76
|
+
offset: pos.offset,
|
|
77
|
+
entry,
|
|
78
|
+
index
|
|
79
|
+
});
|
|
80
|
+
width = currentValueScale - baseValueScale;
|
|
81
|
+
height = pos.size;
|
|
82
|
+
background = {
|
|
83
|
+
x: offset.left,
|
|
84
|
+
y,
|
|
85
|
+
width: offset.width,
|
|
86
|
+
height
|
|
87
|
+
};
|
|
88
|
+
if (Math.abs(minPointSize) > 0 && Math.abs(width) < Math.abs(minPointSize)) {
|
|
89
|
+
const delta = mathSign(width || minPointSize) * (Math.abs(minPointSize) - Math.abs(width));
|
|
90
|
+
width += delta;
|
|
64
91
|
}
|
|
65
92
|
}
|
|
66
93
|
return {
|
|
67
|
-
x
|
|
68
|
-
y
|
|
69
|
-
width
|
|
70
|
-
height
|
|
71
|
-
stackedBarStart:
|
|
72
|
-
value:
|
|
73
|
-
payload:
|
|
74
|
-
background
|
|
94
|
+
x,
|
|
95
|
+
y,
|
|
96
|
+
width,
|
|
97
|
+
height,
|
|
98
|
+
stackedBarStart: stackedBarStart ?? 0,
|
|
99
|
+
value: stackedData ? value : value[1],
|
|
100
|
+
payload: entry,
|
|
101
|
+
background,
|
|
75
102
|
tooltipPosition: {
|
|
76
|
-
x:
|
|
77
|
-
y:
|
|
103
|
+
x: x + width / 2,
|
|
104
|
+
y: y + height / 2
|
|
78
105
|
},
|
|
79
|
-
parentViewBox
|
|
106
|
+
parentViewBox
|
|
80
107
|
};
|
|
81
108
|
});
|
|
82
109
|
}
|
|
83
110
|
//#endregion
|
|
84
|
-
export {
|
|
111
|
+
export { computeBarRectangles };
|