@coinbase/cds-mobile-visualization 3.4.0-beta.10 → 3.4.0-beta.11
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 +6 -0
- package/dts/chart/axis/Axis.d.ts +19 -41
- package/dts/chart/axis/Axis.d.ts.map +1 -1
- package/dts/chart/axis/XAxis.d.ts.map +1 -1
- package/dts/chart/axis/YAxis.d.ts.map +1 -1
- package/dts/chart/line/Line.d.ts +13 -11
- package/dts/chart/line/Line.d.ts.map +1 -1
- package/dts/chart/utils/axis.d.ts +25 -1
- package/dts/chart/utils/axis.d.ts.map +1 -1
- package/dts/chart/utils/point.d.ts +17 -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/esm/chart/axis/Axis.js +5 -41
- package/esm/chart/axis/XAxis.js +102 -27
- package/esm/chart/axis/YAxis.js +100 -23
- package/esm/chart/axis/__stories__/Axis.stories.js +259 -0
- package/esm/chart/bar/__stories__/BarChart.stories.js +39 -0
- package/esm/chart/utils/axis.js +45 -29
- package/esm/chart/utils/point.js +64 -21
- package/esm/chart/utils/scale.js +13 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,12 @@ All notable changes to this project will be documented in this file.
|
|
|
8
8
|
|
|
9
9
|
<!-- template-start -->
|
|
10
10
|
|
|
11
|
+
## 3.4.0-beta.11 (1/7/2026 PST)
|
|
12
|
+
|
|
13
|
+
#### 🐞 Fixes
|
|
14
|
+
|
|
15
|
+
- Allow customization of axis tick mark and grid line alignment in band scale. [[#291](https://github.com/coinbase/cds/pull/291)]
|
|
16
|
+
|
|
11
17
|
## 3.4.0-beta.10 (1/6/2026 PST)
|
|
12
18
|
|
|
13
19
|
#### 🐞 Fixes
|
package/dts/chart/axis/Axis.d.ts
CHANGED
|
@@ -1,49 +1,13 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import { type LineComponent } from '../line';
|
|
3
3
|
import type { ChartTextChildren, ChartTextProps } from '../text/ChartText';
|
|
4
|
+
import { type AxisBandPlacement } from '../utils';
|
|
4
5
|
/**
|
|
5
|
-
* Animation
|
|
6
|
-
*
|
|
7
|
-
* Web uses similar variants with delay to match path enter animation timing.
|
|
6
|
+
* Animation transition for axis elements (grid lines, tick marks, tick labels).
|
|
7
|
+
* Matches web's axisUpdateAnimationTransition timing.
|
|
8
8
|
*/
|
|
9
|
-
export declare const
|
|
10
|
-
|
|
11
|
-
opacity: number;
|
|
12
|
-
};
|
|
13
|
-
animate: {
|
|
14
|
-
opacity: number;
|
|
15
|
-
transition: {
|
|
16
|
-
duration: number;
|
|
17
|
-
delay: number;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
exit: {
|
|
21
|
-
opacity: number;
|
|
22
|
-
transition: {
|
|
23
|
-
duration: number;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Animation variants for axis elements - updates (used for both grid lines and tick labels)
|
|
29
|
-
*/
|
|
30
|
-
export declare const axisUpdateAnimationVariants: {
|
|
31
|
-
initial: {
|
|
32
|
-
opacity: number;
|
|
33
|
-
};
|
|
34
|
-
animate: {
|
|
35
|
-
opacity: number;
|
|
36
|
-
transition: {
|
|
37
|
-
duration: number;
|
|
38
|
-
delay: number;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
exit: {
|
|
42
|
-
opacity: number;
|
|
43
|
-
transition: {
|
|
44
|
-
duration: number;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
9
|
+
export declare const axisUpdateAnimationTransition: {
|
|
10
|
+
duration: number;
|
|
47
11
|
};
|
|
48
12
|
export type AxisTickLabelComponentProps = Pick<
|
|
49
13
|
ChartTextProps,
|
|
@@ -64,6 +28,20 @@ export type AxisTickLabelComponentProps = Pick<
|
|
|
64
28
|
>;
|
|
65
29
|
export type AxisTickLabelComponent = React.FC<AxisTickLabelComponentProps>;
|
|
66
30
|
export type AxisBaseProps = {
|
|
31
|
+
/**
|
|
32
|
+
* Placement of grid lines relative to each band.
|
|
33
|
+
* Options: 'start', 'middle', 'end', 'edges'
|
|
34
|
+
* @note This property only applies to band scales.
|
|
35
|
+
* @default 'edges'
|
|
36
|
+
*/
|
|
37
|
+
bandGridLinePlacement?: AxisBandPlacement;
|
|
38
|
+
/**
|
|
39
|
+
* Placement of tick marks relative to each band.
|
|
40
|
+
* Options: 'start', 'middle', 'end', 'edges'
|
|
41
|
+
* @note This property only applies to band scales.
|
|
42
|
+
* @default 'middle'
|
|
43
|
+
*/
|
|
44
|
+
bandTickMarkPlacement?: AxisBandPlacement;
|
|
67
45
|
/**
|
|
68
46
|
* Label text to display for the axis.
|
|
69
47
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Axis.d.ts","sourceRoot":"","sources":["../../../src/chart/axis/Axis.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Axis.d.ts","sourceRoot":"","sources":["../../../src/chart/axis/Axis.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAmC,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEnF;;;GAGG;AACH,eAAO,MAAM,6BAA6B;;CAEzC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAC5C,cAAc,EACZ,GAAG,GACH,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AGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,aAAa,CAAC;IACtC;;;;;;;;;;;;;OAaG;IACH,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,iBAAiB,CAAC;IAC1D;;;;;;;;;;OAUG;IACH,kBAAkB,CAAC,EAAE,sBAAsB,CAAC;CAC7C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XAxis.d.ts","sourceRoot":"","sources":["../../../src/chart/axis/XAxis.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"XAxis.d.ts","sourceRoot":"","sources":["../../../src/chart/axis/XAxis.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAM5D,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC5B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,cAAc,CAAC;AAEpD,eAAO,MAAM,KAAK,kDA8RjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YAxis.d.ts","sourceRoot":"","sources":["../../../src/chart/axis/YAxis.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"YAxis.d.ts","sourceRoot":"","sources":["../../../src/chart/axis/YAxis.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAM5D,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,cAAc,CAAC;AAEpD,eAAO,MAAM,KAAK,kDAuRjB,CAAC"}
|
package/dts/chart/line/Line.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type AnimatedProp } from '@shopify/react-native-skia';
|
|
3
3
|
import { type AreaComponent } from '../area/Area';
|
|
4
|
+
import { type PathProps } from '../Path';
|
|
4
5
|
import { type PointBaseProps, type PointProps } from '../point';
|
|
5
6
|
import { type ChartPathCurveType, type GradientDefinition, type Transition } from '../utils';
|
|
6
7
|
export type LineBaseProps = {
|
|
@@ -99,17 +100,18 @@ export type LineProps = LineBaseProps & {
|
|
|
99
100
|
export type LineComponentProps = Pick<
|
|
100
101
|
LineProps,
|
|
101
102
|
'stroke' | 'strokeOpacity' | 'strokeWidth' | 'gradient' | 'animate' | 'transition'
|
|
102
|
-
> &
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
103
|
+
> &
|
|
104
|
+
Pick<PathProps, 'clipPath' | 'strokeCap'> & {
|
|
105
|
+
/**
|
|
106
|
+
* Path of the line
|
|
107
|
+
*/
|
|
108
|
+
d: AnimatedProp<string | undefined>;
|
|
109
|
+
/**
|
|
110
|
+
* ID of the y-axis to use.
|
|
111
|
+
* If not provided, defaults to the default y-axis.
|
|
112
|
+
*/
|
|
113
|
+
yAxisId?: string;
|
|
114
|
+
};
|
|
113
115
|
export type LineComponent = React.FC<LineComponentProps>;
|
|
114
116
|
export declare const Line: React.NamedExoticComponent<LineProps>;
|
|
115
117
|
//# sourceMappingURL=Line.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Line.d.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
|
import type { Rect } from '@coinbase/cds-common/types';
|
|
3
3
|
import { type AxisBounds, type Series } from './chart';
|
|
4
|
-
import { type ChartAxisScaleType, type ChartScaleFunction } from './scale';
|
|
4
|
+
import { type ChartAxisScaleType, type ChartScaleFunction, type PointAnchor } from './scale';
|
|
5
5
|
export declare const defaultAxisId = 'DEFAULT_AXIS_ID';
|
|
6
6
|
export declare const defaultAxisScaleType = 'linear';
|
|
7
|
+
/**
|
|
8
|
+
* Position options for band scale axis elements (grid lines, tick marks, labels).
|
|
9
|
+
*
|
|
10
|
+
* - `'start'` - At the start of each step (before bar padding)
|
|
11
|
+
* - `'middle'` - At the center of each band
|
|
12
|
+
* - `'end'` - At the end of each step (after bar padding)
|
|
13
|
+
* - `'edges'` - At start of each tick, plus end for the last tick (encloses the chart)
|
|
14
|
+
*
|
|
15
|
+
* @note These properties only apply when using a band scale (`scaleType: 'band'`).
|
|
16
|
+
*/
|
|
17
|
+
export type AxisBandPlacement = 'start' | 'middle' | 'end' | 'edges';
|
|
18
|
+
/**
|
|
19
|
+
* Converts an AxisBandPlacement to the corresponding PointAnchor for use with getPointOnScale.
|
|
20
|
+
*
|
|
21
|
+
* @param placement - The axis placement value
|
|
22
|
+
* @returns The corresponding PointAnchor for scale calculations
|
|
23
|
+
*/
|
|
24
|
+
export declare const toPointAnchor: (placement: AxisBandPlacement) => PointAnchor;
|
|
7
25
|
/**
|
|
8
26
|
* Axis configuration with computed bounds
|
|
9
27
|
*/
|
|
@@ -154,6 +172,12 @@ type TickGenerationOptions = {
|
|
|
154
172
|
* @default 4
|
|
155
173
|
*/
|
|
156
174
|
minTickCount?: number;
|
|
175
|
+
/**
|
|
176
|
+
* Anchor position for band/categorical scales.
|
|
177
|
+
* Controls where tick labels are positioned within each band.
|
|
178
|
+
* @default 'middle'
|
|
179
|
+
*/
|
|
180
|
+
anchor?: PointAnchor;
|
|
157
181
|
};
|
|
158
182
|
export type GetAxisTicksDataProps = {
|
|
159
183
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axis.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/axis.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EACL,KAAK,UAAU,EAIf,KAAK,MAAM,EACZ,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"axis.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/axis.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EACL,KAAK,UAAU,EAIf,KAAK,MAAM,EACZ,MAAM,SAAS,CAAC;AAEjB,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EAMvB,KAAK,WAAW,EACjB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAC/C,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAE7C;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,WAAW,iBAAiB,KAAG,WAW5D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,+BAA+B;IAC/B,SAAS,EAAE,kBAAkB,CAAC;IAC9B;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IACnB;;OAEG;IACH,KAAK,EAAE,UAAU,CAAC;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAC3B;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,WAAW,EAAE,MAAM,GAAG,QAAQ,C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,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;uBAIvB,MAAM,YAAY,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,QAAQ,MAAM;yBAclC,MAAM;CAwB/C,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TextHorizontalAlignment, TextVerticalAlignment } from '../text';
|
|
2
|
-
import { type ChartScaleFunction, type SerializableScale } from './scale';
|
|
2
|
+
import { type ChartScaleFunction, type PointAnchor, type SerializableScale } from './scale';
|
|
3
3
|
/**
|
|
4
4
|
* Position a label should be placed relative to the point
|
|
5
5
|
*
|
|
@@ -10,24 +10,29 @@ import { type ChartScaleFunction, type SerializableScale } from './scale';
|
|
|
10
10
|
export type PointLabelPosition = 'top' | 'bottom' | 'left' | 'right' | 'center';
|
|
11
11
|
/**
|
|
12
12
|
* Get a point from a data value and a scale.
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
17
|
-
* @returns
|
|
13
|
+
*
|
|
14
|
+
* @param dataValue - The data value to convert to a pixel position.
|
|
15
|
+
* @param scale - The scale function.
|
|
16
|
+
* @param anchor (@default 'middle') - For band scales, where to anchor the point within the band.
|
|
17
|
+
* @returns The pixel value (@default 0 if data value is not defined in scale).
|
|
18
18
|
*/
|
|
19
|
-
export declare const getPointOnScale: (
|
|
19
|
+
export declare const getPointOnScale: (
|
|
20
|
+
dataValue: number,
|
|
21
|
+
scale: ChartScaleFunction,
|
|
22
|
+
anchor?: PointAnchor,
|
|
23
|
+
) => number;
|
|
20
24
|
/**
|
|
21
25
|
* Get a point from a data value and a serializable scale (worklet-compatible).
|
|
22
|
-
*
|
|
23
|
-
* @
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @returns
|
|
26
|
+
*
|
|
27
|
+
* @param dataValue - The data value to convert to a pixel position.
|
|
28
|
+
* @param scale - The serializable scale function.
|
|
29
|
+
* @param anchor (@default 'middle') - For band scales, where to anchor the point within the band.
|
|
30
|
+
* @returns The pixel value (@default 0 if data value is not defined in scale).
|
|
27
31
|
*/
|
|
28
32
|
export declare function getPointOnSerializableScale(
|
|
29
33
|
dataValue: number,
|
|
30
34
|
scale: SerializableScale,
|
|
35
|
+
anchor?: PointAnchor,
|
|
31
36
|
): number;
|
|
32
37
|
/**
|
|
33
38
|
* Projects a single data point to pixel coordinates using serializable scales.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/point.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE9E,OAAO,
|
|
1
|
+
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/point.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE9E,OAAO,EAIL,KAAK,kBAAkB,EAIvB,KAAK,WAAW,EAEhB,KAAK,iBAAiB,EACvB,MAAM,SAAS,CAAC;AAEjB;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEhF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,WAAW,MAAM,EACjB,OAAO,kBAAkB,EACzB,SAAQ,WAAsB,KAC7B,MAgCF,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,iBAAiB,EACxB,MAAM,GAAE,WAAsB,GAC7B,MAAM,CAuCR;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,EAChD,CAAC,EACD,CAAC,EACD,MAAM,EACN,MAAM,GACP,EAAE;IACD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,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AAC"}
|
|
@@ -47,6 +47,17 @@ export declare const getCategoricalScale: ({
|
|
|
47
47
|
range: AxisBounds;
|
|
48
48
|
padding?: number;
|
|
49
49
|
}) => CategoricalScale;
|
|
50
|
+
/**
|
|
51
|
+
* Anchor position for points on a scale. Currently used only for band scales.
|
|
52
|
+
*
|
|
53
|
+
* For band scales, this determines where within the band to position a point:
|
|
54
|
+
* - `'stepStart'` - At the start of the step
|
|
55
|
+
* - `'bandStart'` - At the start of the band
|
|
56
|
+
* - `'middle'` - At the center of the band
|
|
57
|
+
* - `'bandEnd'` - At the end of the band
|
|
58
|
+
* - `'stepEnd'` - At the end of the step
|
|
59
|
+
*/
|
|
60
|
+
export type PointAnchor = 'stepStart' | 'bandStart' | 'middle' | 'bandEnd' | 'stepEnd';
|
|
50
61
|
/**
|
|
51
62
|
* Convert a D3 scale to a serializable scale configuration that can be used in worklets
|
|
52
63
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scale.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/scale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAE3D,MAAM,MAAM,YAAY,GACpB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,GAClC,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAE5C,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAEjD,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,gBAAgB,CAAC;AAEjE,eAAO,MAAM,kBAAkB,GAAI,OAAO,kBAAkB,KAAG,KAAK,IAAI,gBAEvE,CAAC;AAEF,eAA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EAAE,KAAK,EAAE,uBAAuB,GAAG,MAAM,CAQ5F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAuBtF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,GAAG,MAAM,CAYxF;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAa5F"}
|
package/esm/chart/axis/Axis.js
CHANGED
|
@@ -1,45 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
* Animation variants for grouped axis tick labels - initial mount
|
|
3
|
-
* Note: Mobile currently doesn't use these variants. Axes render immediately without animation.
|
|
4
|
-
* Web uses similar variants with delay to match path enter animation timing.
|
|
5
|
-
*/
|
|
6
|
-
export const axisTickLabelsInitialAnimationVariants = {
|
|
7
|
-
initial: {
|
|
8
|
-
opacity: 0
|
|
9
|
-
},
|
|
10
|
-
animate: {
|
|
11
|
-
opacity: 1,
|
|
12
|
-
transition: {
|
|
13
|
-
duration: 0,
|
|
14
|
-
delay: 0
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
exit: {
|
|
18
|
-
opacity: 0,
|
|
19
|
-
transition: {
|
|
20
|
-
duration: 0.15
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
};
|
|
1
|
+
import { accessoryFadeTransitionDuration } from '../utils';
|
|
24
2
|
|
|
25
3
|
/**
|
|
26
|
-
* Animation
|
|
4
|
+
* Animation transition for axis elements (grid lines, tick marks, tick labels).
|
|
5
|
+
* Matches web's axisUpdateAnimationTransition timing.
|
|
27
6
|
*/
|
|
28
|
-
export const
|
|
29
|
-
|
|
30
|
-
opacity: 0
|
|
31
|
-
},
|
|
32
|
-
animate: {
|
|
33
|
-
opacity: 1,
|
|
34
|
-
transition: {
|
|
35
|
-
duration: 0.15,
|
|
36
|
-
delay: 0.15 // For updates: fade out 150ms, then fade in 150ms
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
exit: {
|
|
40
|
-
opacity: 0,
|
|
41
|
-
transition: {
|
|
42
|
-
duration: 0.15
|
|
43
|
-
}
|
|
44
|
-
}
|
|
7
|
+
export const axisUpdateAnimationTransition = {
|
|
8
|
+
duration: accessoryFadeTransitionDuration
|
|
45
9
|
};
|
package/esm/chart/axis/XAxis.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
const _excluded = ["position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "tickMinStep", "tickMaxStep", "label", "labelGap", "height"];
|
|
1
|
+
const _excluded = ["position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "tickMinStep", "tickMaxStep", "label", "labelGap", "height", "bandGridLinePlacement", "bandTickMarkPlacement"];
|
|
2
2
|
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; }
|
|
3
3
|
import { memo, useCallback, useEffect, useId, useMemo } from 'react';
|
|
4
4
|
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
5
5
|
import { Group } from '@shopify/react-native-skia';
|
|
6
6
|
import { useCartesianChartContext } from '../ChartProvider';
|
|
7
7
|
import { DottedLine } from '../line/DottedLine';
|
|
8
|
-
import { ReferenceLine } from '../line/ReferenceLine';
|
|
9
8
|
import { SolidLine } from '../line/SolidLine';
|
|
10
9
|
import { ChartText } from '../text/ChartText';
|
|
11
10
|
import { ChartTextGroup } from '../text/ChartTextGroup';
|
|
12
|
-
import { getAxisTicksData, isCategoricalScale, lineToPath } from '../utils';
|
|
11
|
+
import { getAxisTicksData, getPointOnScale, isCategoricalScale, lineToPath, toPointAnchor } from '../utils';
|
|
13
12
|
import { DefaultAxisTickLabel } from './DefaultAxisTickLabel';
|
|
14
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
14
|
const AXIS_HEIGHT = 32;
|
|
@@ -35,13 +34,16 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
35
34
|
tickMaxStep,
|
|
36
35
|
label,
|
|
37
36
|
labelGap = 4,
|
|
38
|
-
height = label ? AXIS_HEIGHT + LABEL_SIZE : AXIS_HEIGHT
|
|
37
|
+
height = label ? AXIS_HEIGHT + LABEL_SIZE : AXIS_HEIGHT,
|
|
38
|
+
bandGridLinePlacement = 'edges',
|
|
39
|
+
bandTickMarkPlacement = 'middle'
|
|
39
40
|
} = _ref,
|
|
40
41
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
41
42
|
const theme = useTheme();
|
|
42
43
|
const registrationId = useId();
|
|
43
44
|
const {
|
|
44
45
|
animate,
|
|
46
|
+
drawingArea,
|
|
45
47
|
getXScale,
|
|
46
48
|
getXAxis,
|
|
47
49
|
registerAxis,
|
|
@@ -51,10 +53,6 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
51
53
|
const xScale = getXScale();
|
|
52
54
|
const xAxis = getXAxis();
|
|
53
55
|
const axisBounds = getAxisBounds(registrationId);
|
|
54
|
-
|
|
55
|
-
// Note: gridOpacity not currently used in Skia version
|
|
56
|
-
// const gridOpacity = useSharedValue(1);
|
|
57
|
-
|
|
58
56
|
useEffect(() => {
|
|
59
57
|
registerAxis(registrationId, position, height);
|
|
60
58
|
return () => unregisterAxis(registrationId);
|
|
@@ -112,6 +110,72 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
112
110
|
}
|
|
113
111
|
});
|
|
114
112
|
}, [ticks, xScale, requestedTickCount, tickInterval, tickMinStep, tickMaxStep, xAxis == null ? void 0 : xAxis.data]);
|
|
113
|
+
const isBandScale = useMemo(() => {
|
|
114
|
+
if (!xScale) return false;
|
|
115
|
+
return isCategoricalScale(xScale);
|
|
116
|
+
}, [xScale]);
|
|
117
|
+
|
|
118
|
+
// Compute grid line positions (including bounds closing line for band scales)
|
|
119
|
+
const gridLinePositions = useMemo(() => {
|
|
120
|
+
if (!xScale) return [];
|
|
121
|
+
return ticksData.flatMap((tick, index) => {
|
|
122
|
+
if (!isBandScale) {
|
|
123
|
+
return [{
|
|
124
|
+
x: tick.position,
|
|
125
|
+
key: "grid-" + tick.tick + "-" + index
|
|
126
|
+
}];
|
|
127
|
+
}
|
|
128
|
+
const bandScale = xScale;
|
|
129
|
+
const isLastTick = index === ticksData.length - 1;
|
|
130
|
+
const isEdges = bandGridLinePlacement === 'edges';
|
|
131
|
+
const startX = getPointOnScale(tick.tick, bandScale, toPointAnchor(bandGridLinePlacement));
|
|
132
|
+
const positions = [{
|
|
133
|
+
x: startX,
|
|
134
|
+
key: "grid-" + tick.tick + "-" + index
|
|
135
|
+
}];
|
|
136
|
+
|
|
137
|
+
// For edges on last tick, add the closing line at stepEnd
|
|
138
|
+
if (isLastTick && isEdges) {
|
|
139
|
+
const endX = getPointOnScale(tick.tick, bandScale, 'stepEnd');
|
|
140
|
+
positions.push({
|
|
141
|
+
x: endX,
|
|
142
|
+
key: "grid-" + tick.tick + "-" + index + "-end"
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return positions;
|
|
146
|
+
});
|
|
147
|
+
}, [ticksData, xScale, isBandScale, bandGridLinePlacement]);
|
|
148
|
+
|
|
149
|
+
// Compute tick mark positions (including bounds closing tick for band scales)
|
|
150
|
+
const tickMarkPositions = useMemo(() => {
|
|
151
|
+
if (!xScale) return [];
|
|
152
|
+
return ticksData.flatMap((tick, index) => {
|
|
153
|
+
if (!isBandScale) {
|
|
154
|
+
return [{
|
|
155
|
+
x: tick.position,
|
|
156
|
+
key: "tick-mark-" + tick.tick + "-" + index
|
|
157
|
+
}];
|
|
158
|
+
}
|
|
159
|
+
const bandScale = xScale;
|
|
160
|
+
const isLastTick = index === ticksData.length - 1;
|
|
161
|
+
const isEdges = bandTickMarkPlacement === 'edges';
|
|
162
|
+
const startX = getPointOnScale(tick.tick, bandScale, toPointAnchor(bandTickMarkPlacement));
|
|
163
|
+
const positions = [{
|
|
164
|
+
x: startX,
|
|
165
|
+
key: "tick-mark-" + tick.tick + "-" + index
|
|
166
|
+
}];
|
|
167
|
+
|
|
168
|
+
// For edges on last tick, add the closing tick mark at stepEnd
|
|
169
|
+
if (isLastTick && isEdges) {
|
|
170
|
+
const endX = getPointOnScale(tick.tick, bandScale, 'stepEnd');
|
|
171
|
+
positions.push({
|
|
172
|
+
x: endX,
|
|
173
|
+
key: "tick-mark-" + tick.tick + "-" + index + "-end"
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return positions;
|
|
177
|
+
});
|
|
178
|
+
}, [ticksData, xScale, isBandScale, bandTickMarkPlacement]);
|
|
115
179
|
const chartTextData = useMemo(() => {
|
|
116
180
|
if (!axisBounds) return null;
|
|
117
181
|
return ticksData.map(tick => {
|
|
@@ -121,11 +185,7 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
121
185
|
// This ensures tick labels are centered in the axis area, not including label space
|
|
122
186
|
const availableSpace = AXIS_HEIGHT - tickOffset;
|
|
123
187
|
const labelOffset = availableSpace / 2;
|
|
124
|
-
|
|
125
|
-
// For bottom position: start at axisBounds.y
|
|
126
|
-
// For top position with label: start at axisBounds.y + LABEL_SIZE
|
|
127
|
-
const baseY = position === 'top' && label ? axisBounds.y + LABEL_SIZE : axisBounds.y;
|
|
128
|
-
const labelY = position === 'top' ? baseY + labelOffset - tickOffset : baseY + labelOffset + tickOffset;
|
|
188
|
+
const labelY = position === 'top' ? axisBounds.y + axisBounds.height - tickOffset - labelOffset : axisBounds.y + labelOffset + tickOffset;
|
|
129
189
|
return {
|
|
130
190
|
x: tick.position,
|
|
131
191
|
y: labelY,
|
|
@@ -137,20 +197,33 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
137
197
|
}
|
|
138
198
|
};
|
|
139
199
|
});
|
|
140
|
-
}, [axisBounds, ticksData, theme.color.fgMuted, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick
|
|
200
|
+
}, [axisBounds, ticksData, theme.color.fgMuted, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick]);
|
|
141
201
|
if (!xScale || !axisBounds) return;
|
|
142
202
|
const labelX = axisBounds.x + axisBounds.width / 2;
|
|
143
203
|
const labelY = position === 'bottom' ? axisBounds.y + axisBounds.height - LABEL_SIZE / 2 : axisBounds.y + LABEL_SIZE / 2;
|
|
204
|
+
|
|
205
|
+
// Pre-compute tick mark Y coordinates
|
|
206
|
+
const tickYTop = axisBounds.y;
|
|
207
|
+
const tickYBottom = axisBounds.y + axisBounds.height;
|
|
208
|
+
const tickYStart = position === 'bottom' ? tickYTop : tickYBottom;
|
|
209
|
+
const tickYEnd = position === 'bottom' ? tickYTop + tickMarkSize : tickYBottom - tickMarkSize;
|
|
210
|
+
|
|
211
|
+
// Note: Unlike web, mobile renders grid lines and tick marks immediately without fade animation.
|
|
212
|
+
// This is because Skia can measure text dimensions synchronously, so there's no need to hide
|
|
213
|
+
// elements while waiting for measurements (web uses async ResizeObserver).
|
|
144
214
|
return /*#__PURE__*/_jsxs(Group, {
|
|
145
215
|
children: [showGrid && /*#__PURE__*/_jsx(Group, {
|
|
146
|
-
children:
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
return /*#__PURE__*/_jsx(
|
|
152
|
-
|
|
153
|
-
|
|
216
|
+
children: gridLinePositions.map(_ref2 => {
|
|
217
|
+
let {
|
|
218
|
+
x,
|
|
219
|
+
key
|
|
220
|
+
} = _ref2;
|
|
221
|
+
return /*#__PURE__*/_jsx(GridLineComponent, {
|
|
222
|
+
animate: false,
|
|
223
|
+
clipPath: null,
|
|
224
|
+
d: lineToPath(x, drawingArea.y, x, drawingArea.y + drawingArea.height),
|
|
225
|
+
stroke: theme.color.bgLine
|
|
226
|
+
}, key);
|
|
154
227
|
})
|
|
155
228
|
}), chartTextData && /*#__PURE__*/_jsx(ChartTextGroup, {
|
|
156
229
|
prioritizeEndLabels: true,
|
|
@@ -158,17 +231,19 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
158
231
|
labels: chartTextData,
|
|
159
232
|
minGap: minTickLabelGap
|
|
160
233
|
}), axisBounds && showTickMarks && /*#__PURE__*/_jsx(Group, {
|
|
161
|
-
children:
|
|
162
|
-
|
|
163
|
-
|
|
234
|
+
children: tickMarkPositions.map(_ref3 => {
|
|
235
|
+
let {
|
|
236
|
+
x,
|
|
237
|
+
key
|
|
238
|
+
} = _ref3;
|
|
164
239
|
return /*#__PURE__*/_jsx(TickMarkLineComponent, {
|
|
165
240
|
animate: false,
|
|
166
241
|
clipPath: null,
|
|
167
|
-
d: lineToPath(
|
|
242
|
+
d: lineToPath(x, tickYStart, x, tickYEnd),
|
|
168
243
|
stroke: theme.color.fg,
|
|
169
244
|
strokeCap: "square",
|
|
170
245
|
strokeWidth: 1
|
|
171
|
-
},
|
|
246
|
+
}, key);
|
|
172
247
|
})
|
|
173
248
|
}), showLine && /*#__PURE__*/_jsx(LineComponent, {
|
|
174
249
|
animate: false,
|