@coinbase/cds-mobile 9.12.3 → 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 +12 -0
- package/dts/visualizations/chart/CartesianChart.d.ts +2 -1
- package/dts/visualizations/chart/CartesianChart.d.ts.map +1 -1
- package/dts/visualizations/chart/Path.d.ts +4 -0
- package/dts/visualizations/chart/Path.d.ts.map +1 -1
- 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/LineChart.d.ts +4 -0
- package/dts/visualizations/chart/line/LineChart.d.ts.map +1 -1
- package/dts/visualizations/chart/line/ReferenceLine.d.ts +6 -0
- package/dts/visualizations/chart/line/ReferenceLine.d.ts.map +1 -1
- package/dts/visualizations/chart/scrubber/ScrubberProvider.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/Path.js +105 -31
- 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/line/LineChart.js +4 -0
- package/esm/visualizations/chart/line/ReferenceLine.js +5 -2
- package/esm/visualizations/chart/line/__stories__/LineChart.stories.js +21 -0
- package/esm/visualizations/chart/scrubber/DefaultScrubberBeaconLabel.js +1 -1
- package/esm/visualizations/chart/scrubber/ScrubberProvider.js +40 -24
- package/esm/visualizations/chart/text/ChartText.js +21 -19
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -17,6 +17,10 @@ const getDefaultScrubberAccessibilityStep = function (dataLength, sampleCount) {
|
|
|
17
17
|
if (dataLength <= 0) return 1;
|
|
18
18
|
return Math.max(1, Math.ceil(dataLength / sampleCount));
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* A line chart built on `CartesianChart`. For non-interactive usage (e.g. row sparklines), pass
|
|
22
|
+
* `animate={false}` for a lightweight static render (cheap rectangular clip, no entrance animation).
|
|
23
|
+
*/
|
|
20
24
|
export const LineChart = /*#__PURE__*/memo(_ref => {
|
|
21
25
|
let {
|
|
22
26
|
ref,
|
|
@@ -24,6 +24,7 @@ export const ReferenceLine = /*#__PURE__*/memo(_ref => {
|
|
|
24
24
|
labelVerticalAlignment,
|
|
25
25
|
labelBoundsInset,
|
|
26
26
|
stroke,
|
|
27
|
+
strokeWidth,
|
|
27
28
|
opacity = 1
|
|
28
29
|
} = _ref;
|
|
29
30
|
const theme = useTheme();
|
|
@@ -81,7 +82,8 @@ export const ReferenceLine = /*#__PURE__*/memo(_ref => {
|
|
|
81
82
|
animate: false,
|
|
82
83
|
d: horizontalLine,
|
|
83
84
|
stroke: effectiveLineStroke,
|
|
84
|
-
strokeOpacity: opacity
|
|
85
|
+
strokeOpacity: opacity,
|
|
86
|
+
strokeWidth: strokeWidth
|
|
85
87
|
}), label && /*#__PURE__*/_jsx(LabelComponent, {
|
|
86
88
|
boundsInset: labelBoundsInset,
|
|
87
89
|
dx: labelDx,
|
|
@@ -113,7 +115,8 @@ export const ReferenceLine = /*#__PURE__*/memo(_ref => {
|
|
|
113
115
|
animate: false,
|
|
114
116
|
d: verticalLine,
|
|
115
117
|
stroke: effectiveLineStroke,
|
|
116
|
-
strokeOpacity: opacity
|
|
118
|
+
strokeOpacity: opacity,
|
|
119
|
+
strokeWidth: strokeWidth
|
|
117
120
|
}), label && /*#__PURE__*/_jsx(LabelComponent, {
|
|
118
121
|
boundsInset: labelBoundsInset,
|
|
119
122
|
dx: labelDx,
|
|
@@ -1794,6 +1794,27 @@ function ExampleNavigator() {
|
|
|
1794
1794
|
data: [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58]
|
|
1795
1795
|
}]
|
|
1796
1796
|
})
|
|
1797
|
+
}, {
|
|
1798
|
+
title: 'Lightweight (Static)',
|
|
1799
|
+
component: /*#__PURE__*/_jsx(LineChart, {
|
|
1800
|
+
animate: false,
|
|
1801
|
+
height: 200,
|
|
1802
|
+
series: [{
|
|
1803
|
+
id: 'prices',
|
|
1804
|
+
data: [-20, 12, -8, 34, -15, 28, -4, 40, -25, 18, -10, 30, -18, 22]
|
|
1805
|
+
}],
|
|
1806
|
+
yAxis: {
|
|
1807
|
+
domain: {
|
|
1808
|
+
min: -40,
|
|
1809
|
+
max: 45
|
|
1810
|
+
}
|
|
1811
|
+
},
|
|
1812
|
+
children: /*#__PURE__*/_jsx(ReferenceLine, {
|
|
1813
|
+
LineComponent: DottedLine,
|
|
1814
|
+
dataY: 0,
|
|
1815
|
+
strokeWidth: 2
|
|
1816
|
+
})
|
|
1817
|
+
})
|
|
1797
1818
|
}, {
|
|
1798
1819
|
title: 'Horizontal Layout',
|
|
1799
1820
|
component: /*#__PURE__*/_jsx(HorizontalLayoutLineChart, {})
|
|
@@ -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
|