@coinbase/cds-mobile 9.13.0 → 9.14.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 +6 -0
- package/dts/visualizations/chart/axis/Axis.d.ts +12 -0
- package/dts/visualizations/chart/axis/Axis.d.ts.map +1 -1
- package/dts/visualizations/chart/axis/AxisTickLabelOverflowMask.d.ts +11 -0
- package/dts/visualizations/chart/axis/AxisTickLabelOverflowMask.d.ts.map +1 -0
- package/dts/visualizations/chart/axis/XAxis.d.ts.map +1 -1
- package/dts/visualizations/chart/axis/YAxis.d.ts.map +1 -1
- package/dts/visualizations/chart/axis/index.d.ts +1 -0
- package/dts/visualizations/chart/axis/index.d.ts.map +1 -1
- package/dts/visualizations/chart/line/ReferenceLine.d.ts +1 -0
- package/dts/visualizations/chart/line/ReferenceLine.d.ts.map +1 -1
- package/dts/visualizations/chart/text/ChartText.d.ts +20 -3
- package/dts/visualizations/chart/text/ChartText.d.ts.map +1 -1
- package/esm/visualizations/chart/axis/AxisTickLabelOverflowMask.js +44 -0
- package/esm/visualizations/chart/axis/XAxis.js +23 -10
- package/esm/visualizations/chart/axis/YAxis.js +23 -10
- package/esm/visualizations/chart/axis/__stories__/Axis.stories.js +276 -121
- package/esm/visualizations/chart/axis/index.js +1 -0
- package/esm/visualizations/chart/scrubber/DefaultScrubberBeaconLabel.js +1 -1
- package/esm/visualizations/chart/text/ChartText.js +21 -19
- package/package.json +2 -2
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
|
+
## 9.14.0 (8/11/2026 PST)
|
|
12
|
+
|
|
13
|
+
#### 🚀 Updates
|
|
14
|
+
|
|
15
|
+
- Feat: support different tick label overflow- #835. [[#835](https://github.com/coinbase/cds/pull/835)]
|
|
16
|
+
|
|
11
17
|
## 9.13.0 (8/11/2026 PST)
|
|
12
18
|
|
|
13
19
|
#### 🚀 Updates
|
|
@@ -25,8 +25,11 @@ export type AxisTickLabelComponentProps = Pick<
|
|
|
25
25
|
| 'horizontalAlignment'
|
|
26
26
|
| 'verticalAlignment'
|
|
27
27
|
| 'opacity'
|
|
28
|
+
| 'repositionAxes'
|
|
29
|
+
| 'disableRepositioning'
|
|
28
30
|
>;
|
|
29
31
|
export type AxisTickLabelComponent = React.FC<AxisTickLabelComponentProps>;
|
|
32
|
+
export type AxisTickLabelOverflow = 'reposition' | 'fade' | 'visible';
|
|
30
33
|
export type AxisBaseProps = {
|
|
31
34
|
/**
|
|
32
35
|
* Placement of grid lines relative to each band.
|
|
@@ -126,6 +129,15 @@ export type AxisBaseProps = {
|
|
|
126
129
|
* Prevents the step from being larger than this value.
|
|
127
130
|
*/
|
|
128
131
|
tickMaxStep?: number;
|
|
132
|
+
/**
|
|
133
|
+
* How tick labels behave at the chart edges.
|
|
134
|
+
* - `reposition` — nudge labels to stay in bounds on both axes.
|
|
135
|
+
* - `fade` — add a fade effect to the labels at the edges (vertical for y-axis, horizontal for x-axis),
|
|
136
|
+
* reposition on opposite axis (horizontal for y-axis, vertical for x-axis).
|
|
137
|
+
* - `visible` — leave labels at their natural positions with no fading.
|
|
138
|
+
* @default 'reposition'
|
|
139
|
+
*/
|
|
140
|
+
tickLabelOverflow?: AxisTickLabelOverflow;
|
|
129
141
|
};
|
|
130
142
|
export type AxisProps = AxisBaseProps & {
|
|
131
143
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Axis.d.ts","sourceRoot":"","sources":["../../../../src/visualizations/chart/axis/Axis.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,KAAK,i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'react';
|
|
2
|
+
import type { SharedProps } from '@coinbase/cds-common/types/SharedProps';
|
|
3
|
+
export type AxisTickLabelOverflowMaskProps = SharedProps &
|
|
4
|
+
PropsWithChildren<{
|
|
5
|
+
/**
|
|
6
|
+
* Fade along the chart edges for this axis (`x`: left/right, `y`: top/bottom).
|
|
7
|
+
*/
|
|
8
|
+
axis: 'x' | 'y';
|
|
9
|
+
}>;
|
|
10
|
+
export declare const AxisTickLabelOverflowMask: import('react').NamedExoticComponent<AxisTickLabelOverflowMaskProps>;
|
|
11
|
+
//# sourceMappingURL=AxisTickLabelOverflowMask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AxisTickLabelOverflowMask.d.ts","sourceRoot":"","sources":["../../../../src/visualizations/chart/axis/AxisTickLabelOverflowMask.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAS1E,MAAM,MAAM,8BAA8B,GAAG,WAAW,GACtD,iBAAiB,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,GAAG,GAAG,GAAG,CAAC;CACjB,CAAC,CAAC;AAEL,eAAO,MAAM,yBAAyB,sEAiCrC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XAxis.d.ts","sourceRoot":"","sources":["../../../../src/visualizations/chart/axis/XAxis.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"XAxis.d.ts","sourceRoot":"","sources":["../../../../src/visualizations/chart/axis/XAxis.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAO5D,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;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,kDAmTjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YAxis.d.ts","sourceRoot":"","sources":["../../../../src/visualizations/chart/axis/YAxis.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"YAxis.d.ts","sourceRoot":"","sources":["../../../../src/visualizations/chart/axis/YAxis.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAO5D,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C;;;;OAIG;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,kDA4SjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/visualizations/chart/axis/index.ts"],"names":[],"mappings":"AACA,cAAc,QAAQ,CAAC;AACvB,cAAc,wBAAwB,CAAC;AACvC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/visualizations/chart/axis/index.ts"],"names":[],"mappings":"AACA,cAAc,QAAQ,CAAC;AACvB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReferenceLine.d.ts","sourceRoot":"","sources":["../../../../src/visualizations/chart/line/ReferenceLine.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI/D,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5C,MAAM,MAAM,gCAAgC,GAAG,IAAI,CACjD,cAAc,EACZ,GAAG,GACH,GAAG,GACH,UAAU,GACV,OAAO,GACP,OAAO,GACP,YAAY,GACZ,cAAc,GACd,sBAAsB,GACtB,qBAAqB,GACrB,mBAAmB,GACnB,MAAM,GACN,YAAY,GACZ,cAAc,GACd,SAAS,GACT,IAAI,GACJ,IAAI,GACJ,UAAU,GACV,oBAAoB,CACvB,GAAG;IACF;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,KAAK,CAAC,EAAE,CAAC,gCAAgC,CAAC,CAAC;AAErF,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;OAGG;IACH,cAAc,CAAC,EAAE,2BAA2B,CAAC;IAC7C;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACnC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,wBAAwB,CAAC,EAAE,uBAAuB,CAAC;IACnD;;OAEG;IACH,sBAAsB,CAAC,EAAE,qBAAqB,CAAC;IAC/C;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IACvC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;CAChC,CAAC;AAEF,KAAK,4BAA4B,GAAG,sBAAsB,GAAG;IAC3D;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,KAAK,0BAA0B,GAAG,sBAAsB,GAAG;IACzD;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,4BAA4B,GAAG,0BAA0B,CAAC;AAE3F,eAAO,MAAM,aAAa,0DAoJzB,CAAC"}
|
|
1
|
+
{"version":3,"file":"ReferenceLine.d.ts","sourceRoot":"","sources":["../../../../src/visualizations/chart/line/ReferenceLine.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EA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,EAAE,MAAM,GAAG,UAAU,CAAC;IACvC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;CAChC,CAAC;AAEF,KAAK,4BAA4B,GAAG,sBAAsB,GAAG;IAC3D;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,KAAK,0BAA0B,GAAG,sBAAsB,GAAG;IACzD;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,4BAA4B,GAAG,0BAA0B,CAAC;AAE3F,eAAO,MAAM,aAAa,0DAoJzB,CAAC"}
|
|
@@ -21,6 +21,11 @@ export type TextHorizontalAlignment = 'left' | 'center' | 'right';
|
|
|
21
21
|
* Vertical alignment options for chart text.
|
|
22
22
|
*/
|
|
23
23
|
export type TextVerticalAlignment = 'top' | 'middle' | 'bottom';
|
|
24
|
+
/**
|
|
25
|
+
* Which axes ChartText may nudge labels along to stay in bounds.
|
|
26
|
+
* @default 'both'
|
|
27
|
+
*/
|
|
28
|
+
export type ChartTextRepositionAxes = 'x' | 'y' | 'both' | 'none';
|
|
24
29
|
export type ChartTextBaseProps = {
|
|
25
30
|
/**
|
|
26
31
|
* The text color.
|
|
@@ -37,7 +42,19 @@ export type ChartTextBaseProps = {
|
|
|
37
42
|
*/
|
|
38
43
|
elevated?: boolean;
|
|
39
44
|
/**
|
|
40
|
-
*
|
|
45
|
+
* Which axes to reposition labels on when they would overflow bounds.
|
|
46
|
+
* @default 'both'
|
|
47
|
+
*/
|
|
48
|
+
repositionAxes?: ChartTextRepositionAxes;
|
|
49
|
+
/**
|
|
50
|
+
* Disables automatic repositioning to fit within bounds.
|
|
51
|
+
*
|
|
52
|
+
* @note `true` is equivalent to `repositionAxes='none'`, `false`/omit equals `repositionAxes='both'`.
|
|
53
|
+
*
|
|
54
|
+
* @deprecated Use `repositionAxes` instead
|
|
55
|
+
*
|
|
56
|
+
* This will be removed in a future major release.
|
|
57
|
+
* @deprecationExpectedRemoval v11
|
|
41
58
|
*/
|
|
42
59
|
disableRepositioning?: boolean;
|
|
43
60
|
/**
|
|
@@ -88,12 +105,12 @@ export type ChartTextProps = ChartTextBaseProps & {
|
|
|
88
105
|
children: ChartTextChildren;
|
|
89
106
|
/**
|
|
90
107
|
* The desired x position in pixels.
|
|
91
|
-
* @note Text will be automatically positioned to fit within bounds
|
|
108
|
+
* @note Text will be automatically positioned to fit within bounds based on `repositionAxes`.
|
|
92
109
|
*/
|
|
93
110
|
x: AnimatedProp<number>;
|
|
94
111
|
/**
|
|
95
112
|
* The desired y position in pixels.
|
|
96
|
-
* @note Text will be automatically positioned to fit within bounds
|
|
113
|
+
* @note Text will be automatically positioned to fit within bounds based on `repositionAxes`.
|
|
97
114
|
*/
|
|
98
115
|
y: AnimatedProp<number>;
|
|
99
116
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartText.d.ts","sourceRoot":"","sources":["../../../../src/visualizations/chart/text/ChartText.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EACL,KAAK,YAAY,EAEjB,SAAS,EACT,UAAU,EAOV,KAAK,W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C;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,SAAS,sDA4TrB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { memo, useMemo } from 'react';
|
|
2
|
+
import { Group, LinearGradient, Rect, vec } from '@shopify/react-native-skia';
|
|
3
|
+
import { useCartesianChartContext } from '../ChartProvider';
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
const axisTickLabelOverflowFadeWidth = 30;
|
|
6
|
+
const maskOpaque = 'rgba(255, 255, 255, 1)';
|
|
7
|
+
const maskClear = 'rgba(255, 255, 255, 0)';
|
|
8
|
+
export const AxisTickLabelOverflowMask = /*#__PURE__*/memo(_ref => {
|
|
9
|
+
let {
|
|
10
|
+
axis,
|
|
11
|
+
children
|
|
12
|
+
} = _ref;
|
|
13
|
+
const {
|
|
14
|
+
width: chartWidth,
|
|
15
|
+
height: chartHeight
|
|
16
|
+
} = useCartesianChartContext();
|
|
17
|
+
const fadeWidth = axisTickLabelOverflowFadeWidth;
|
|
18
|
+
const isXAxis = axis === 'x';
|
|
19
|
+
const fadeX = Math.min(fadeWidth, chartWidth / 2) / Math.max(chartWidth, 1);
|
|
20
|
+
const fadeY = Math.min(fadeWidth, chartHeight / 2) / Math.max(chartHeight, 1);
|
|
21
|
+
const colors = useMemo(() => [maskClear, maskOpaque, maskOpaque, maskClear], []);
|
|
22
|
+
const positions = useMemo(() => isXAxis ? [0, fadeX, 1 - fadeX, 1] : [0, fadeY, 1 - fadeY, 1], [fadeX, fadeY, isXAxis]);
|
|
23
|
+
if (chartWidth <= 0 || chartHeight <= 0) {
|
|
24
|
+
return /*#__PURE__*/_jsx(Group, {
|
|
25
|
+
children: children
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return /*#__PURE__*/_jsxs(Group, {
|
|
29
|
+
layer: true,
|
|
30
|
+
children: [children, /*#__PURE__*/_jsx(Rect, {
|
|
31
|
+
blendMode: "dstIn",
|
|
32
|
+
height: chartHeight,
|
|
33
|
+
width: chartWidth,
|
|
34
|
+
x: 0,
|
|
35
|
+
y: 0,
|
|
36
|
+
children: /*#__PURE__*/_jsx(LinearGradient, {
|
|
37
|
+
colors: colors,
|
|
38
|
+
end: isXAxis ? vec(chartWidth, 0) : vec(0, chartHeight),
|
|
39
|
+
positions: positions,
|
|
40
|
+
start: vec(0, 0)
|
|
41
|
+
})
|
|
42
|
+
})]
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["axisId", "position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "tickMinStep", "tickMaxStep", "label", "labelGap", "height", "bandGridLinePlacement", "bandTickMarkPlacement"];
|
|
1
|
+
const _excluded = ["axisId", "position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "tickMinStep", "tickMaxStep", "label", "labelGap", "height", "bandGridLinePlacement", "bandTickMarkPlacement", "tickLabelOverflow"];
|
|
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 { Group } from '@shopify/react-native-skia';
|
|
@@ -12,6 +12,7 @@ import { getAxisTicksData, toPointAnchor } from '../utils/axis';
|
|
|
12
12
|
import { lineToPath } from '../utils/path';
|
|
13
13
|
import { getPointOnScale } from '../utils/point';
|
|
14
14
|
import { isCategoricalScale } from '../utils/scale';
|
|
15
|
+
import { AxisTickLabelOverflowMask } from './AxisTickLabelOverflowMask';
|
|
15
16
|
import { DefaultAxisTickLabel } from './DefaultAxisTickLabel';
|
|
16
17
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
18
|
const AXIS_HEIGHT = 32;
|
|
@@ -40,7 +41,8 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
40
41
|
labelGap = 4,
|
|
41
42
|
height = label ? AXIS_HEIGHT + LABEL_SIZE : AXIS_HEIGHT,
|
|
42
43
|
bandGridLinePlacement = 'edges',
|
|
43
|
-
bandTickMarkPlacement = 'middle'
|
|
44
|
+
bandTickMarkPlacement = 'middle',
|
|
45
|
+
tickLabelOverflow = 'reposition'
|
|
44
46
|
} = _ref,
|
|
45
47
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
46
48
|
const theme = useTheme();
|
|
@@ -55,6 +57,7 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
55
57
|
unregisterAxis,
|
|
56
58
|
getAxisBounds
|
|
57
59
|
} = useCartesianChartContext();
|
|
60
|
+
const fadeTickLabels = tickLabelOverflow === 'fade';
|
|
58
61
|
const xScale = getXScale(axisId);
|
|
59
62
|
const xAxis = getXAxis(axisId);
|
|
60
63
|
const axisBounds = getAxisBounds(registrationId);
|
|
@@ -189,11 +192,12 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
189
192
|
chartTextProps: {
|
|
190
193
|
color: theme.color.fgMuted,
|
|
191
194
|
verticalAlignment: 'middle',
|
|
192
|
-
horizontalAlignment: 'center'
|
|
195
|
+
horizontalAlignment: 'center',
|
|
196
|
+
repositionAxes: tickLabelOverflow === 'visible' ? 'none' : fadeTickLabels ? 'y' : 'both'
|
|
193
197
|
}
|
|
194
198
|
};
|
|
195
199
|
});
|
|
196
|
-
}, [axisBounds, ticksData, theme.color.fgMuted, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick]);
|
|
200
|
+
}, [axisBounds, ticksData, theme.color.fgMuted, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick, fadeTickLabels, tickLabelOverflow]);
|
|
197
201
|
if (!xScale || !axisBounds) return;
|
|
198
202
|
const labelX = axisBounds.x + axisBounds.width / 2;
|
|
199
203
|
const labelY = position === 'bottom' ? axisBounds.y + axisBounds.height - LABEL_SIZE / 2 : axisBounds.y + LABEL_SIZE / 2;
|
|
@@ -221,11 +225,6 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
221
225
|
stroke: theme.color.bgLine
|
|
222
226
|
}, key);
|
|
223
227
|
})
|
|
224
|
-
}), chartTextData && /*#__PURE__*/_jsx(ChartTextGroup, {
|
|
225
|
-
prioritizeEndLabels: true,
|
|
226
|
-
LabelComponent: TickLabelComponent,
|
|
227
|
-
labels: chartTextData,
|
|
228
|
-
minGap: minTickLabelGap
|
|
229
228
|
}), axisBounds && showTickMarks && /*#__PURE__*/_jsx(Group, {
|
|
230
229
|
children: tickMarkPositions.map(_ref3 => {
|
|
231
230
|
let {
|
|
@@ -248,8 +247,22 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
248
247
|
stroke: theme.color.fg,
|
|
249
248
|
strokeCap: "square",
|
|
250
249
|
strokeWidth: 1
|
|
251
|
-
}),
|
|
250
|
+
}), chartTextData && (fadeTickLabels ? /*#__PURE__*/_jsx(AxisTickLabelOverflowMask, {
|
|
251
|
+
axis: "x",
|
|
252
|
+
children: /*#__PURE__*/_jsx(ChartTextGroup, {
|
|
253
|
+
prioritizeEndLabels: true,
|
|
254
|
+
LabelComponent: TickLabelComponent,
|
|
255
|
+
labels: chartTextData,
|
|
256
|
+
minGap: minTickLabelGap
|
|
257
|
+
})
|
|
258
|
+
}) : /*#__PURE__*/_jsx(ChartTextGroup, {
|
|
259
|
+
prioritizeEndLabels: true,
|
|
260
|
+
LabelComponent: TickLabelComponent,
|
|
261
|
+
labels: chartTextData,
|
|
262
|
+
minGap: minTickLabelGap
|
|
263
|
+
})), label && /*#__PURE__*/_jsx(ChartText, {
|
|
252
264
|
horizontalAlignment: "center",
|
|
265
|
+
repositionAxes: "none",
|
|
253
266
|
verticalAlignment: "middle",
|
|
254
267
|
x: labelX,
|
|
255
268
|
y: labelY,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["axisId", "position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "label", "labelGap", "width", "bandGridLinePlacement", "bandTickMarkPlacement"];
|
|
1
|
+
const _excluded = ["axisId", "position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "label", "labelGap", "width", "bandGridLinePlacement", "bandTickMarkPlacement", "tickLabelOverflow"];
|
|
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 { Group, vec } from '@shopify/react-native-skia';
|
|
@@ -12,6 +12,7 @@ import { getAxisTicksData, toPointAnchor } from '../utils/axis';
|
|
|
12
12
|
import { lineToPath } from '../utils/path';
|
|
13
13
|
import { getPointOnScale } from '../utils/point';
|
|
14
14
|
import { isCategoricalScale } from '../utils/scale';
|
|
15
|
+
import { AxisTickLabelOverflowMask } from './AxisTickLabelOverflowMask';
|
|
15
16
|
import { DefaultAxisTickLabel } from './DefaultAxisTickLabel';
|
|
16
17
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
18
|
const AXIS_WIDTH = 44;
|
|
@@ -38,7 +39,8 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
|
38
39
|
labelGap = 4,
|
|
39
40
|
width = label ? AXIS_WIDTH + LABEL_SIZE : AXIS_WIDTH,
|
|
40
41
|
bandGridLinePlacement = 'edges',
|
|
41
|
-
bandTickMarkPlacement = 'middle'
|
|
42
|
+
bandTickMarkPlacement = 'middle',
|
|
43
|
+
tickLabelOverflow = 'reposition'
|
|
42
44
|
} = _ref,
|
|
43
45
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
44
46
|
const theme = useTheme();
|
|
@@ -53,6 +55,7 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
|
53
55
|
unregisterAxis,
|
|
54
56
|
getAxisBounds
|
|
55
57
|
} = useCartesianChartContext();
|
|
58
|
+
const fadeTickLabels = tickLabelOverflow === 'fade';
|
|
56
59
|
const yScale = getYScale(axisId);
|
|
57
60
|
const yAxis = getYAxis(axisId);
|
|
58
61
|
const axisBounds = getAxisBounds(registrationId);
|
|
@@ -182,11 +185,12 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
|
182
185
|
chartTextProps: {
|
|
183
186
|
color: theme.color.fgMuted,
|
|
184
187
|
verticalAlignment: 'middle',
|
|
185
|
-
horizontalAlignment: position === 'left' ? 'right' : 'left'
|
|
188
|
+
horizontalAlignment: position === 'left' ? 'right' : 'left',
|
|
189
|
+
repositionAxes: tickLabelOverflow === 'visible' ? 'none' : fadeTickLabels ? 'x' : 'both'
|
|
186
190
|
}
|
|
187
191
|
};
|
|
188
192
|
});
|
|
189
|
-
}, [axisBounds, ticksData, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick, theme.color.fgMuted]);
|
|
193
|
+
}, [axisBounds, ticksData, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick, theme.color.fgMuted, fadeTickLabels, tickLabelOverflow]);
|
|
190
194
|
if (!yScale || !axisBounds) return;
|
|
191
195
|
const labelX = position === 'left' ? axisBounds.x + LABEL_SIZE / 2 : axisBounds.x + axisBounds.width - LABEL_SIZE / 2;
|
|
192
196
|
const labelY = axisBounds.y + axisBounds.height / 2;
|
|
@@ -214,11 +218,6 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
|
214
218
|
stroke: theme.color.bgLine
|
|
215
219
|
}, key);
|
|
216
220
|
})
|
|
217
|
-
}), chartTextData && /*#__PURE__*/_jsx(ChartTextGroup, {
|
|
218
|
-
prioritizeEndLabels: true,
|
|
219
|
-
LabelComponent: TickLabelComponent,
|
|
220
|
-
labels: chartTextData,
|
|
221
|
-
minGap: minTickLabelGap
|
|
222
221
|
}), axisBounds && showTickMarks && /*#__PURE__*/_jsx(Group, {
|
|
223
222
|
children: tickMarkPositions.map(_ref3 => {
|
|
224
223
|
let {
|
|
@@ -241,13 +240,27 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
|
241
240
|
stroke: theme.color.fg,
|
|
242
241
|
strokeCap: "square",
|
|
243
242
|
strokeWidth: 1
|
|
244
|
-
}),
|
|
243
|
+
}), chartTextData && (fadeTickLabels ? /*#__PURE__*/_jsx(AxisTickLabelOverflowMask, {
|
|
244
|
+
axis: "y",
|
|
245
|
+
children: /*#__PURE__*/_jsx(ChartTextGroup, {
|
|
246
|
+
prioritizeEndLabels: true,
|
|
247
|
+
LabelComponent: TickLabelComponent,
|
|
248
|
+
labels: chartTextData,
|
|
249
|
+
minGap: minTickLabelGap
|
|
250
|
+
})
|
|
251
|
+
}) : /*#__PURE__*/_jsx(ChartTextGroup, {
|
|
252
|
+
prioritizeEndLabels: true,
|
|
253
|
+
LabelComponent: TickLabelComponent,
|
|
254
|
+
labels: chartTextData,
|
|
255
|
+
minGap: minTickLabelGap
|
|
256
|
+
})), label && /*#__PURE__*/_jsx(Group, {
|
|
245
257
|
origin: vec(labelX, labelY),
|
|
246
258
|
transform: [{
|
|
247
259
|
rotate: position === 'left' ? -Math.PI / 2 : Math.PI / 2
|
|
248
260
|
}],
|
|
249
261
|
children: /*#__PURE__*/_jsx(ChartText, {
|
|
250
262
|
horizontalAlignment: "center",
|
|
263
|
+
repositionAxes: "none",
|
|
251
264
|
verticalAlignment: "middle",
|
|
252
265
|
x: labelX,
|
|
253
266
|
y: labelY,
|
|
@@ -1,55 +1,58 @@
|
|
|
1
1
|
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); }
|
|
2
|
-
import { memo, useCallback, useMemo } from 'react';
|
|
2
|
+
import { memo, useCallback, useMemo, useState } from 'react';
|
|
3
|
+
import { IconButton } from '../../../../buttons';
|
|
3
4
|
import { Example, ExampleScreen } from '../../../../examples/ExampleScreen';
|
|
4
5
|
import { useTheme } from '../../../../hooks/useTheme';
|
|
6
|
+
import { HStack, VStack } from '../../../../layout';
|
|
7
|
+
import { Text } from '../../../../typography';
|
|
5
8
|
import { BarPlot } from '../../bar';
|
|
6
9
|
import { CartesianChart } from '../../CartesianChart';
|
|
7
10
|
import { LineChart, SolidLine } from '../../line';
|
|
8
11
|
import { Line } from '../../line/Line';
|
|
9
12
|
import { Scrubber } from '../../scrubber/Scrubber';
|
|
10
13
|
import { XAxis, YAxis } from '..';
|
|
11
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
15
|
const defaultChartHeight = 250;
|
|
13
16
|
const ThinSolidLine = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(SolidLine, _extends({}, props, {
|
|
14
17
|
strokeWidth: 1
|
|
15
18
|
})));
|
|
19
|
+
const data = [{
|
|
20
|
+
name: 'Page A',
|
|
21
|
+
uv: 4000,
|
|
22
|
+
pv: 2400,
|
|
23
|
+
amt: 2400
|
|
24
|
+
}, {
|
|
25
|
+
name: 'Page B',
|
|
26
|
+
uv: 3000,
|
|
27
|
+
pv: 1398,
|
|
28
|
+
amt: 2210
|
|
29
|
+
}, {
|
|
30
|
+
name: 'Page C',
|
|
31
|
+
uv: 2000,
|
|
32
|
+
pv: 9800,
|
|
33
|
+
amt: 2290
|
|
34
|
+
}, {
|
|
35
|
+
name: 'Page D',
|
|
36
|
+
uv: 2780,
|
|
37
|
+
pv: 3908,
|
|
38
|
+
amt: 2000
|
|
39
|
+
}, {
|
|
40
|
+
name: 'Page E',
|
|
41
|
+
uv: 1890,
|
|
42
|
+
pv: 4800,
|
|
43
|
+
amt: 2181
|
|
44
|
+
}, {
|
|
45
|
+
name: 'Page F',
|
|
46
|
+
uv: 2390,
|
|
47
|
+
pv: 3800,
|
|
48
|
+
amt: 2500
|
|
49
|
+
}, {
|
|
50
|
+
name: 'Page G',
|
|
51
|
+
uv: 3490,
|
|
52
|
+
pv: 4300,
|
|
53
|
+
amt: 2100
|
|
54
|
+
}];
|
|
16
55
|
const Simple = () => {
|
|
17
|
-
const data = [{
|
|
18
|
-
name: 'Page A',
|
|
19
|
-
uv: 4000,
|
|
20
|
-
pv: 2400,
|
|
21
|
-
amt: 2400
|
|
22
|
-
}, {
|
|
23
|
-
name: 'Page B',
|
|
24
|
-
uv: 3000,
|
|
25
|
-
pv: 1398,
|
|
26
|
-
amt: 2210
|
|
27
|
-
}, {
|
|
28
|
-
name: 'Page C',
|
|
29
|
-
uv: 2000,
|
|
30
|
-
pv: 9800,
|
|
31
|
-
amt: 2290
|
|
32
|
-
}, {
|
|
33
|
-
name: 'Page D',
|
|
34
|
-
uv: 2780,
|
|
35
|
-
pv: 3908,
|
|
36
|
-
amt: 2000
|
|
37
|
-
}, {
|
|
38
|
-
name: 'Page E',
|
|
39
|
-
uv: 1890,
|
|
40
|
-
pv: 4800,
|
|
41
|
-
amt: 2181
|
|
42
|
-
}, {
|
|
43
|
-
name: 'Page F',
|
|
44
|
-
uv: 2390,
|
|
45
|
-
pv: 3800,
|
|
46
|
-
amt: 2500
|
|
47
|
-
}, {
|
|
48
|
-
name: 'Page G',
|
|
49
|
-
uv: 3490,
|
|
50
|
-
pv: 4300,
|
|
51
|
-
amt: 2100
|
|
52
|
-
}];
|
|
53
56
|
const pageViews = data.map(d => d.pv);
|
|
54
57
|
const pageNames = data.map(d => d.name);
|
|
55
58
|
const pageUniqueVisitors = data.map(d => d.uv);
|
|
@@ -457,80 +460,180 @@ const LineChartOnBandScale = _ref2 => {
|
|
|
457
460
|
})]
|
|
458
461
|
});
|
|
459
462
|
};
|
|
460
|
-
const
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
463
|
+
const tickLabelOverflowModes = ['reposition', 'fade', 'visible'];
|
|
464
|
+
const ordinalLabels = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th'];
|
|
465
|
+
const overflowSeriesData = [10, 22, 29, 45, 98, 45, 22];
|
|
466
|
+
const TickLabelOverflowYAxes = () => {
|
|
467
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
468
|
+
height: 320,
|
|
469
|
+
series: [{
|
|
470
|
+
id: 'line1',
|
|
471
|
+
data: overflowSeriesData
|
|
472
|
+
}],
|
|
473
|
+
yAxis: {
|
|
474
|
+
domain: {
|
|
475
|
+
min: 0
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
inset: 0,
|
|
479
|
+
children: [tickLabelOverflowModes.map(tickLabelOverflow => /*#__PURE__*/_jsx(YAxis, {
|
|
480
|
+
position: "left",
|
|
481
|
+
tickLabelOverflow: tickLabelOverflow,
|
|
482
|
+
width: 30
|
|
483
|
+
}, "left-" + tickLabelOverflow)), tickLabelOverflowModes.map(tickLabelOverflow => /*#__PURE__*/_jsx(YAxis, {
|
|
484
|
+
position: "right",
|
|
485
|
+
tickLabelOverflow: tickLabelOverflow,
|
|
486
|
+
width: 30
|
|
487
|
+
}, "right-" + tickLabelOverflow)), /*#__PURE__*/_jsx(Line, {
|
|
488
|
+
seriesId: "line1"
|
|
489
|
+
})]
|
|
490
|
+
});
|
|
491
|
+
};
|
|
492
|
+
const TickLabelOverflowXAxes = () => {
|
|
493
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
494
|
+
height: 420,
|
|
495
|
+
series: [{
|
|
496
|
+
id: 'line1',
|
|
497
|
+
data: overflowSeriesData
|
|
498
|
+
}],
|
|
499
|
+
xAxis: {
|
|
500
|
+
data: ordinalLabels
|
|
501
|
+
},
|
|
502
|
+
yAxis: {
|
|
503
|
+
domain: {
|
|
504
|
+
min: 0
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
inset: 0,
|
|
508
|
+
children: [tickLabelOverflowModes.map(tickLabelOverflow => /*#__PURE__*/_jsx(XAxis, {
|
|
509
|
+
showLine: true,
|
|
510
|
+
showTickMarks: true,
|
|
511
|
+
label: tickLabelOverflow,
|
|
512
|
+
position: "bottom",
|
|
513
|
+
tickLabelOverflow: tickLabelOverflow
|
|
514
|
+
}, "bottom-" + tickLabelOverflow)), tickLabelOverflowModes.map(tickLabelOverflow => /*#__PURE__*/_jsx(XAxis, {
|
|
515
|
+
showLine: true,
|
|
516
|
+
showTickMarks: true,
|
|
517
|
+
label: tickLabelOverflow,
|
|
518
|
+
position: "top",
|
|
519
|
+
tickLabelOverflow: tickLabelOverflow
|
|
520
|
+
}, "top-" + tickLabelOverflow)), /*#__PURE__*/_jsx(Line, {
|
|
521
|
+
seriesId: "line1"
|
|
522
|
+
})]
|
|
523
|
+
});
|
|
524
|
+
};
|
|
525
|
+
const TickLabelOverflowAllSides = () => {
|
|
526
|
+
const theme = useTheme();
|
|
527
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
528
|
+
height: 250,
|
|
529
|
+
series: [{
|
|
530
|
+
id: 'line1',
|
|
531
|
+
data: overflowSeriesData,
|
|
532
|
+
color: theme.color.accentBoldBlue
|
|
533
|
+
}],
|
|
534
|
+
xAxis: {
|
|
535
|
+
data: ordinalLabels
|
|
536
|
+
},
|
|
537
|
+
yAxis: {
|
|
538
|
+
domain: {
|
|
539
|
+
min: 0,
|
|
540
|
+
max: 100
|
|
541
|
+
}
|
|
542
|
+
},
|
|
543
|
+
inset: 0,
|
|
544
|
+
children: [/*#__PURE__*/_jsx(XAxis, {
|
|
545
|
+
showLine: true,
|
|
546
|
+
showTickMarks: true,
|
|
547
|
+
label: "Fade",
|
|
548
|
+
position: "bottom",
|
|
549
|
+
tickLabelOverflow: "fade"
|
|
550
|
+
}), /*#__PURE__*/_jsx(YAxis, {
|
|
551
|
+
showLine: true,
|
|
552
|
+
showTickMarks: true,
|
|
553
|
+
label: "Visible",
|
|
554
|
+
position: "left",
|
|
555
|
+
tickLabelOverflow: "visible"
|
|
556
|
+
}), /*#__PURE__*/_jsx(Line, {
|
|
557
|
+
curve: "natural",
|
|
558
|
+
seriesId: "line1"
|
|
559
|
+
})]
|
|
560
|
+
});
|
|
561
|
+
};
|
|
562
|
+
function ExampleNavigator() {
|
|
563
|
+
const [currentIndex, setCurrentIndex] = useState(0);
|
|
564
|
+
const examples = useMemo(() => [{
|
|
565
|
+
title: 'Basic',
|
|
566
|
+
component: /*#__PURE__*/_jsx(Simple, {})
|
|
567
|
+
}, {
|
|
568
|
+
title: 'Time of Day',
|
|
569
|
+
component: /*#__PURE__*/_jsx(TimeOfDayAxesExample, {})
|
|
570
|
+
}, {
|
|
571
|
+
title: 'Multiple Axes on Same Side',
|
|
572
|
+
component: /*#__PURE__*/_jsx(MultipleYAxesExample, {})
|
|
573
|
+
}, {
|
|
574
|
+
title: 'Strict Domain Limit',
|
|
575
|
+
component: /*#__PURE__*/_jsx(DomainLimitType, {
|
|
576
|
+
limit: "strict"
|
|
577
|
+
})
|
|
578
|
+
}, {
|
|
579
|
+
title: 'Nice Domain Limit',
|
|
580
|
+
component: /*#__PURE__*/_jsx(DomainLimitType, {
|
|
581
|
+
limit: "nice"
|
|
582
|
+
})
|
|
583
|
+
}, {
|
|
584
|
+
title: 'Band Axis Grid Alignment',
|
|
585
|
+
component: /*#__PURE__*/_jsxs(CartesianChart, {
|
|
586
|
+
height: 350,
|
|
587
|
+
inset: 8,
|
|
588
|
+
series: [{
|
|
589
|
+
id: 'prices',
|
|
590
|
+
data: [10, 22, 29, 45, 98, 45, 22]
|
|
591
|
+
}],
|
|
592
|
+
xAxis: {
|
|
593
|
+
scaleType: 'band',
|
|
594
|
+
data: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
|
|
595
|
+
},
|
|
596
|
+
yAxis: {
|
|
597
|
+
domain: {
|
|
598
|
+
min: 0
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
children: [/*#__PURE__*/_jsx(XAxis, {
|
|
602
|
+
showGrid: true,
|
|
603
|
+
showLine: true,
|
|
604
|
+
showTickMarks: true,
|
|
605
|
+
label: "Default"
|
|
606
|
+
}), /*#__PURE__*/_jsx(XAxis, {
|
|
607
|
+
showLine: true,
|
|
608
|
+
showTickMarks: true,
|
|
609
|
+
bandTickMarkPlacement: "start",
|
|
610
|
+
label: "Start"
|
|
611
|
+
}), /*#__PURE__*/_jsx(XAxis, {
|
|
612
|
+
showLine: true,
|
|
613
|
+
showTickMarks: true,
|
|
614
|
+
bandTickMarkPlacement: "end",
|
|
615
|
+
label: "End"
|
|
616
|
+
}), /*#__PURE__*/_jsx(XAxis, {
|
|
617
|
+
showLine: true,
|
|
618
|
+
showTickMarks: true,
|
|
619
|
+
bandTickMarkPlacement: "middle",
|
|
620
|
+
label: "Middle"
|
|
621
|
+
}), /*#__PURE__*/_jsx(XAxis, {
|
|
622
|
+
showLine: true,
|
|
623
|
+
showTickMarks: true,
|
|
624
|
+
bandTickMarkPlacement: "edges",
|
|
625
|
+
label: "Edges"
|
|
626
|
+
}), /*#__PURE__*/_jsx(BarPlot, {})]
|
|
627
|
+
})
|
|
628
|
+
}, {
|
|
629
|
+
title: 'Band Scale - Tick Filtering',
|
|
630
|
+
component: /*#__PURE__*/_jsx(BandScaleTickFiltering, {})
|
|
631
|
+
}, {
|
|
632
|
+
title: 'Band Scale - Explicit Ticks',
|
|
633
|
+
component: /*#__PURE__*/_jsx(BandScaleExplicitTicks, {})
|
|
634
|
+
}, {
|
|
635
|
+
title: 'Line Chart on Band Scale - Grid Positions',
|
|
636
|
+
component: /*#__PURE__*/_jsxs(_Fragment, {
|
|
534
637
|
children: [/*#__PURE__*/_jsx(LineChartOnBandScale, {
|
|
535
638
|
bandGridLinePlacement: "edges"
|
|
536
639
|
}), /*#__PURE__*/_jsx(LineChartOnBandScale, {
|
|
@@ -540,13 +643,65 @@ const AxisStories = () => {
|
|
|
540
643
|
}), /*#__PURE__*/_jsx(LineChartOnBandScale, {
|
|
541
644
|
bandGridLinePlacement: "end"
|
|
542
645
|
})]
|
|
543
|
-
})
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
})
|
|
646
|
+
})
|
|
647
|
+
}, {
|
|
648
|
+
title: 'Axes on All Sides',
|
|
649
|
+
component: /*#__PURE__*/_jsx(AxesOnAllSides, {})
|
|
650
|
+
}, {
|
|
651
|
+
title: 'Custom Tick Mark Sizes',
|
|
652
|
+
component: /*#__PURE__*/_jsx(CustomTickMarkSizes, {})
|
|
653
|
+
}, {
|
|
654
|
+
title: 'Y Axis Label Repositioning',
|
|
655
|
+
component: /*#__PURE__*/_jsx(TickLabelOverflowYAxes, {})
|
|
656
|
+
}, {
|
|
657
|
+
title: 'X Axis Label Repositioning',
|
|
658
|
+
component: /*#__PURE__*/_jsx(TickLabelOverflowXAxes, {})
|
|
659
|
+
}, {
|
|
660
|
+
title: 'Ineffective Repositioning',
|
|
661
|
+
component: /*#__PURE__*/_jsx(TickLabelOverflowAllSides, {})
|
|
662
|
+
}], []);
|
|
663
|
+
const currentExample = examples[currentIndex];
|
|
664
|
+
const handlePrevious = useCallback(() => {
|
|
665
|
+
setCurrentIndex(prev => (prev - 1 + examples.length) % examples.length);
|
|
666
|
+
}, [examples.length]);
|
|
667
|
+
const handleNext = useCallback(() => {
|
|
668
|
+
setCurrentIndex(prev => (prev + 1) % examples.length);
|
|
669
|
+
}, [examples.length]);
|
|
670
|
+
return /*#__PURE__*/_jsx(ExampleScreen, {
|
|
671
|
+
paddingX: 0,
|
|
672
|
+
children: /*#__PURE__*/_jsxs(VStack, {
|
|
673
|
+
gap: 4,
|
|
674
|
+
children: [/*#__PURE__*/_jsxs(HStack, {
|
|
675
|
+
alignItems: "center",
|
|
676
|
+
justifyContent: "space-between",
|
|
677
|
+
padding: 2,
|
|
678
|
+
children: [/*#__PURE__*/_jsx(IconButton, {
|
|
679
|
+
accessibilityHint: "Navigate to previous example",
|
|
680
|
+
accessibilityLabel: "Previous",
|
|
681
|
+
name: "arrowLeft",
|
|
682
|
+
onPress: handlePrevious,
|
|
683
|
+
variant: "secondary"
|
|
684
|
+
}), /*#__PURE__*/_jsxs(VStack, {
|
|
685
|
+
alignItems: "center",
|
|
686
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
687
|
+
font: "title3",
|
|
688
|
+
children: currentExample.title
|
|
689
|
+
}), /*#__PURE__*/_jsxs(Text, {
|
|
690
|
+
color: "fgMuted",
|
|
691
|
+
font: "label1",
|
|
692
|
+
children: [currentIndex + 1, " / ", examples.length]
|
|
693
|
+
})]
|
|
694
|
+
}), /*#__PURE__*/_jsx(IconButton, {
|
|
695
|
+
accessibilityHint: "Navigate to next example",
|
|
696
|
+
accessibilityLabel: "Next",
|
|
697
|
+
name: "arrowRight",
|
|
698
|
+
onPress: handleNext,
|
|
699
|
+
variant: "secondary"
|
|
700
|
+
})]
|
|
701
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
702
|
+
children: currentExample.component
|
|
703
|
+
})]
|
|
704
|
+
})
|
|
550
705
|
});
|
|
551
|
-
}
|
|
552
|
-
export default
|
|
706
|
+
}
|
|
707
|
+
export default ExampleNavigator;
|
|
@@ -29,13 +29,13 @@ export const DefaultScrubberBeaconLabel = /*#__PURE__*/memo(_ref => {
|
|
|
29
29
|
chartTextProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
30
30
|
const theme = useTheme();
|
|
31
31
|
return /*#__PURE__*/_jsx(ChartText, _extends({
|
|
32
|
-
disableRepositioning: true,
|
|
33
32
|
background: background != null ? background : theme.color.bg,
|
|
34
33
|
borderRadius: borderRadius,
|
|
35
34
|
color: color != null ? color : theme.color.fgPrimary,
|
|
36
35
|
elevated: elevated,
|
|
37
36
|
font: font,
|
|
38
37
|
inset: inset,
|
|
38
|
+
repositionAxes: "none",
|
|
39
39
|
verticalAlignment: verticalAlignment
|
|
40
40
|
}, chartTextProps, {
|
|
41
41
|
children: label
|
|
@@ -34,6 +34,11 @@ const getFontWeight = (theme, font) => {
|
|
|
34
34
|
* Vertical alignment options for chart text.
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Which axes ChartText may nudge labels along to stay in bounds.
|
|
39
|
+
* @default 'both'
|
|
40
|
+
*/
|
|
41
|
+
|
|
37
42
|
export const ChartText = /*#__PURE__*/memo(_ref => {
|
|
38
43
|
var _elevationShadow$shad, _elevationShadow$shad2, _elevationShadow$shad3, _elevationShadow$shad4, _elevationShadow$shad5, _elevationShadow$shad6, _elevationShadow$shad7;
|
|
39
44
|
let {
|
|
@@ -46,6 +51,7 @@ export const ChartText = /*#__PURE__*/memo(_ref => {
|
|
|
46
51
|
verticalAlignment = 'middle',
|
|
47
52
|
paragraphAlignment = TextAlign.Left,
|
|
48
53
|
disableRepositioning = false,
|
|
54
|
+
repositionAxes = disableRepositioning ? 'none' : 'both',
|
|
49
55
|
bounds,
|
|
50
56
|
color,
|
|
51
57
|
background: backgroundProp,
|
|
@@ -183,12 +189,8 @@ export const ChartText = /*#__PURE__*/memo(_ref => {
|
|
|
183
189
|
height: chartHeight
|
|
184
190
|
}), [chartWidth, chartHeight]);
|
|
185
191
|
const overflowAmount = useDerivedValue(() => {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
x: 0,
|
|
189
|
-
y: 0
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
+
const repositionX = repositionAxes === 'both' || repositionAxes === 'x';
|
|
193
|
+
const repositionY = repositionAxes === 'both' || repositionAxes === 'y';
|
|
192
194
|
const parentBounds = bounds != null ? bounds : fullChartBounds;
|
|
193
195
|
if (!parentBounds || parentBounds.width <= 0 || parentBounds.height <= 0) {
|
|
194
196
|
return {
|
|
@@ -198,25 +200,25 @@ export const ChartText = /*#__PURE__*/memo(_ref => {
|
|
|
198
200
|
}
|
|
199
201
|
let offsetX = 0;
|
|
200
202
|
let offsetY = 0;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
if (repositionX) {
|
|
204
|
+
if (backgroundRect.value.x < parentBounds.x) {
|
|
205
|
+
offsetX = parentBounds.x - backgroundRect.value.x;
|
|
206
|
+
} else if (backgroundRect.value.x + backgroundRect.value.width > parentBounds.x + parentBounds.width) {
|
|
207
|
+
offsetX = parentBounds.x + parentBounds.width - (backgroundRect.value.x + backgroundRect.value.width);
|
|
208
|
+
}
|
|
207
209
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
210
|
+
if (repositionY) {
|
|
211
|
+
if (backgroundRect.value.y < parentBounds.y) {
|
|
212
|
+
offsetY = parentBounds.y - backgroundRect.value.y;
|
|
213
|
+
} else if (backgroundRect.value.y + backgroundRect.value.height > parentBounds.y + parentBounds.height) {
|
|
214
|
+
offsetY = parentBounds.y + parentBounds.height - (backgroundRect.value.y + backgroundRect.value.height);
|
|
215
|
+
}
|
|
214
216
|
}
|
|
215
217
|
return {
|
|
216
218
|
x: offsetX,
|
|
217
219
|
y: offsetY
|
|
218
220
|
};
|
|
219
|
-
}, [backgroundRect, fullChartBounds, bounds,
|
|
221
|
+
}, [backgroundRect, fullChartBounds, bounds, repositionAxes]);
|
|
220
222
|
|
|
221
223
|
// Final adjusted positions
|
|
222
224
|
const backgroundRectWithOffset = useDerivedValue(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cds-mobile",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.14.0",
|
|
4
4
|
"description": "Coinbase Design System - Mobile",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
"react-native-worklets": "0.5.2"
|
|
219
219
|
},
|
|
220
220
|
"dependencies": {
|
|
221
|
-
"@coinbase/cds-common": "^9.
|
|
221
|
+
"@coinbase/cds-common": "^9.14.0",
|
|
222
222
|
"@coinbase/cds-icons": "^5.21.0",
|
|
223
223
|
"@coinbase/cds-illustrations": "^4.47.0",
|
|
224
224
|
"@coinbase/cds-lottie-files": "^3.3.4",
|