@coinbase/cds-mobile-visualization 3.4.0-beta.17 → 3.4.0-beta.19
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 +12 -0
- package/dts/chart/Path.d.ts +35 -13
- package/dts/chart/Path.d.ts.map +1 -1
- package/dts/chart/area/Area.d.ts +7 -11
- package/dts/chart/area/Area.d.ts.map +1 -1
- package/dts/chart/area/AreaChart.d.ts +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/bar/Bar.d.ts +32 -2
- package/dts/chart/bar/Bar.d.ts.map +1 -1
- package/dts/chart/bar/BarChart.d.ts +2 -0
- 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 +5 -10
- package/dts/chart/bar/BarStack.d.ts.map +1 -1
- package/dts/chart/bar/BarStackGroup.d.ts +1 -0
- 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/line/DottedLine.d.ts.map +1 -1
- package/dts/chart/line/Line.d.ts +4 -9
- package/dts/chart/line/Line.d.ts.map +1 -1
- package/dts/chart/line/LineChart.d.ts +1 -1
- package/dts/chart/line/SolidLine.d.ts.map +1 -1
- package/dts/chart/point/Point.d.ts +18 -2
- package/dts/chart/point/Point.d.ts.map +1 -1
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +9 -1
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -1
- package/dts/chart/scrubber/Scrubber.d.ts +45 -24
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +9 -1
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -1
- package/dts/chart/utils/bar.d.ts +34 -0
- package/dts/chart/utils/bar.d.ts.map +1 -1
- package/dts/chart/utils/path.d.ts +6 -0
- package/dts/chart/utils/path.d.ts.map +1 -1
- package/dts/chart/utils/transition.d.ts +59 -21
- package/dts/chart/utils/transition.d.ts.map +1 -1
- package/esm/chart/Path.js +18 -17
- package/esm/chart/__stories__/CartesianChart.stories.js +3 -77
- package/esm/chart/__stories__/ChartTransitions.stories.js +629 -0
- package/esm/chart/area/Area.js +2 -0
- package/esm/chart/area/DottedArea.js +7 -3
- package/esm/chart/area/GradientArea.js +4 -2
- package/esm/chart/area/SolidArea.js +4 -2
- package/esm/chart/bar/Bar.js +2 -0
- package/esm/chart/bar/BarChart.js +4 -2
- package/esm/chart/bar/BarPlot.js +2 -0
- package/esm/chart/bar/BarStack.js +3 -0
- package/esm/chart/bar/DefaultBar.js +15 -15
- package/esm/chart/bar/DefaultBarStack.js +14 -3
- package/esm/chart/bar/__stories__/BarChart.stories.js +448 -52
- package/esm/chart/line/DottedLine.js +4 -2
- package/esm/chart/line/Line.js +6 -17
- package/esm/chart/line/SolidLine.js +4 -2
- package/esm/chart/line/__stories__/LineChart.stories.js +130 -235
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +95 -1
- package/esm/chart/point/Point.js +33 -35
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +2 -5
- package/esm/chart/scrubber/Scrubber.js +15 -14
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +29 -7
- package/esm/chart/utils/bar.js +43 -0
- package/esm/chart/utils/path.js +8 -0
- package/esm/chart/utils/transition.js +96 -61
- package/package.json +5 -5
- package/esm/chart/__stories__/Chart.stories.js +0 -77
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { ChartTextProps } from '../text';
|
|
2
2
|
import { type ScrubberLabelPosition } from '../utils/scrubber';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
ScrubberBeaconLabelComponent,
|
|
5
|
+
ScrubberBeaconLabelProps,
|
|
6
|
+
ScrubberBeaconProps,
|
|
7
|
+
} from './Scrubber';
|
|
4
8
|
export type ScrubberBeaconLabelGroupBaseProps = {
|
|
5
9
|
/**
|
|
6
10
|
* Labels to be displayed.
|
|
@@ -33,6 +37,10 @@ export type ScrubberBeaconLabelGroupProps = ScrubberBeaconLabelGroupBaseProps &
|
|
|
33
37
|
* @default DefaultScrubberBeaconLabel
|
|
34
38
|
*/
|
|
35
39
|
BeaconLabelComponent?: ScrubberBeaconLabelComponent;
|
|
40
|
+
/**
|
|
41
|
+
* Transition configuration for beacon label animations.
|
|
42
|
+
*/
|
|
43
|
+
transitions?: ScrubberBeaconProps['transitions'];
|
|
36
44
|
};
|
|
37
45
|
export declare const ScrubberBeaconLabelGroup: import('react').NamedExoticComponent<ScrubberBeaconLabelGroupProps>;
|
|
38
46
|
//# sourceMappingURL=ScrubberBeaconLabelGroup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrubberBeaconLabelGroup.d.ts","sourceRoot":"","sources":["../../../src/chart/scrubber/ScrubberBeaconLabelGroup.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,SAAS,CAAC;AAEjE,OAAO,EAKL,KAAK,qBAAqB,EAC3B,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ScrubberBeaconLabelGroup.d.ts","sourceRoot":"","sources":["../../../src/chart/scrubber/ScrubberBeaconLabelGroup.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,SAAS,CAAC;AAEjE,OAAO,EAKL,KAAK,qBAAqB,EAC3B,MAAM,mBAAmB,CAAC;AAS3B,OAAO,KAAK,EACV,4BAA4B,EAC5B,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AA4EpB,MAAM,MAAM,iCAAiC,GAAG;IAC9C;;OAEG;IACH,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,wBAAwB,EAAE,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAC9E;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;;OAEG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACnC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,qBAAqB,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,iCAAiC,GAAG;IAC9E;;;OAGG;IACH,oBAAoB,CAAC,EAAE,4BAA4B,CAAC;IACpD;;OAEG;IACH,WAAW,CAAC,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;CAClD,CAAC;AAEF,eAAO,MAAM,wBAAwB,qEAoMpC,CAAC"}
|
package/dts/chart/utils/bar.d.ts
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
import { type Transition } from './transition';
|
|
2
|
+
/**
|
|
3
|
+
* A bar-specific transition that extends Transition with stagger support.
|
|
4
|
+
* When `staggerDelay` is provided, bars will animate with increasing delays
|
|
5
|
+
* based on their horizontal position (leftmost starts first, rightmost last).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // Bars stagger in from left to right over 250ms, each animating for 750ms
|
|
9
|
+
* { type: 'timing', duration: 750, staggerDelay: 250 }
|
|
10
|
+
*/
|
|
11
|
+
export type BarTransition = Transition & {
|
|
12
|
+
/**
|
|
13
|
+
* Maximum stagger delay (ms) distributed across bars by x position.
|
|
14
|
+
* Leftmost bar starts immediately, rightmost starts after this delay.
|
|
15
|
+
*/
|
|
16
|
+
staggerDelay?: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Strips `staggerDelay` from a transition and computes a positional delay.
|
|
20
|
+
*
|
|
21
|
+
* @param transition - The transition config (may include staggerDelay)
|
|
22
|
+
* @param normalizedX - The bar's normalized x position (0 = left edge, 1 = right edge)
|
|
23
|
+
* @returns A standard Transition with computed delay
|
|
24
|
+
*/
|
|
25
|
+
export declare const withStaggerDelayTransition: (
|
|
26
|
+
transition: BarTransition,
|
|
27
|
+
normalizedX: number,
|
|
28
|
+
) => Transition;
|
|
29
|
+
/**
|
|
30
|
+
* Default bar enter transition. Uses the default spring with a stagger delay
|
|
31
|
+
* so bars spring into place from left to right.
|
|
32
|
+
* `{ type: 'spring', stiffness: 900, damping: 120, staggerDelay: 250 }`
|
|
33
|
+
*/
|
|
34
|
+
export declare const defaultBarEnterTransition: BarTransition;
|
|
1
35
|
/**
|
|
2
36
|
* Calculates the size adjustment needed for bars when accounting for gaps between them.
|
|
3
37
|
* This function helps determine how much to reduce each bar's width to accommodate
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAM9E"}
|
|
1
|
+
{"version":3,"file":"bar.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/bar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG;IACvC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GACrC,YAAY,aAAa,EACzB,aAAa,MAAM,KAClB,UAOF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,aAGvC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAM9E"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { type ChartScaleFunction } from './scale';
|
|
2
|
+
import type { Transition } from './transition';
|
|
3
|
+
/**
|
|
4
|
+
* Default enter transition for path-based components (Line, Area).
|
|
5
|
+
* `{ type: 'timing', duration: 500 }`
|
|
6
|
+
*/
|
|
7
|
+
export declare const defaultPathEnterTransition: Transition;
|
|
2
8
|
export type ChartPathCurveType =
|
|
3
9
|
| 'bump'
|
|
4
10
|
| 'catmullRom'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/path.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/path.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,SAAS,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,UAGxC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,YAAY,GACZ,QAAQ,GACR,cAAc,GACd,UAAU,GACV,SAAS,GACT,MAAM,GACN,YAAY,GACZ,WAAW,CAAC;AAEhB;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAO,kBAA6B,oCAsBxE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GAAI,uDAOzB;IACD,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IACnD,KAAK,CAAC,E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type SkPath } from '@shopify/react-native-skia';
|
|
|
18
18
|
* // Timing animation
|
|
19
19
|
* { type: 'timing', duration: 500, easing: Easing.inOut(Easing.ease) }
|
|
20
20
|
*/
|
|
21
|
-
export type Transition =
|
|
21
|
+
export type Transition = (
|
|
22
22
|
| ({
|
|
23
23
|
type: 'timing';
|
|
24
24
|
} & WithTimingConfig)
|
|
25
25
|
| ({
|
|
26
26
|
type: 'spring';
|
|
27
|
-
} & WithSpringConfig)
|
|
27
|
+
} & WithSpringConfig)
|
|
28
|
+
) & {
|
|
29
|
+
/**
|
|
30
|
+
* Delay in milliseconds (ms) before the animation starts.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Wait 2 seconds before animating
|
|
34
|
+
* { type: 'timing', duration: 500, delay: 2000 }
|
|
35
|
+
*/
|
|
36
|
+
delay?: number;
|
|
37
|
+
};
|
|
28
38
|
/**
|
|
29
|
-
* Default transition
|
|
39
|
+
* Default update transition used across all chart components.
|
|
40
|
+
* `{ type: 'spring', stiffness: 900, damping: 120 }`
|
|
30
41
|
*/
|
|
31
42
|
export declare const defaultTransition: Transition;
|
|
43
|
+
/**
|
|
44
|
+
* Instant transition that completes immediately with no animation.
|
|
45
|
+
* Used when a transition is set to `null`.
|
|
46
|
+
*/
|
|
47
|
+
export declare const instantTransition: Transition;
|
|
32
48
|
/**
|
|
33
49
|
* Duration in milliseconds for accessory elements to fade in.
|
|
34
50
|
*/
|
|
@@ -38,19 +54,20 @@ export declare const accessoryFadeTransitionDuration = 150;
|
|
|
38
54
|
*/
|
|
39
55
|
export declare const accessoryFadeTransitionDelay = 350;
|
|
40
56
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* @param progress - Shared value between 0 and 1
|
|
45
|
-
* @param fromPath - Starting path as SVG string
|
|
46
|
-
* @param toPath - Ending path as SVG string
|
|
47
|
-
* @returns Interpolated SkPath as a shared value
|
|
57
|
+
* Default enter transition for accessory elements (Point, Scrubber beacons).
|
|
58
|
+
* `{ type: 'timing', duration: 150, delay: 350 }`
|
|
48
59
|
*/
|
|
49
|
-
export declare const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
export declare const defaultAccessoryEnterTransition: Transition;
|
|
61
|
+
/**
|
|
62
|
+
* Resolves a transition value based on the animation state and a default.
|
|
63
|
+
* @note Passing in null will disable an animation.
|
|
64
|
+
* @note Passing in undefined will use the provided default.
|
|
65
|
+
*/
|
|
66
|
+
export declare const getTransition: (
|
|
67
|
+
value: Transition | null | undefined,
|
|
68
|
+
animate: boolean,
|
|
69
|
+
defaultValue: Transition,
|
|
70
|
+
) => Transition;
|
|
54
71
|
/**
|
|
55
72
|
* @worklet
|
|
56
73
|
*/
|
|
@@ -96,15 +113,16 @@ export declare const buildTransition: (targetValue: number, transition: Transiti
|
|
|
96
113
|
*
|
|
97
114
|
* @param currentPath - Current target path to animate to
|
|
98
115
|
* @param initialPath - Initial path for enter animation. When provided, the first animation will go from initialPath to currentPath.
|
|
99
|
-
* @param
|
|
116
|
+
* @param transitions - Transition configuration for enter and update animations
|
|
100
117
|
* @returns Animated SkPath as a shared value
|
|
101
118
|
*
|
|
102
119
|
* @example
|
|
103
120
|
* // Simple path transition
|
|
104
121
|
* const path = usePathTransition({
|
|
105
122
|
* currentPath: d ?? '',
|
|
106
|
-
*
|
|
107
|
-
*
|
|
123
|
+
* transitions: {
|
|
124
|
+
* update: { type: 'timing', duration: 3000 },
|
|
125
|
+
* },
|
|
108
126
|
* });
|
|
109
127
|
*
|
|
110
128
|
* @example
|
|
@@ -112,13 +130,16 @@ export declare const buildTransition: (targetValue: number, transition: Transiti
|
|
|
112
130
|
* const path = usePathTransition({
|
|
113
131
|
* currentPath: targetPath,
|
|
114
132
|
* initialPath: baselinePath,
|
|
115
|
-
*
|
|
116
|
-
*
|
|
133
|
+
* transitions: {
|
|
134
|
+
* enter: { type: 'tween', duration: 500 },
|
|
135
|
+
* update: { type: 'spring', stiffness: 900, damping: 120 },
|
|
136
|
+
* },
|
|
117
137
|
* });
|
|
118
138
|
*/
|
|
119
139
|
export declare const usePathTransition: ({
|
|
120
140
|
currentPath,
|
|
121
141
|
initialPath,
|
|
142
|
+
transitions,
|
|
122
143
|
transition,
|
|
123
144
|
}: {
|
|
124
145
|
/**
|
|
@@ -132,7 +153,24 @@ export declare const usePathTransition: ({
|
|
|
132
153
|
*/
|
|
133
154
|
initialPath?: string;
|
|
134
155
|
/**
|
|
135
|
-
* Transition configuration
|
|
156
|
+
* Transition configuration for enter and update animations.
|
|
157
|
+
*/
|
|
158
|
+
transitions?: {
|
|
159
|
+
/**
|
|
160
|
+
* Transition for the initial enter animation (initialPath → currentPath).
|
|
161
|
+
* Only used when `initialPath` is provided.
|
|
162
|
+
* If not provided, falls back to `update`.
|
|
163
|
+
*/
|
|
164
|
+
enter?: Transition;
|
|
165
|
+
/**
|
|
166
|
+
* Transition for subsequent data update animations.
|
|
167
|
+
* @default defaultTransition
|
|
168
|
+
*/
|
|
169
|
+
update?: Transition;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Transition for updates.
|
|
173
|
+
* @deprecated Use `transitions.update` instead.
|
|
136
174
|
*/
|
|
137
175
|
transition?: Transition;
|
|
138
176
|
}) => SharedValue<SkPath>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/transition.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/transition.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAKhB,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAsB,KAAK,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAG7E;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;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,iBAAiB,GAAI,wDAK/B;IACD;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,WAAW,CAAC,EAAE;QACZ;;;;WAIG;QACH,KAAK,CAAC,EAAE,UAAU,CAAC;QACnB;;;WAGG;QACH,MAAM,CAAC,EAAE,UAAU,CAAC;KACrB,CAAC;IACF;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,KAAG,WAAW,CAAC,MAAM,CAoErB,CAAC"}
|
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,12 +82,16 @@ 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]);
|
|
93
95
|
|
|
94
96
|
// The clip offset provides extra padding to prevent path from being cut off
|
|
95
97
|
// Area charts typically use offset=0 for exact clipping, while lines use offset=2 for breathing room
|
|
@@ -97,15 +99,11 @@ export const Path = /*#__PURE__*/memo(props => {
|
|
|
97
99
|
|
|
98
100
|
// Animation progress for clip path reveal
|
|
99
101
|
const clipProgress = useSharedValue(animate ? 0 : 1);
|
|
100
|
-
|
|
101
|
-
// Trigger clip path animation when component mounts and animate is true
|
|
102
102
|
useEffect(() => {
|
|
103
|
-
if (animate) {
|
|
104
|
-
clipProgress.value =
|
|
105
|
-
duration: pathEnterTransitionDuration
|
|
106
|
-
});
|
|
103
|
+
if (animate && isReady) {
|
|
104
|
+
clipProgress.value = buildTransition(1, enterTransition);
|
|
107
105
|
}
|
|
108
|
-
}, [animate, clipProgress]);
|
|
106
|
+
}, [animate, isReady, clipProgress, enterTransition]);
|
|
109
107
|
|
|
110
108
|
// Create initial and target clip paths for animation
|
|
111
109
|
const {
|
|
@@ -200,7 +198,10 @@ export const Path = /*#__PURE__*/memo(props => {
|
|
|
200
198
|
strokeJoin: strokeJoin,
|
|
201
199
|
strokeOpacity: strokeOpacity,
|
|
202
200
|
strokeWidth: strokeWidth,
|
|
203
|
-
|
|
201
|
+
transitions: {
|
|
202
|
+
enter: enterTransition,
|
|
203
|
+
update: updateTransition
|
|
204
|
+
},
|
|
204
205
|
children: children
|
|
205
206
|
});
|
|
206
207
|
|
|
@@ -7,7 +7,7 @@ import { Example, ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScr
|
|
|
7
7
|
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
8
8
|
import { Box, HStack, VStack } from '@coinbase/cds-mobile/layout';
|
|
9
9
|
import { Text } from '@coinbase/cds-mobile/typography';
|
|
10
|
-
import { Circle, Group
|
|
10
|
+
import { Circle, Group } from '@shopify/react-native-skia';
|
|
11
11
|
import { Area } from '../area/Area';
|
|
12
12
|
import { XAxis, YAxis } from '../axis';
|
|
13
13
|
import { BarPlot } from '../bar/BarPlot';
|
|
@@ -485,80 +485,6 @@ function TradingTrends() {
|
|
|
485
485
|
})]
|
|
486
486
|
});
|
|
487
487
|
}
|
|
488
|
-
const UVGradient = {
|
|
489
|
-
axis: 'y',
|
|
490
|
-
stops: [{
|
|
491
|
-
offset: 0,
|
|
492
|
-
color: 'green'
|
|
493
|
-
}, {
|
|
494
|
-
offset: 3,
|
|
495
|
-
color: 'yellow'
|
|
496
|
-
}, {
|
|
497
|
-
offset: 5,
|
|
498
|
-
color: 'orange'
|
|
499
|
-
}, {
|
|
500
|
-
offset: 8,
|
|
501
|
-
color: 'red'
|
|
502
|
-
}, {
|
|
503
|
-
offset: 10,
|
|
504
|
-
color: 'purple'
|
|
505
|
-
}]
|
|
506
|
-
};
|
|
507
|
-
const PreviousData = /*#__PURE__*/memo(_ref0 => {
|
|
508
|
-
let {
|
|
509
|
-
children,
|
|
510
|
-
currentHour,
|
|
511
|
-
clipOffset = 0
|
|
512
|
-
} = _ref0;
|
|
513
|
-
// we will clip the data to the current hour
|
|
514
|
-
const {
|
|
515
|
-
drawingArea,
|
|
516
|
-
getXScale
|
|
517
|
-
} = useCartesianChartContext();
|
|
518
|
-
const xScale = getXScale();
|
|
519
|
-
const currentHourX = xScale == null ? void 0 : xScale(currentHour);
|
|
520
|
-
const clipPath = useMemo(() => {
|
|
521
|
-
if (!xScale || currentHourX === undefined) return null;
|
|
522
|
-
|
|
523
|
-
// Create a rectangle from top-left of drawing area to currentHourX on the right
|
|
524
|
-
// Apply clipOffset to left, top, and bottom edges only (NOT to currentHourX)
|
|
525
|
-
const pathString = "M " + (drawingArea.x - clipOffset) + " " + (drawingArea.y - clipOffset) + " L " + currentHourX + " " + (drawingArea.y - clipOffset) + " L " + currentHourX + " " + (drawingArea.y + drawingArea.height + clipOffset) + " L " + (drawingArea.x - clipOffset) + " " + (drawingArea.y + drawingArea.height + clipOffset) + " Z";
|
|
526
|
-
return Skia.Path.MakeFromSVGString(pathString);
|
|
527
|
-
}, [xScale, currentHourX, drawingArea, clipOffset]);
|
|
528
|
-
if (!clipPath) return null;
|
|
529
|
-
return /*#__PURE__*/_jsx(Group, {
|
|
530
|
-
clip: clipPath,
|
|
531
|
-
opacity: 0.75,
|
|
532
|
-
children: children
|
|
533
|
-
});
|
|
534
|
-
});
|
|
535
|
-
const FutureData = /*#__PURE__*/memo(_ref1 => {
|
|
536
|
-
let {
|
|
537
|
-
children,
|
|
538
|
-
currentHour,
|
|
539
|
-
clipOffset = 0
|
|
540
|
-
} = _ref1;
|
|
541
|
-
// we will clip the data from the current hour to the right edge
|
|
542
|
-
const {
|
|
543
|
-
drawingArea,
|
|
544
|
-
getXScale
|
|
545
|
-
} = useCartesianChartContext();
|
|
546
|
-
const xScale = getXScale();
|
|
547
|
-
const currentHourX = xScale == null ? void 0 : xScale(currentHour);
|
|
548
|
-
const clipPath = useMemo(() => {
|
|
549
|
-
if (!xScale || currentHourX === undefined) return null;
|
|
550
|
-
|
|
551
|
-
// Create a rectangle from currentHourX to right edge of drawing area
|
|
552
|
-
// Apply clipOffset to top, bottom, and right, but NOT left (currentHourX)
|
|
553
|
-
const pathString = "M " + currentHourX + " " + (drawingArea.y - clipOffset) + " L " + (drawingArea.x + drawingArea.width + clipOffset) + " " + (drawingArea.y - clipOffset) + " L " + (drawingArea.x + drawingArea.width + clipOffset) + " " + (drawingArea.y + drawingArea.height + clipOffset) + " L " + currentHourX + " " + (drawingArea.y + drawingArea.height + clipOffset) + " Z";
|
|
554
|
-
return Skia.Path.MakeFromSVGString(pathString);
|
|
555
|
-
}, [xScale, currentHourX, drawingArea, clipOffset]);
|
|
556
|
-
if (!clipPath) return null;
|
|
557
|
-
return /*#__PURE__*/_jsx(Group, {
|
|
558
|
-
clip: clipPath,
|
|
559
|
-
children: children
|
|
560
|
-
});
|
|
561
|
-
});
|
|
562
488
|
const ScatterplotWithCustomLabels = /*#__PURE__*/memo(() => {
|
|
563
489
|
const theme = useTheme();
|
|
564
490
|
const dataPoints = useMemo(() => [{
|
|
@@ -642,13 +568,13 @@ const ScatterplotWithCustomLabels = /*#__PURE__*/memo(() => {
|
|
|
642
568
|
const yMax = Math.max(...yValues);
|
|
643
569
|
|
|
644
570
|
// Custom label component that places labels to the top-right
|
|
645
|
-
const TopRightPointLabel = useCallback(
|
|
571
|
+
const TopRightPointLabel = useCallback(_ref0 => {
|
|
646
572
|
let {
|
|
647
573
|
x,
|
|
648
574
|
y,
|
|
649
575
|
offset = 0,
|
|
650
576
|
children
|
|
651
|
-
} =
|
|
577
|
+
} = _ref0;
|
|
652
578
|
return /*#__PURE__*/_jsx(ChartText, {
|
|
653
579
|
font: "label1",
|
|
654
580
|
fontWeight: 600,
|