@coinbase/cds-mobile-visualization 3.4.0-beta.8 → 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 +142 -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 +21 -6
- 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 +6 -2
- package/esm/chart/__stories__/CartesianChart.stories.js +27 -86
- 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 +102 -4
- 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 +241 -594
- 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/__stories__/Sparkline.stories.js +11 -7
- package/esm/sparkline/__stories__/SparklineGradient.stories.js +7 -4
- 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/__stories__/SparklineInteractive.stories.js +51 -26
- package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +1 -1
- package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +19 -9
- package/package.json +13 -10
- package/esm/chart/__stories__/Chart.stories.js +0 -77
|
@@ -178,7 +178,8 @@ declare function SparklineInteractiveWithGeneric<Period extends string>({
|
|
|
178
178
|
...props
|
|
179
179
|
}: SparklineInteractiveProps<Period>): import('react/jsx-runtime').JSX.Element;
|
|
180
180
|
/**
|
|
181
|
-
* @deprecated Use LineChart instead.
|
|
181
|
+
* @deprecated Use LineChart instead. This will be removed in a future major release.
|
|
182
|
+
* @deprecationExpectedRemoval v4
|
|
182
183
|
*/
|
|
183
184
|
export declare const SparklineInteractive: typeof SparklineInteractiveWithGeneric;
|
|
184
185
|
//# sourceMappingURL=SparklineInteractive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SparklineInteractive.d.ts","sourceRoot":"","sources":["../../../src/sparkline/sparkline-interactive/SparklineInteractive.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkE,MAAM,OAAO,CAAC;AACvF,OAAO,EAAY,KAAK,SAAS,EAAoB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EACV,SAAS,EAET,iBAAiB,EACjB,eAAe,EAEf,gBAAgB,EAChB,eAAe,EAChB,MAAM,kCAAkC,CAAC;AA2B1C,cAAc,kCAAkC,CAAC;AAEjD,MAAM,MAAM,6BAA6B,CAAC,MAAM,SAAS,MAAM,IAAI;IACjE;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IACjC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACjC;;OAEG;IACH,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5C;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,MAAM,CA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CAAC,KAAK,IAAI,CAAC;CACpD,CAAC;AA2OF,MAAM,MAAM,yBAAyB,CAAC,MAAM,SAAS,MAAM,IACzD,6BAA6B,CAAC,MAAM,CAAC,GAAG;IACtC;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAEtC;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC;IAEzB;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE;QACP;;WAEG;QACH,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QAC9B;;WAEG;QACH,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;KAC7B,CAAC;IACF,6BAA6B;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEJ,iBAAS,+BAA+B,CAAC,MAAM,SAAS,MAAM,EAAE,EAC9D,OAAO,EACP,MAAM,EACN,GAAG,KAAK,EACT,EAAE,yBAAyB,CAAC,MAAM,CAAC,2CAMnC;AAED
|
|
1
|
+
{"version":3,"file":"SparklineInteractive.d.ts","sourceRoot":"","sources":["../../../src/sparkline/sparkline-interactive/SparklineInteractive.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkE,MAAM,OAAO,CAAC;AACvF,OAAO,EAAY,KAAK,SAAS,EAAoB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EACV,SAAS,EAET,iBAAi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H,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QAC9B;;WAEG;QACH,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;KAC7B,CAAC;IACF,6BAA6B;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEJ,iBAAS,+BAA+B,CAAC,MAAM,SAAS,MAAM,EAAE,EAC9D,OAAO,EACP,MAAM,EACN,GAAG,KAAK,EACT,EAAE,yBAAyB,CAAC,MAAM,CAAC,2CAMnC;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAE5B,OAAO,+BAA+B,CAAC"}
|
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
const _excluded = ["series", "children", "animate", "enableScrubbing", "xAxis", "yAxis", "inset", "onScrubberPositionChange", "width", "height", "style", "styles", "allowOverflowGestures", "fontFamilies", "fontProvider", "collapsable"];
|
|
1
|
+
const _excluded = ["series", "children", "layout", "animate", "enableScrubbing", "getScrubberAccessibilityLabel", "scrubberAccessibilityLabelStep", "xAxis", "yAxis", "inset", "onScrubberPositionChange", "legend", "legendPosition", "legendAccessibilityLabel", "width", "height", "style", "styles", "allowOverflowGestures", "fontFamilies", "fontProvider", "collapsable", "accessible", "accessibilityLabel", "accessibilityLiveRegion"];
|
|
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 React, { forwardRef, memo, useCallback, useMemo } from 'react';
|
|
5
5
|
import { useLayout } from '@coinbase/cds-mobile/hooks/useLayout';
|
|
6
6
|
import { Box } from '@coinbase/cds-mobile/layout';
|
|
7
7
|
import { Canvas, Skia } from '@shopify/react-native-skia';
|
|
8
|
+
import { ScrubberAccessibilityView } from './scrubber/ScrubberAccessibilityView';
|
|
8
9
|
import { ScrubberProvider } from './scrubber/ScrubberProvider';
|
|
9
10
|
import { convertToSerializableScale } from './utils/scale';
|
|
10
11
|
import { useChartContextBridge } from './ChartContextBridge';
|
|
11
12
|
import { CartesianChartProvider } from './ChartProvider';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
13
|
+
import { Legend } from './legend';
|
|
14
|
+
import { defaultAxisId, defaultHorizontalLayoutChartInset, defaultVerticalLayoutChartInset, getAxisConfig, getAxisRange, getCartesianAxisDomain, getCartesianAxisScale, getChartInset, getStackedSeriesData as calculateStackedSeriesData, useTotalAxisPadding } from './utils';
|
|
15
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
16
|
const ChartCanvas = /*#__PURE__*/memo(_ref => {
|
|
15
17
|
let {
|
|
16
18
|
children,
|
|
17
|
-
style
|
|
19
|
+
style,
|
|
20
|
+
accessible = true,
|
|
21
|
+
accessibilityLabel,
|
|
22
|
+
accessibilityLiveRegion = 'polite'
|
|
18
23
|
} = _ref;
|
|
19
24
|
const ContextBridge = useChartContextBridge();
|
|
25
|
+
const isAccessible = accessible && accessibilityLabel !== null;
|
|
20
26
|
return /*#__PURE__*/_jsx(Canvas, {
|
|
27
|
+
accessibilityLabel: isAccessible ? accessibilityLabel : undefined,
|
|
28
|
+
accessibilityLiveRegion: isAccessible ? accessibilityLiveRegion : undefined,
|
|
29
|
+
accessible: isAccessible,
|
|
21
30
|
style: [{
|
|
22
31
|
width: '100%',
|
|
23
32
|
height: '100%'
|
|
@@ -31,12 +40,18 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2,
|
|
|
31
40
|
let {
|
|
32
41
|
series,
|
|
33
42
|
children,
|
|
43
|
+
layout = 'vertical',
|
|
34
44
|
animate = true,
|
|
35
45
|
enableScrubbing,
|
|
46
|
+
getScrubberAccessibilityLabel,
|
|
47
|
+
scrubberAccessibilityLabelStep,
|
|
36
48
|
xAxis: xAxisConfigProp,
|
|
37
49
|
yAxis: yAxisConfigProp,
|
|
38
50
|
inset,
|
|
39
51
|
onScrubberPositionChange,
|
|
52
|
+
legend,
|
|
53
|
+
legendPosition = 'bottom',
|
|
54
|
+
legendAccessibilityLabel,
|
|
40
55
|
width = '100%',
|
|
41
56
|
height = '100%',
|
|
42
57
|
style,
|
|
@@ -47,17 +62,27 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2,
|
|
|
47
62
|
// React Native will collapse views by default when only used
|
|
48
63
|
// to group children, which interferes with gesture-handler
|
|
49
64
|
// https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture-detector/#:~:text=%7B%0A%20%20return%20%3C-,View,-collapsable%3D%7B
|
|
50
|
-
collapsable = false
|
|
65
|
+
collapsable = false,
|
|
66
|
+
accessible = true,
|
|
67
|
+
accessibilityLabel,
|
|
68
|
+
accessibilityLiveRegion = 'polite'
|
|
51
69
|
} = _ref2,
|
|
52
70
|
props = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
53
71
|
const [containerLayout, onContainerLayout] = useLayout();
|
|
54
72
|
const chartWidth = containerLayout.width;
|
|
55
73
|
const chartHeight = containerLayout.height;
|
|
56
|
-
const calculatedInset = useMemo(() => getChartInset(inset,
|
|
57
|
-
|
|
58
|
-
// there can only be one x axis but the helper function always returns an array
|
|
59
|
-
const xAxisConfig = useMemo(() => getAxisConfig('x', xAxisConfigProp)[0], [xAxisConfigProp]);
|
|
74
|
+
const calculatedInset = useMemo(() => getChartInset(inset, layout === 'horizontal' ? defaultHorizontalLayoutChartInset : defaultVerticalLayoutChartInset), [inset, layout]);
|
|
75
|
+
const xAxisConfig = useMemo(() => getAxisConfig('x', xAxisConfigProp), [xAxisConfigProp]);
|
|
60
76
|
const yAxisConfig = useMemo(() => getAxisConfig('y', yAxisConfigProp), [yAxisConfigProp]);
|
|
77
|
+
|
|
78
|
+
// Horizontal layout supports multiple value axes on x, but only a single category axis on y.
|
|
79
|
+
// Vertical layout keeps a single x-axis to preserve existing behavior.
|
|
80
|
+
if (layout === 'horizontal' && yAxisConfig.length > 1) {
|
|
81
|
+
throw new Error('When layout="horizontal", only one y-axis is supported. See https://cds.coinbase.com/components/charts/CartesianChart.');
|
|
82
|
+
}
|
|
83
|
+
if (layout !== 'horizontal' && xAxisConfig.length > 1) {
|
|
84
|
+
throw new Error('Multiple x-axes are only supported when layout="horizontal". See https://cds.coinbase.com/components/charts/CartesianChart.');
|
|
85
|
+
}
|
|
61
86
|
const {
|
|
62
87
|
renderedAxes,
|
|
63
88
|
registerAxis,
|
|
@@ -87,54 +112,76 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2,
|
|
|
87
112
|
};
|
|
88
113
|
}, [chartHeight, chartWidth, totalInset]);
|
|
89
114
|
const {
|
|
90
|
-
|
|
91
|
-
|
|
115
|
+
xAxes,
|
|
116
|
+
xScales
|
|
92
117
|
} = useMemo(() => {
|
|
118
|
+
const axes = new Map();
|
|
119
|
+
const scales = new Map();
|
|
93
120
|
if (!chartRect || chartRect.width <= 0 || chartRect.height <= 0) return {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
};
|
|
97
|
-
const domain = getAxisDomain(xAxisConfig, series != null ? series : [], 'x');
|
|
98
|
-
const range = getAxisRange(xAxisConfig, chartRect, 'x');
|
|
99
|
-
const axisConfig = {
|
|
100
|
-
scaleType: xAxisConfig.scaleType,
|
|
101
|
-
domain,
|
|
102
|
-
range,
|
|
103
|
-
data: xAxisConfig.data,
|
|
104
|
-
categoryPadding: xAxisConfig.categoryPadding,
|
|
105
|
-
domainLimit: xAxisConfig.domainLimit
|
|
121
|
+
xAxes: axes,
|
|
122
|
+
xScales: scales
|
|
106
123
|
};
|
|
124
|
+
xAxisConfig.forEach(axisParam => {
|
|
125
|
+
var _axisParam$id, _series$filter, _axisParam$domainLimi;
|
|
126
|
+
const axisId = (_axisParam$id = axisParam.id) != null ? _axisParam$id : defaultAxisId;
|
|
107
127
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
128
|
+
// Get relevant series data.
|
|
129
|
+
const relevantSeries = xAxisConfig.length > 1 ? (_series$filter = series == null ? void 0 : series.filter(s => {
|
|
130
|
+
var _s$xAxisId;
|
|
131
|
+
return ((_s$xAxisId = s.xAxisId) != null ? _s$xAxisId : defaultAxisId) === axisId;
|
|
132
|
+
})) != null ? _series$filter : [] : series != null ? series : [];
|
|
133
|
+
|
|
134
|
+
// Calculate domain and range.
|
|
135
|
+
const dataDomain = getCartesianAxisDomain(axisParam, relevantSeries, 'x', layout);
|
|
136
|
+
const range = getAxisRange(axisParam, chartRect, 'x');
|
|
137
|
+
const axisConfig = {
|
|
138
|
+
scaleType: axisParam.scaleType,
|
|
139
|
+
domain: dataDomain,
|
|
140
|
+
range,
|
|
141
|
+
data: axisParam.data,
|
|
142
|
+
categoryPadding: axisParam.categoryPadding,
|
|
143
|
+
domainLimit: (_axisParam$domainLimi = axisParam.domainLimit) != null ? _axisParam$domainLimi : layout === 'horizontal' ? 'nice' : 'strict'
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// Create the scale.
|
|
147
|
+
const scale = getCartesianAxisScale({
|
|
148
|
+
config: axisConfig,
|
|
149
|
+
type: 'x',
|
|
150
|
+
range: axisConfig.range,
|
|
151
|
+
dataDomain: axisConfig.domain,
|
|
152
|
+
layout
|
|
153
|
+
});
|
|
154
|
+
if (scale) {
|
|
155
|
+
scales.set(axisId, scale);
|
|
119
156
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
157
|
+
// Update axis config with actual scale domain (after .nice() or other adjustments).
|
|
158
|
+
const scaleDomain = scale.domain();
|
|
159
|
+
const actualDomain = Array.isArray(scaleDomain) && scaleDomain.length === 2 ? {
|
|
160
|
+
min: scaleDomain[0],
|
|
161
|
+
max: scaleDomain[1]
|
|
162
|
+
} : axisConfig.domain;
|
|
163
|
+
axes.set(axisId, _extends({}, axisConfig, {
|
|
164
|
+
domain: actualDomain
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
128
167
|
});
|
|
129
168
|
return {
|
|
130
|
-
|
|
131
|
-
|
|
169
|
+
xAxes: axes,
|
|
170
|
+
xScales: scales
|
|
132
171
|
};
|
|
133
|
-
}, [xAxisConfig, series, chartRect]);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
172
|
+
}, [xAxisConfig, series, chartRect, layout]);
|
|
173
|
+
|
|
174
|
+
// We need a set of serialized scales usable in UI thread.
|
|
175
|
+
const xSerializableScales = useMemo(() => {
|
|
176
|
+
const serializableScales = new Map();
|
|
177
|
+
xScales.forEach((scale, id) => {
|
|
178
|
+
const serializableScale = convertToSerializableScale(scale);
|
|
179
|
+
if (serializableScale) {
|
|
180
|
+
serializableScales.set(id, serializableScale);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return serializableScales;
|
|
184
|
+
}, [xScales]);
|
|
138
185
|
const {
|
|
139
186
|
yAxes,
|
|
140
187
|
yScales
|
|
@@ -146,17 +193,17 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2,
|
|
|
146
193
|
yScales: scales
|
|
147
194
|
};
|
|
148
195
|
yAxisConfig.forEach(axisParam => {
|
|
149
|
-
var _axisParam$
|
|
150
|
-
const axisId = (_axisParam$
|
|
196
|
+
var _axisParam$id2, _series$filter2, _axisParam$domainLimi2;
|
|
197
|
+
const axisId = (_axisParam$id2 = axisParam.id) != null ? _axisParam$id2 : defaultAxisId;
|
|
151
198
|
|
|
152
|
-
// Get relevant series data
|
|
153
|
-
const relevantSeries = (_series$
|
|
199
|
+
// Get relevant series data.
|
|
200
|
+
const relevantSeries = yAxisConfig.length > 1 ? (_series$filter2 = series == null ? void 0 : series.filter(s => {
|
|
154
201
|
var _s$yAxisId;
|
|
155
202
|
return ((_s$yAxisId = s.yAxisId) != null ? _s$yAxisId : defaultAxisId) === axisId;
|
|
156
|
-
})) != null ? _series$
|
|
203
|
+
})) != null ? _series$filter2 : [] : series != null ? series : [];
|
|
157
204
|
|
|
158
|
-
// Calculate domain and range
|
|
159
|
-
const dataDomain =
|
|
205
|
+
// Calculate domain and range.
|
|
206
|
+
const dataDomain = getCartesianAxisDomain(axisParam, relevantSeries, 'y', layout);
|
|
160
207
|
const range = getAxisRange(axisParam, chartRect, 'y');
|
|
161
208
|
const axisConfig = {
|
|
162
209
|
scaleType: axisParam.scaleType,
|
|
@@ -164,20 +211,21 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2,
|
|
|
164
211
|
range,
|
|
165
212
|
data: axisParam.data,
|
|
166
213
|
categoryPadding: axisParam.categoryPadding,
|
|
167
|
-
domainLimit: (_axisParam$
|
|
214
|
+
domainLimit: (_axisParam$domainLimi2 = axisParam.domainLimit) != null ? _axisParam$domainLimi2 : layout === 'horizontal' ? 'strict' : 'nice'
|
|
168
215
|
};
|
|
169
216
|
|
|
170
|
-
// Create the scale
|
|
171
|
-
const scale =
|
|
217
|
+
// Create the scale.
|
|
218
|
+
const scale = getCartesianAxisScale({
|
|
172
219
|
config: axisConfig,
|
|
173
220
|
type: 'y',
|
|
174
221
|
range: axisConfig.range,
|
|
175
|
-
dataDomain: axisConfig.domain
|
|
222
|
+
dataDomain: axisConfig.domain,
|
|
223
|
+
layout
|
|
176
224
|
});
|
|
177
225
|
if (scale) {
|
|
178
226
|
scales.set(axisId, scale);
|
|
179
227
|
|
|
180
|
-
// Update axis config with actual scale domain (after .nice() or other adjustments)
|
|
228
|
+
// Update axis config with actual scale domain (after .nice() or other adjustments).
|
|
181
229
|
const scaleDomain = scale.domain();
|
|
182
230
|
const actualDomain = Array.isArray(scaleDomain) && scaleDomain.length === 2 ? {
|
|
183
231
|
min: scaleDomain[0],
|
|
@@ -192,7 +240,7 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2,
|
|
|
192
240
|
yAxes: axes,
|
|
193
241
|
yScales: scales
|
|
194
242
|
};
|
|
195
|
-
}, [yAxisConfig, series, chartRect]);
|
|
243
|
+
}, [yAxisConfig, series, chartRect, layout]);
|
|
196
244
|
|
|
197
245
|
// We need a set of serialized scales usable in UI thread
|
|
198
246
|
const ySerializableScales = useMemo(() => {
|
|
@@ -205,11 +253,11 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2,
|
|
|
205
253
|
});
|
|
206
254
|
return serializableScales;
|
|
207
255
|
}, [yScales]);
|
|
208
|
-
const getXAxis = useCallback(
|
|
256
|
+
const getXAxis = useCallback(id => xAxes.get(id != null ? id : defaultAxisId), [xAxes]);
|
|
209
257
|
const getYAxis = useCallback(id => yAxes.get(id != null ? id : defaultAxisId), [yAxes]);
|
|
210
|
-
const getXScale = useCallback(
|
|
258
|
+
const getXScale = useCallback(id => xScales.get(id != null ? id : defaultAxisId), [xScales]);
|
|
211
259
|
const getYScale = useCallback(id => yScales.get(id != null ? id : defaultAxisId), [yScales]);
|
|
212
|
-
const getXSerializableScale = useCallback(
|
|
260
|
+
const getXSerializableScale = useCallback(id => xSerializableScales.get(id != null ? id : defaultAxisId), [xSerializableScales]);
|
|
213
261
|
const getYSerializableScale = useCallback(id => ySerializableScales.get(id != null ? id : defaultAxisId), [ySerializableScales]);
|
|
214
262
|
const getSeries = useCallback(seriesId => series == null ? void 0 : series.find(s => s.id === seriesId), [series]);
|
|
215
263
|
const stackedDataMap = useMemo(() => {
|
|
@@ -220,20 +268,27 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2,
|
|
|
220
268
|
if (!seriesId) return undefined;
|
|
221
269
|
return stackedDataMap.get(seriesId);
|
|
222
270
|
}, [stackedDataMap]);
|
|
271
|
+
const categoryAxisIsX = useMemo(() => {
|
|
272
|
+
return layout !== 'horizontal';
|
|
273
|
+
}, [layout]);
|
|
274
|
+
const categoryAxisConfig = useMemo(() => {
|
|
275
|
+
var _xAxisConfig$, _yAxisConfig$;
|
|
276
|
+
return categoryAxisIsX ? (_xAxisConfig$ = xAxisConfig[0]) != null ? _xAxisConfig$ : yAxisConfig[0] : (_yAxisConfig$ = yAxisConfig[0]) != null ? _yAxisConfig$ : xAxisConfig[0];
|
|
277
|
+
}, [categoryAxisIsX, xAxisConfig, yAxisConfig]);
|
|
223
278
|
const dataLength = useMemo(() => {
|
|
224
|
-
// If
|
|
225
|
-
if (
|
|
226
|
-
return
|
|
279
|
+
// If category axis has categorical data, use that length.
|
|
280
|
+
if (categoryAxisConfig.data && categoryAxisConfig.data.length > 0) {
|
|
281
|
+
return categoryAxisConfig.data.length;
|
|
227
282
|
}
|
|
228
283
|
|
|
229
|
-
// Otherwise, find the longest series
|
|
284
|
+
// Otherwise, find the longest series.
|
|
230
285
|
if (!series || series.length === 0) return 0;
|
|
231
286
|
return series.reduce((max, s) => {
|
|
232
287
|
var _seriesData$length;
|
|
233
288
|
const seriesData = getStackedSeriesData(s.id);
|
|
234
289
|
return Math.max(max, (_seriesData$length = seriesData == null ? void 0 : seriesData.length) != null ? _seriesData$length : 0);
|
|
235
290
|
}, 0);
|
|
236
|
-
}, [
|
|
291
|
+
}, [categoryAxisConfig, series, getStackedSeriesData]);
|
|
237
292
|
const getAxisBounds = useCallback(axisId => {
|
|
238
293
|
const axis = renderedAxes.get(axisId);
|
|
239
294
|
if (!axis || !chartRect) return;
|
|
@@ -286,6 +341,7 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2,
|
|
|
286
341
|
return Skia.TypefaceFontProvider.Make();
|
|
287
342
|
}, [fontProviderProp]);
|
|
288
343
|
const contextValue = useMemo(() => ({
|
|
344
|
+
layout,
|
|
289
345
|
series: series != null ? series : [],
|
|
290
346
|
getSeries,
|
|
291
347
|
getSeriesData: getStackedSeriesData,
|
|
@@ -305,30 +361,68 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2,
|
|
|
305
361
|
registerAxis,
|
|
306
362
|
unregisterAxis,
|
|
307
363
|
getAxisBounds
|
|
308
|
-
}), [series, getSeries, getStackedSeriesData, animate, chartWidth, chartHeight, fontFamilies, fontProvider, getXAxis, getYAxis, getXScale, getYScale, getXSerializableScale, getYSerializableScale, chartRect, dataLength, registerAxis, unregisterAxis, getAxisBounds]);
|
|
364
|
+
}), [layout, series, getSeries, getStackedSeriesData, animate, chartWidth, chartHeight, fontFamilies, fontProvider, getXAxis, getYAxis, getXScale, getYScale, getXSerializableScale, getYSerializableScale, chartRect, dataLength, registerAxis, unregisterAxis, getAxisBounds]);
|
|
309
365
|
const rootStyles = useMemo(() => {
|
|
310
366
|
return [style, styles == null ? void 0 : styles.root];
|
|
311
367
|
}, [style, styles == null ? void 0 : styles.root]);
|
|
368
|
+
const legendElement = useMemo(() => {
|
|
369
|
+
if (!legend) return;
|
|
370
|
+
if (legend === true) {
|
|
371
|
+
const isHorizontal = legendPosition === 'top' || legendPosition === 'bottom';
|
|
372
|
+
const flexDirection = isHorizontal ? 'row' : 'column';
|
|
373
|
+
return /*#__PURE__*/_jsx(Legend, {
|
|
374
|
+
accessibilityLabel: legendAccessibilityLabel,
|
|
375
|
+
flexDirection: flexDirection
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
return legend;
|
|
379
|
+
}, [legend, legendAccessibilityLabel, legendPosition]);
|
|
380
|
+
const rootBoxProps = useMemo(() => _extends({
|
|
381
|
+
ref,
|
|
382
|
+
height,
|
|
383
|
+
style: rootStyles,
|
|
384
|
+
width
|
|
385
|
+
}, props), [ref, height, rootStyles, width, props]);
|
|
312
386
|
return /*#__PURE__*/_jsx(CartesianChartProvider, {
|
|
313
387
|
value: contextValue,
|
|
314
388
|
children: /*#__PURE__*/_jsx(ScrubberProvider, {
|
|
315
389
|
allowOverflowGestures: allowOverflowGestures,
|
|
316
390
|
enableScrubbing: enableScrubbing,
|
|
317
391
|
onScrubberPositionChange: onScrubberPositionChange,
|
|
318
|
-
children: /*#__PURE__*/
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
392
|
+
children: legend ? /*#__PURE__*/_jsxs(Box, _extends({
|
|
393
|
+
flexDirection: legendPosition === 'top' || legendPosition === 'bottom' ? 'column' : 'row'
|
|
394
|
+
}, rootBoxProps, {
|
|
395
|
+
children: [(legendPosition === 'top' || legendPosition === 'left') && legendElement, /*#__PURE__*/_jsxs(Box, {
|
|
396
|
+
collapsable: collapsable,
|
|
397
|
+
onLayout: onContainerLayout,
|
|
398
|
+
style: {
|
|
399
|
+
flex: 1
|
|
400
|
+
},
|
|
401
|
+
children: [/*#__PURE__*/_jsx(ChartCanvas, {
|
|
402
|
+
accessibilityLabel: accessibilityLabel,
|
|
403
|
+
accessibilityLiveRegion: accessibilityLiveRegion,
|
|
404
|
+
accessible: accessible,
|
|
405
|
+
style: styles == null ? void 0 : styles.chart,
|
|
406
|
+
children: children
|
|
407
|
+
}), /*#__PURE__*/_jsx(ScrubberAccessibilityView, {
|
|
408
|
+
accessibilityLabel: getScrubberAccessibilityLabel,
|
|
409
|
+
accessibilityStep: scrubberAccessibilityLabelStep
|
|
410
|
+
})]
|
|
411
|
+
}), (legendPosition === 'bottom' || legendPosition === 'right') && legendElement]
|
|
412
|
+
})) : /*#__PURE__*/_jsxs(Box, _extends({
|
|
322
413
|
collapsable: collapsable,
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
414
|
+
onLayout: onContainerLayout
|
|
415
|
+
}, rootBoxProps, {
|
|
416
|
+
children: [/*#__PURE__*/_jsx(ChartCanvas, {
|
|
417
|
+
accessibilityLabel: accessibilityLabel,
|
|
418
|
+
accessibilityLiveRegion: accessibilityLiveRegion,
|
|
419
|
+
accessible: accessible,
|
|
329
420
|
style: styles == null ? void 0 : styles.chart,
|
|
330
421
|
children: children
|
|
331
|
-
})
|
|
422
|
+
}), /*#__PURE__*/_jsx(ScrubberAccessibilityView, {
|
|
423
|
+
accessibilityLabel: getScrubberAccessibilityLabel,
|
|
424
|
+
accessibilityStep: scrubberAccessibilityLabelStep
|
|
425
|
+
})]
|
|
332
426
|
}))
|
|
333
427
|
})
|
|
334
428
|
});
|
|
@@ -6,6 +6,17 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import * as React from 'react';
|
|
9
|
+
import { ThemeContext } from '@coinbase/cds-mobile/system/ThemeProvider';
|
|
10
|
+
import { ScrubberContext } from './utils/context';
|
|
11
|
+
import { CartesianChartContext } from './ChartProvider';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Whitelist of contexts that should be bridged to the Skia canvas.
|
|
15
|
+
* Only these contexts will be made available inside the chart's Skia tree.
|
|
16
|
+
* This improves performance by avoiding the overhead of rendering every bridged context.
|
|
17
|
+
*/
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
const BRIDGED_CONTEXTS = [ThemeContext, CartesianChartContext, ScrubberContext];
|
|
9
20
|
|
|
10
21
|
/**
|
|
11
22
|
* Represents a react-internal tree node.
|
|
@@ -14,7 +25,7 @@ import * as React from 'react';
|
|
|
14
25
|
/**
|
|
15
26
|
* Represents a tree node selector for traversal.
|
|
16
27
|
*/
|
|
17
|
-
|
|
28
|
+
|
|
18
29
|
/**
|
|
19
30
|
* Traverses up or down a React tree, return `true` to stop and select a node.
|
|
20
31
|
*/
|
|
@@ -104,7 +115,7 @@ function useTreeNode() {
|
|
|
104
115
|
return treeNode;
|
|
105
116
|
}
|
|
106
117
|
/**
|
|
107
|
-
* Returns a map of
|
|
118
|
+
* Returns a map of whitelisted contexts and their values.
|
|
108
119
|
*/
|
|
109
120
|
function useContextMap() {
|
|
110
121
|
const treeNode = useTreeNode();
|
|
@@ -118,7 +129,7 @@ function useContextMap() {
|
|
|
118
129
|
// https://github.com/facebook/react/pull/28226
|
|
119
130
|
const enableRenderableContext = node.type._context === undefined && node.type.Provider === node.type;
|
|
120
131
|
const context = enableRenderableContext ? node.type : node.type._context;
|
|
121
|
-
if (context && context !== TreeNodeContext && !contextMap.has(context)) {
|
|
132
|
+
if (context && context !== TreeNodeContext && BRIDGED_CONTEXTS.includes(context) && !contextMap.has(context)) {
|
|
122
133
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
123
134
|
contextMap.set(context, React.useContext(wrapContext(context)));
|
|
124
135
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createContext, useContext } from 'react';
|
|
2
|
-
const CartesianChartContext = /*#__PURE__*/createContext(undefined);
|
|
2
|
+
export const CartesianChartContext = /*#__PURE__*/createContext(undefined);
|
|
3
3
|
export const useCartesianChartContext = () => {
|
|
4
4
|
const context = useContext(CartesianChartContext);
|
|
5
5
|
if (!context) {
|
|
6
|
-
throw new Error('useCartesianChartContext must be used within a CartesianChart component. See
|
|
6
|
+
throw new Error('useCartesianChartContext must be used within a CartesianChart component. See https://cds.coinbase.com/components/charts/CartesianChart.');
|
|
7
7
|
}
|
|
8
8
|
return context;
|
|
9
9
|
};
|
package/esm/chart/Path.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
const _excluded = ["d", "initialPath", "fill", "fillOpacity", "stroke", "strokeOpacity", "strokeWidth", "strokeCap", "strokeJoin", "children", "
|
|
2
|
-
_excluded2 = ["animate", "clipRect", "clipPath", "clipOffset", "d", "initialPath", "fill", "fillOpacity", "stroke", "strokeOpacity", "strokeWidth", "strokeCap", "strokeJoin", "children", "transition"];
|
|
1
|
+
const _excluded = ["d", "initialPath", "fill", "fillOpacity", "stroke", "strokeOpacity", "strokeWidth", "strokeCap", "strokeJoin", "children", "transitions"],
|
|
2
|
+
_excluded2 = ["animate", "clipRect", "clipPath", "clipOffset", "d", "initialPath", "fill", "fillOpacity", "stroke", "strokeOpacity", "strokeWidth", "strokeCap", "strokeJoin", "children", "transitions", "transition"];
|
|
3
3
|
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); }
|
|
4
4
|
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; }
|
|
5
5
|
import { memo, useEffect, useMemo } from 'react';
|
|
6
|
-
import { useDerivedValue, useSharedValue
|
|
6
|
+
import { useDerivedValue, useSharedValue } from 'react-native-reanimated';
|
|
7
7
|
import { Group, Path as SkiaPath, Skia, usePathInterpolation } from '@shopify/react-native-skia';
|
|
8
|
-
import {
|
|
8
|
+
import { defaultPathEnterTransition } from './utils/path';
|
|
9
|
+
import { buildTransition, defaultTransition, getTransition, usePathTransition } from './utils/transition';
|
|
9
10
|
import { useCartesianChartContext } from './ChartProvider';
|
|
10
11
|
import { unwrapAnimatedValue } from './utils';
|
|
11
12
|
|
|
@@ -26,17 +27,14 @@ const AnimatedPath = /*#__PURE__*/memo(_ref => {
|
|
|
26
27
|
strokeCap,
|
|
27
28
|
strokeJoin,
|
|
28
29
|
children,
|
|
29
|
-
|
|
30
|
+
transitions
|
|
30
31
|
} = _ref,
|
|
31
32
|
pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
32
33
|
const isDAnimated = typeof d !== 'string';
|
|
33
|
-
|
|
34
|
-
// When d is animated, usePathTransition handles static path transitions.
|
|
35
|
-
// For animated d values, we skip usePathTransition and use useDerivedValue directly.
|
|
36
34
|
const animatedPath = usePathTransition({
|
|
37
35
|
currentPath: isDAnimated ? '' : d,
|
|
38
36
|
initialPath,
|
|
39
|
-
|
|
37
|
+
transitions
|
|
40
38
|
});
|
|
41
39
|
const isFilled = fill !== undefined && fill !== 'none';
|
|
42
40
|
const isStroked = stroke !== undefined && stroke !== 'none';
|
|
@@ -84,28 +82,29 @@ export const Path = /*#__PURE__*/memo(props => {
|
|
|
84
82
|
strokeCap,
|
|
85
83
|
strokeJoin,
|
|
86
84
|
children,
|
|
85
|
+
transitions,
|
|
87
86
|
transition
|
|
88
87
|
} = props,
|
|
89
88
|
pathProps = _objectWithoutPropertiesLoose(props, _excluded2);
|
|
90
89
|
const context = useCartesianChartContext();
|
|
91
90
|
const rect = clipRect != null ? clipRect : context.drawingArea;
|
|
92
91
|
const animate = animateProp != null ? animateProp : context.animate;
|
|
92
|
+
const isReady = !!context.getXScale();
|
|
93
|
+
const enterTransition = useMemo(() => getTransition(transitions == null ? void 0 : transitions.enter, animate, defaultPathEnterTransition), [animate, transitions == null ? void 0 : transitions.enter]);
|
|
94
|
+
const updateTransition = useMemo(() => getTransition((transitions == null ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), [animate, transitions == null ? void 0 : transitions.update, transition]);
|
|
95
|
+
const shouldAnimateClip = animate && enterTransition !== null;
|
|
93
96
|
|
|
94
97
|
// The clip offset provides extra padding to prevent path from being cut off
|
|
95
98
|
// Area charts typically use offset=0 for exact clipping, while lines use offset=2 for breathing room
|
|
96
99
|
const totalOffset = clipOffset * 2; // Applied on both sides
|
|
97
100
|
|
|
98
101
|
// Animation progress for clip path reveal
|
|
99
|
-
const clipProgress = useSharedValue(
|
|
100
|
-
|
|
101
|
-
// Trigger clip path animation when component mounts and animate is true
|
|
102
|
+
const clipProgress = useSharedValue(shouldAnimateClip ? 0 : 1);
|
|
102
103
|
useEffect(() => {
|
|
103
|
-
if (
|
|
104
|
-
clipProgress.value =
|
|
105
|
-
duration: pathEnterTransitionDuration
|
|
106
|
-
});
|
|
104
|
+
if (shouldAnimateClip && isReady) {
|
|
105
|
+
clipProgress.value = buildTransition(1, enterTransition);
|
|
107
106
|
}
|
|
108
|
-
}, [
|
|
107
|
+
}, [shouldAnimateClip, isReady, clipProgress, enterTransition]);
|
|
109
108
|
|
|
110
109
|
// Create initial and target clip paths for animation
|
|
111
110
|
const {
|
|
@@ -116,32 +115,35 @@ export const Path = /*#__PURE__*/memo(props => {
|
|
|
116
115
|
initialClipPath: null,
|
|
117
116
|
targetClipPath: null
|
|
118
117
|
};
|
|
118
|
+
const categoryAxisIsX = context.layout !== 'horizontal';
|
|
119
|
+
const fullWidth = rect.width + totalOffset;
|
|
120
|
+
const fullHeight = rect.height + totalOffset;
|
|
119
121
|
|
|
120
|
-
// Initial clip path
|
|
122
|
+
// Initial clip path starts collapsed on the category axis.
|
|
121
123
|
const initial = Skia.Path.Make();
|
|
122
124
|
initial.addRect({
|
|
123
125
|
x: rect.x - clipOffset,
|
|
124
126
|
y: rect.y - clipOffset,
|
|
125
|
-
width: 0,
|
|
126
|
-
height:
|
|
127
|
+
width: categoryAxisIsX ? 0 : fullWidth,
|
|
128
|
+
height: categoryAxisIsX ? fullHeight : 0
|
|
127
129
|
});
|
|
128
130
|
|
|
129
|
-
// Target clip path
|
|
131
|
+
// Target clip path is fully expanded.
|
|
130
132
|
const target = Skia.Path.Make();
|
|
131
133
|
target.addRect({
|
|
132
134
|
x: rect.x - clipOffset,
|
|
133
135
|
y: rect.y - clipOffset,
|
|
134
|
-
width:
|
|
135
|
-
height:
|
|
136
|
+
width: fullWidth,
|
|
137
|
+
height: fullHeight
|
|
136
138
|
});
|
|
137
139
|
return {
|
|
138
140
|
initialClipPath: initial,
|
|
139
141
|
targetClipPath: target
|
|
140
142
|
};
|
|
141
|
-
}, [rect, clipOffset, totalOffset]);
|
|
143
|
+
}, [rect, clipOffset, totalOffset, context.layout]);
|
|
142
144
|
|
|
143
145
|
// Use usePathInterpolation for animated clip path
|
|
144
|
-
const animatedClipPath = usePathInterpolation(clipProgress, [0, 1],
|
|
146
|
+
const animatedClipPath = usePathInterpolation(clipProgress, [0, 1], shouldAnimateClip && initialClipPath && targetClipPath ? [initialClipPath, targetClipPath] : targetClipPath ? [targetClipPath, targetClipPath] : [Skia.Path.Make(), Skia.Path.Make()]);
|
|
145
147
|
|
|
146
148
|
// Resolve the final clip path:
|
|
147
149
|
// 1. If clipPath prop was explicitly provided, use it (even if null = no clipping)
|
|
@@ -154,13 +156,13 @@ export const Path = /*#__PURE__*/memo(props => {
|
|
|
154
156
|
}
|
|
155
157
|
|
|
156
158
|
// If not animating or paths are null, return target clip path
|
|
157
|
-
if (!
|
|
159
|
+
if (!shouldAnimateClip || !targetClipPath) {
|
|
158
160
|
return targetClipPath;
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
// Return undefined here since we'll use animatedClipPath directly
|
|
162
164
|
return undefined;
|
|
163
|
-
}, [clipPathProp,
|
|
165
|
+
}, [clipPathProp, shouldAnimateClip, targetClipPath]);
|
|
164
166
|
|
|
165
167
|
// Convert SVG path string to SkPath for static rendering
|
|
166
168
|
const staticPath = useDerivedValue(() => {
|
|
@@ -200,12 +202,15 @@ export const Path = /*#__PURE__*/memo(props => {
|
|
|
200
202
|
strokeJoin: strokeJoin,
|
|
201
203
|
strokeOpacity: strokeOpacity,
|
|
202
204
|
strokeWidth: strokeWidth,
|
|
203
|
-
|
|
205
|
+
transitions: {
|
|
206
|
+
enter: enterTransition,
|
|
207
|
+
update: updateTransition
|
|
208
|
+
},
|
|
204
209
|
children: children
|
|
205
210
|
});
|
|
206
211
|
|
|
207
212
|
// Determine which clip path to use
|
|
208
|
-
const finalClipPath =
|
|
213
|
+
const finalClipPath = shouldAnimateClip && resolvedClipPath === undefined ? animatedClipPath : resolvedClipPath;
|
|
209
214
|
|
|
210
215
|
// If finalClipPath is null, render without clipping
|
|
211
216
|
if (finalClipPath === null) {
|