@coinbase/cds-mobile-visualization 3.4.0-beta.9 → 3.4.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/CHANGELOG.md +132 -0
- package/dts/chart/CartesianChart.d.ts +92 -7
- package/dts/chart/CartesianChart.d.ts.map +1 -1
- package/dts/chart/ChartContextBridge.d.ts.map +1 -1
- package/dts/chart/ChartProvider.d.ts +3 -0
- package/dts/chart/ChartProvider.d.ts.map +1 -1
- package/dts/chart/Path.d.ts +36 -13
- package/dts/chart/Path.d.ts.map +1 -1
- package/dts/chart/PeriodSelector.d.ts +20 -5
- package/dts/chart/PeriodSelector.d.ts.map +1 -1
- package/dts/chart/area/Area.d.ts +14 -11
- package/dts/chart/area/Area.d.ts.map +1 -1
- package/dts/chart/area/AreaChart.d.ts +33 -9
- package/dts/chart/area/AreaChart.d.ts.map +1 -1
- package/dts/chart/area/DottedArea.d.ts.map +1 -1
- package/dts/chart/area/GradientArea.d.ts.map +1 -1
- package/dts/chart/area/SolidArea.d.ts.map +1 -1
- package/dts/chart/axis/Axis.d.ts +22 -42
- package/dts/chart/axis/Axis.d.ts.map +1 -1
- package/dts/chart/axis/XAxis.d.ts +6 -0
- package/dts/chart/axis/XAxis.d.ts.map +1 -1
- package/dts/chart/axis/YAxis.d.ts +1 -0
- package/dts/chart/axis/YAxis.d.ts.map +1 -1
- package/dts/chart/bar/Bar.d.ts +51 -51
- package/dts/chart/bar/Bar.d.ts.map +1 -1
- package/dts/chart/bar/BarChart.d.ts +56 -11
- package/dts/chart/bar/BarChart.d.ts.map +1 -1
- package/dts/chart/bar/BarPlot.d.ts +2 -1
- package/dts/chart/bar/BarPlot.d.ts.map +1 -1
- package/dts/chart/bar/BarStack.d.ts +45 -20
- package/dts/chart/bar/BarStack.d.ts.map +1 -1
- package/dts/chart/bar/BarStackGroup.d.ts +2 -1
- package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
- package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
- package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
- package/dts/chart/gradient/Gradient.d.ts +5 -0
- package/dts/chart/gradient/Gradient.d.ts.map +1 -1
- package/dts/chart/index.d.ts +1 -0
- package/dts/chart/index.d.ts.map +1 -1
- package/dts/chart/legend/DefaultLegendEntry.d.ts +5 -0
- package/dts/chart/legend/DefaultLegendEntry.d.ts.map +1 -0
- package/dts/chart/legend/DefaultLegendShape.d.ts +5 -0
- package/dts/chart/legend/DefaultLegendShape.d.ts.map +1 -0
- package/dts/chart/legend/Legend.d.ts +168 -0
- package/dts/chart/legend/Legend.d.ts.map +1 -0
- package/dts/chart/legend/index.d.ts +4 -0
- package/dts/chart/legend/index.d.ts.map +1 -0
- package/dts/chart/line/DottedLine.d.ts.map +1 -1
- package/dts/chart/line/Line.d.ts +23 -19
- package/dts/chart/line/Line.d.ts.map +1 -1
- package/dts/chart/line/LineChart.d.ts +26 -9
- package/dts/chart/line/LineChart.d.ts.map +1 -1
- package/dts/chart/line/ReferenceLine.d.ts +1 -0
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
- package/dts/chart/line/SolidLine.d.ts.map +1 -1
- package/dts/chart/point/Point.d.ts +26 -2
- package/dts/chart/point/Point.d.ts.map +1 -1
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +32 -2
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -1
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +2 -1
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -1
- package/dts/chart/scrubber/Scrubber.d.ts +86 -17
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts +12 -0
- package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +10 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +16 -1
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -1
- package/dts/chart/utils/axis.d.ts +45 -10
- package/dts/chart/utils/axis.d.ts.map +1 -1
- package/dts/chart/utils/bar.d.ts +190 -0
- package/dts/chart/utils/bar.d.ts.map +1 -1
- package/dts/chart/utils/chart.d.ts +32 -0
- package/dts/chart/utils/chart.d.ts.map +1 -1
- package/dts/chart/utils/context.d.ts +21 -6
- package/dts/chart/utils/context.d.ts.map +1 -1
- package/dts/chart/utils/gradient.d.ts +3 -1
- package/dts/chart/utils/gradient.d.ts.map +1 -1
- package/dts/chart/utils/path.d.ts +26 -0
- package/dts/chart/utils/path.d.ts.map +1 -1
- package/dts/chart/utils/point.d.ts +24 -12
- package/dts/chart/utils/point.d.ts.map +1 -1
- package/dts/chart/utils/scale.d.ts +11 -0
- package/dts/chart/utils/scale.d.ts.map +1 -1
- package/dts/chart/utils/scrubber.d.ts +2 -1
- package/dts/chart/utils/scrubber.d.ts.map +1 -1
- package/dts/chart/utils/transition.d.ts +63 -22
- package/dts/chart/utils/transition.d.ts.map +1 -1
- package/dts/sparkline/Sparkline.d.ts +2 -1
- package/dts/sparkline/Sparkline.d.ts.map +1 -1
- package/dts/sparkline/SparklineArea.d.ts +2 -1
- package/dts/sparkline/SparklineArea.d.ts.map +1 -1
- package/dts/sparkline/SparklineGradient.d.ts +2 -1
- package/dts/sparkline/SparklineGradient.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +2 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -1
- package/esm/chart/CartesianChart.js +176 -82
- package/esm/chart/ChartContextBridge.js +14 -3
- package/esm/chart/ChartProvider.js +2 -2
- package/esm/chart/Path.js +34 -29
- package/esm/chart/PeriodSelector.js +5 -1
- package/esm/chart/__stories__/CartesianChart.stories.js +16 -80
- package/esm/chart/__stories__/ChartAccessibility.stories.js +721 -0
- package/esm/chart/__stories__/ChartTransitions.stories.js +625 -0
- package/esm/chart/__stories__/PeriodSelector.stories.js +99 -1
- package/esm/chart/area/Area.js +21 -9
- package/esm/chart/area/AreaChart.js +18 -13
- package/esm/chart/area/DottedArea.js +28 -18
- package/esm/chart/area/GradientArea.js +14 -7
- package/esm/chart/area/SolidArea.js +6 -2
- package/esm/chart/area/__stories__/AreaChart.stories.js +47 -5
- package/esm/chart/axis/Axis.js +5 -41
- package/esm/chart/axis/XAxis.js +116 -47
- package/esm/chart/axis/YAxis.js +105 -26
- package/esm/chart/axis/__stories__/Axis.stories.js +324 -48
- package/esm/chart/bar/Bar.js +17 -15
- package/esm/chart/bar/BarChart.js +38 -33
- package/esm/chart/bar/BarPlot.js +40 -45
- package/esm/chart/bar/BarStack.js +92 -475
- package/esm/chart/bar/BarStackGroup.js +37 -27
- package/esm/chart/bar/DefaultBar.js +27 -18
- package/esm/chart/bar/DefaultBarStack.js +25 -9
- package/esm/chart/bar/__stories__/BarChart.stories.js +728 -54
- package/esm/chart/gradient/Gradient.js +2 -1
- package/esm/chart/index.js +1 -0
- package/esm/chart/legend/DefaultLegendEntry.js +42 -0
- package/esm/chart/legend/DefaultLegendShape.js +64 -0
- package/esm/chart/legend/Legend.js +59 -0
- package/esm/chart/legend/__stories__/Legend.stories.js +574 -0
- package/esm/chart/legend/index.js +3 -0
- package/esm/chart/line/DottedLine.js +6 -2
- package/esm/chart/line/Line.js +42 -38
- package/esm/chart/line/LineChart.js +36 -12
- package/esm/chart/line/SolidLine.js +6 -2
- package/esm/chart/line/__stories__/LineChart.stories.js +236 -590
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +95 -1
- package/esm/chart/point/Point.js +35 -36
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +41 -38
- package/esm/chart/scrubber/DefaultScrubberLabel.js +26 -10
- package/esm/chart/scrubber/Scrubber.js +67 -35
- package/esm/chart/scrubber/ScrubberAccessibilityView.js +177 -0
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +30 -22
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +35 -8
- package/esm/chart/scrubber/ScrubberProvider.js +29 -24
- package/esm/chart/scrubber/__stories__/Scrubber.stories.js +946 -0
- package/esm/chart/utils/axis.js +88 -44
- package/esm/chart/utils/bar.js +820 -0
- package/esm/chart/utils/chart.js +34 -7
- package/esm/chart/utils/context.js +7 -0
- package/esm/chart/utils/gradient.js +8 -4
- package/esm/chart/utils/path.js +91 -61
- package/esm/chart/utils/point.js +92 -39
- package/esm/chart/utils/scale.js +13 -2
- package/esm/chart/utils/scrubber.js +12 -5
- package/esm/chart/utils/transition.js +108 -60
- package/esm/sparkline/Sparkline.js +2 -1
- package/esm/sparkline/SparklineArea.js +2 -1
- package/esm/sparkline/SparklineGradient.js +2 -1
- package/esm/sparkline/__figma__/Sparkline.figma.js +1 -1
- package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +2 -1
- package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +1 -1
- package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +1 -1
- package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +2 -0
- package/package.json +5 -6
- package/esm/chart/__stories__/Chart.stories.js +0 -77
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["series", "yAxisId", "stackIndex", "totalStacks", "barPadding"];
|
|
1
|
+
const _excluded = ["series", "xAxisId", "yAxisId", "stackIndex", "totalStacks", "barPadding"];
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
4
|
import { memo, useMemo, createElement as _createElement } from 'react';
|
|
@@ -12,6 +12,7 @@ import { BarStack } from './BarStack';
|
|
|
12
12
|
export const BarStackGroup = /*#__PURE__*/memo(_ref => {
|
|
13
13
|
let {
|
|
14
14
|
series,
|
|
15
|
+
xAxisId = defaultAxisId,
|
|
15
16
|
yAxisId = defaultAxisId,
|
|
16
17
|
stackIndex,
|
|
17
18
|
totalStacks,
|
|
@@ -19,61 +20,70 @@ export const BarStackGroup = /*#__PURE__*/memo(_ref => {
|
|
|
19
20
|
} = _ref,
|
|
20
21
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
21
22
|
const {
|
|
23
|
+
layout,
|
|
22
24
|
getXScale,
|
|
23
25
|
getYScale,
|
|
24
26
|
drawingArea,
|
|
25
27
|
dataLength
|
|
26
28
|
} = useCartesianChartContext();
|
|
27
|
-
const xScale = getXScale();
|
|
29
|
+
const xScale = getXScale(xAxisId);
|
|
28
30
|
const yScale = getYScale(yAxisId);
|
|
29
31
|
const stackConfigs = useMemo(() => {
|
|
30
32
|
if (!xScale || !yScale || !drawingArea || dataLength === 0) return [];
|
|
31
|
-
|
|
33
|
+
const indexScale = layout !== 'horizontal' ? xScale : yScale;
|
|
34
|
+
if (!isCategoricalScale(indexScale)) {
|
|
32
35
|
return [];
|
|
33
36
|
}
|
|
34
|
-
const categoryWidth =
|
|
37
|
+
const categoryWidth = indexScale.bandwidth();
|
|
35
38
|
|
|
36
|
-
// Calculate
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const barWidth = categoryWidth / totalStacks - getBarSizeAdjustment(totalStacks, gapWidth);
|
|
39
|
+
// Calculate thickness for each stack within a category.
|
|
40
|
+
const gapSize = totalStacks > 1 ? categoryWidth * barPadding / (totalStacks - 1) : 0;
|
|
41
|
+
const stackThickness = categoryWidth / totalStacks - getBarSizeAdjustment(totalStacks, gapSize);
|
|
40
42
|
const configs = [];
|
|
41
43
|
|
|
42
|
-
// Calculate position for each category
|
|
43
|
-
// todo: look at using xDomain for this instead of dataLength
|
|
44
|
+
// Calculate position for each category.
|
|
44
45
|
for (let categoryIndex = 0; categoryIndex < dataLength; categoryIndex++) {
|
|
45
|
-
// Get
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
// Calculate
|
|
49
|
-
const
|
|
46
|
+
// Get position for this category along the index axis.
|
|
47
|
+
const categoryPos = indexScale(categoryIndex);
|
|
48
|
+
if (categoryPos !== undefined) {
|
|
49
|
+
// Calculate position for this specific stack within the category.
|
|
50
|
+
const stackPos = categoryPos + stackIndex * (stackThickness + gapSize);
|
|
50
51
|
configs.push({
|
|
51
52
|
categoryIndex,
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
indexPos: stackPos,
|
|
54
|
+
thickness: stackThickness
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
return configs;
|
|
58
|
-
}, [xScale, yScale, drawingArea, dataLength,
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
}, [xScale, yScale, drawingArea, dataLength, layout, totalStacks, barPadding, stackIndex]);
|
|
60
|
+
const indexScaleComputed = layout !== 'horizontal' ? xScale : yScale;
|
|
61
|
+
const valueScaleComputed = layout !== 'horizontal' ? yScale : xScale;
|
|
62
|
+
if (indexScaleComputed && !isCategoricalScale(indexScaleComputed)) {
|
|
63
|
+
throw new Error("BarStackGroup requires a band scale for " + (layout !== 'horizontal' ? 'x-axis' : 'y-axis') + ". See https://cds.coinbase.com/components/charts/" + (layout !== 'horizontal' ? 'XAxis' : 'YAxis') + "/#scale-type");
|
|
61
64
|
}
|
|
62
|
-
if (!
|
|
63
|
-
|
|
65
|
+
if (!indexScaleComputed || !valueScaleComputed || !drawingArea || stackConfigs.length === 0) return;
|
|
66
|
+
|
|
67
|
+
// In horizontal layout, render stacks in reverse order so top rows (lower categoryIndex)
|
|
68
|
+
// appear on top. Otherwise bottom rows would overlap and obscure top rows during animation.
|
|
69
|
+
const orderedConfigs = layout === 'horizontal' ? [...stackConfigs].reverse() : stackConfigs;
|
|
70
|
+
return orderedConfigs.map(_ref2 => {
|
|
64
71
|
let {
|
|
65
72
|
categoryIndex,
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
indexPos,
|
|
74
|
+
thickness
|
|
68
75
|
} = _ref2;
|
|
69
76
|
return /*#__PURE__*/_createElement(BarStack, _extends({}, props, {
|
|
70
77
|
key: "stack-" + stackIndex + "-category-" + categoryIndex,
|
|
71
78
|
categoryIndex: categoryIndex,
|
|
79
|
+
indexPos: indexPos,
|
|
80
|
+
indexScale: indexScaleComputed,
|
|
72
81
|
rect: drawingArea,
|
|
73
82
|
series: series,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
thickness: thickness,
|
|
84
|
+
valueScale: valueScaleComputed,
|
|
85
|
+
xAxisId: xAxisId,
|
|
86
|
+
yAxisId: yAxisId
|
|
77
87
|
}));
|
|
78
88
|
});
|
|
79
89
|
});
|
|
@@ -2,7 +2,9 @@ import { memo, useMemo } from 'react';
|
|
|
2
2
|
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
3
3
|
import { useCartesianChartContext } from '../ChartProvider';
|
|
4
4
|
import { Path } from '../Path';
|
|
5
|
-
import { getBarPath } from '../utils';
|
|
5
|
+
import { defaultBarEnterTransition, getBarPath, withStaggerDelayTransition } from '../utils';
|
|
6
|
+
import { getNormalizedStagger } from '../utils/bar';
|
|
7
|
+
import { defaultTransition, getTransition } from '../utils/transition';
|
|
6
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
9
|
/**
|
|
8
10
|
* Default bar component that renders a solid bar with animation support.
|
|
@@ -13,7 +15,7 @@ export const DefaultBar = /*#__PURE__*/memo(_ref => {
|
|
|
13
15
|
y,
|
|
14
16
|
width,
|
|
15
17
|
height,
|
|
16
|
-
borderRadius,
|
|
18
|
+
borderRadius = 4,
|
|
17
19
|
roundTop,
|
|
18
20
|
roundBottom,
|
|
19
21
|
d,
|
|
@@ -21,36 +23,43 @@ export const DefaultBar = /*#__PURE__*/memo(_ref => {
|
|
|
21
23
|
fillOpacity = 1,
|
|
22
24
|
stroke,
|
|
23
25
|
strokeWidth,
|
|
24
|
-
|
|
26
|
+
origin,
|
|
27
|
+
minSize = 1,
|
|
28
|
+
transitions,
|
|
25
29
|
transition
|
|
26
30
|
} = _ref;
|
|
27
31
|
const {
|
|
28
|
-
animate
|
|
32
|
+
animate,
|
|
33
|
+
drawingArea,
|
|
34
|
+
layout
|
|
29
35
|
} = useCartesianChartContext();
|
|
30
36
|
const theme = useTheme();
|
|
31
37
|
const defaultFill = fill || theme.color.fgPrimary;
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const effectiveRoundBottom = roundBottom != null ? roundBottom : true;
|
|
36
|
-
return d || getBarPath(x, y, width, height, effectiveBorderRadius, effectiveRoundTop, effectiveRoundBottom);
|
|
37
|
-
}, [x, y, width, height, borderRadius, roundTop, roundBottom, d]);
|
|
38
|
+
const normalizedStagger = useMemo(() => getNormalizedStagger(layout, x, y, drawingArea), [layout, x, y, drawingArea]);
|
|
39
|
+
const enterTransition = useMemo(() => withStaggerDelayTransition(getTransition(transitions == null ? void 0 : transitions.enter, animate, defaultBarEnterTransition), normalizedStagger), [transitions == null ? void 0 : transitions.enter, animate, normalizedStagger]);
|
|
40
|
+
const updateTransition = useMemo(() => withStaggerDelayTransition(getTransition((transitions == null ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), normalizedStagger), [transitions == null ? void 0 : transitions.update, transition, animate, normalizedStagger]);
|
|
38
41
|
const initialPath = useMemo(() => {
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
if (!animate) return;
|
|
43
|
+
const isHorizontalLayout = layout === 'horizontal';
|
|
44
|
+
const baseline = origin != null ? origin : isHorizontalLayout ? x : y + height;
|
|
45
|
+
const initialX = isHorizontalLayout ? baseline : x;
|
|
46
|
+
const initialY = isHorizontalLayout ? y : baseline;
|
|
47
|
+
const initialWidth = isHorizontalLayout ? minSize : width;
|
|
48
|
+
const initialHeight = isHorizontalLayout ? height : minSize;
|
|
49
|
+
return getBarPath(initialX, initialY, initialWidth, initialHeight, borderRadius, !!roundTop, !!roundBottom, layout);
|
|
50
|
+
}, [animate, layout, x, y, origin, width, height, borderRadius, roundTop, roundBottom, minSize]);
|
|
45
51
|
return /*#__PURE__*/_jsx(Path, {
|
|
46
52
|
animate: animate,
|
|
47
53
|
clipPath: null,
|
|
48
|
-
d:
|
|
54
|
+
d: d,
|
|
49
55
|
fill: stroke ? 'none' : defaultFill,
|
|
50
56
|
fillOpacity: fillOpacity,
|
|
51
57
|
initialPath: initialPath,
|
|
52
58
|
stroke: stroke,
|
|
53
59
|
strokeWidth: strokeWidth,
|
|
54
|
-
|
|
60
|
+
transitions: {
|
|
61
|
+
enter: enterTransition,
|
|
62
|
+
update: updateTransition
|
|
63
|
+
}
|
|
55
64
|
});
|
|
56
65
|
});
|
|
@@ -2,7 +2,8 @@ import { memo, useMemo } from 'react';
|
|
|
2
2
|
import { Group } from '@shopify/react-native-skia';
|
|
3
3
|
import { useCartesianChartContext } from '../ChartProvider';
|
|
4
4
|
import { getBarPath } from '../utils';
|
|
5
|
-
import {
|
|
5
|
+
import { defaultBarEnterTransition, getNormalizedStagger, getStackInitialClipRect, withStaggerDelayTransition } from '../utils/bar';
|
|
6
|
+
import { defaultTransition, getTransition, usePathTransition } from '../utils/transition';
|
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
8
|
/**
|
|
8
9
|
* Default stack component that renders children in a group with animated clip path.
|
|
@@ -17,27 +18,42 @@ export const DefaultBarStack = /*#__PURE__*/memo(_ref => {
|
|
|
17
18
|
borderRadius = 4,
|
|
18
19
|
roundTop = true,
|
|
19
20
|
roundBottom = true,
|
|
20
|
-
|
|
21
|
+
origin,
|
|
22
|
+
transitions,
|
|
21
23
|
transition
|
|
22
24
|
} = _ref;
|
|
23
25
|
const {
|
|
24
|
-
animate
|
|
26
|
+
animate,
|
|
27
|
+
drawingArea,
|
|
28
|
+
layout
|
|
25
29
|
} = useCartesianChartContext();
|
|
30
|
+
const normalizedStagger = useMemo(() => getNormalizedStagger(layout, x, y, drawingArea), [layout, x, y, drawingArea]);
|
|
31
|
+
const enterTransition = useMemo(() => withStaggerDelayTransition(getTransition(transitions == null ? void 0 : transitions.enter, animate, defaultBarEnterTransition), normalizedStagger), [animate, transitions == null ? void 0 : transitions.enter, normalizedStagger]);
|
|
32
|
+
const updateTransition = useMemo(() => withStaggerDelayTransition(getTransition((transitions == null ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), normalizedStagger), [animate, transitions == null ? void 0 : transitions.update, transition, normalizedStagger]);
|
|
26
33
|
|
|
27
34
|
// Generate target clip path (full bar)
|
|
28
35
|
const targetPath = useMemo(() => {
|
|
29
|
-
return getBarPath(x, y, width, height, borderRadius, roundTop, roundBottom);
|
|
30
|
-
}, [x, y, width, height, borderRadius, roundTop, roundBottom]);
|
|
36
|
+
return getBarPath(x, y, width, height, borderRadius, roundTop, roundBottom, layout);
|
|
37
|
+
}, [x, y, width, height, borderRadius, roundTop, roundBottom, layout]);
|
|
31
38
|
|
|
32
39
|
// Initial clip path for entry animation (bar at baseline with minimal height)
|
|
33
40
|
const initialPath = useMemo(() => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
if (!animate) return;
|
|
42
|
+
const initialClipRect = getStackInitialClipRect({
|
|
43
|
+
x,
|
|
44
|
+
y,
|
|
45
|
+
width,
|
|
46
|
+
height
|
|
47
|
+
}, layout, origin);
|
|
48
|
+
return getBarPath(initialClipRect.x, initialClipRect.y, initialClipRect.width, initialClipRect.height, borderRadius, roundTop, roundBottom, layout);
|
|
49
|
+
}, [animate, layout, x, y, height, width, borderRadius, roundTop, roundBottom, origin]);
|
|
37
50
|
const animatedClipPath = usePathTransition({
|
|
38
51
|
currentPath: targetPath,
|
|
39
52
|
initialPath,
|
|
40
|
-
|
|
53
|
+
transitions: {
|
|
54
|
+
enter: enterTransition,
|
|
55
|
+
update: updateTransition
|
|
56
|
+
}
|
|
41
57
|
});
|
|
42
58
|
const clipPath = animate ? animatedClipPath : targetPath;
|
|
43
59
|
return /*#__PURE__*/_jsx(Group, {
|