@coinbase/cds-mobile-visualization 3.4.0-beta.9 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +132 -0
- package/dts/chart/CartesianChart.d.ts +92 -7
- package/dts/chart/CartesianChart.d.ts.map +1 -1
- package/dts/chart/ChartContextBridge.d.ts.map +1 -1
- package/dts/chart/ChartProvider.d.ts +3 -0
- package/dts/chart/ChartProvider.d.ts.map +1 -1
- package/dts/chart/Path.d.ts +36 -13
- package/dts/chart/Path.d.ts.map +1 -1
- package/dts/chart/PeriodSelector.d.ts +20 -5
- package/dts/chart/PeriodSelector.d.ts.map +1 -1
- package/dts/chart/area/Area.d.ts +14 -11
- package/dts/chart/area/Area.d.ts.map +1 -1
- package/dts/chart/area/AreaChart.d.ts +33 -9
- package/dts/chart/area/AreaChart.d.ts.map +1 -1
- package/dts/chart/area/DottedArea.d.ts.map +1 -1
- package/dts/chart/area/GradientArea.d.ts.map +1 -1
- package/dts/chart/area/SolidArea.d.ts.map +1 -1
- package/dts/chart/axis/Axis.d.ts +22 -42
- package/dts/chart/axis/Axis.d.ts.map +1 -1
- package/dts/chart/axis/XAxis.d.ts +6 -0
- package/dts/chart/axis/XAxis.d.ts.map +1 -1
- package/dts/chart/axis/YAxis.d.ts +1 -0
- package/dts/chart/axis/YAxis.d.ts.map +1 -1
- package/dts/chart/bar/Bar.d.ts +51 -51
- package/dts/chart/bar/Bar.d.ts.map +1 -1
- package/dts/chart/bar/BarChart.d.ts +56 -11
- package/dts/chart/bar/BarChart.d.ts.map +1 -1
- package/dts/chart/bar/BarPlot.d.ts +2 -1
- package/dts/chart/bar/BarPlot.d.ts.map +1 -1
- package/dts/chart/bar/BarStack.d.ts +45 -20
- package/dts/chart/bar/BarStack.d.ts.map +1 -1
- package/dts/chart/bar/BarStackGroup.d.ts +2 -1
- package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
- package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
- package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
- package/dts/chart/gradient/Gradient.d.ts +5 -0
- package/dts/chart/gradient/Gradient.d.ts.map +1 -1
- package/dts/chart/index.d.ts +1 -0
- package/dts/chart/index.d.ts.map +1 -1
- package/dts/chart/legend/DefaultLegendEntry.d.ts +5 -0
- package/dts/chart/legend/DefaultLegendEntry.d.ts.map +1 -0
- package/dts/chart/legend/DefaultLegendShape.d.ts +5 -0
- package/dts/chart/legend/DefaultLegendShape.d.ts.map +1 -0
- package/dts/chart/legend/Legend.d.ts +168 -0
- package/dts/chart/legend/Legend.d.ts.map +1 -0
- package/dts/chart/legend/index.d.ts +4 -0
- package/dts/chart/legend/index.d.ts.map +1 -0
- package/dts/chart/line/DottedLine.d.ts.map +1 -1
- package/dts/chart/line/Line.d.ts +23 -19
- package/dts/chart/line/Line.d.ts.map +1 -1
- package/dts/chart/line/LineChart.d.ts +26 -9
- package/dts/chart/line/LineChart.d.ts.map +1 -1
- package/dts/chart/line/ReferenceLine.d.ts +1 -0
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
- package/dts/chart/line/SolidLine.d.ts.map +1 -1
- package/dts/chart/point/Point.d.ts +26 -2
- package/dts/chart/point/Point.d.ts.map +1 -1
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +32 -2
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -1
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +2 -1
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -1
- package/dts/chart/scrubber/Scrubber.d.ts +86 -17
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts +12 -0
- package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +10 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +16 -1
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -1
- package/dts/chart/utils/axis.d.ts +45 -10
- package/dts/chart/utils/axis.d.ts.map +1 -1
- package/dts/chart/utils/bar.d.ts +190 -0
- package/dts/chart/utils/bar.d.ts.map +1 -1
- package/dts/chart/utils/chart.d.ts +32 -0
- package/dts/chart/utils/chart.d.ts.map +1 -1
- package/dts/chart/utils/context.d.ts +21 -6
- package/dts/chart/utils/context.d.ts.map +1 -1
- package/dts/chart/utils/gradient.d.ts +3 -1
- package/dts/chart/utils/gradient.d.ts.map +1 -1
- package/dts/chart/utils/path.d.ts +26 -0
- package/dts/chart/utils/path.d.ts.map +1 -1
- package/dts/chart/utils/point.d.ts +24 -12
- package/dts/chart/utils/point.d.ts.map +1 -1
- package/dts/chart/utils/scale.d.ts +11 -0
- package/dts/chart/utils/scale.d.ts.map +1 -1
- package/dts/chart/utils/scrubber.d.ts +2 -1
- package/dts/chart/utils/scrubber.d.ts.map +1 -1
- package/dts/chart/utils/transition.d.ts +63 -22
- package/dts/chart/utils/transition.d.ts.map +1 -1
- package/dts/sparkline/Sparkline.d.ts +2 -1
- package/dts/sparkline/Sparkline.d.ts.map +1 -1
- package/dts/sparkline/SparklineArea.d.ts +2 -1
- package/dts/sparkline/SparklineArea.d.ts.map +1 -1
- package/dts/sparkline/SparklineGradient.d.ts +2 -1
- package/dts/sparkline/SparklineGradient.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +2 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -1
- package/esm/chart/CartesianChart.js +176 -82
- package/esm/chart/ChartContextBridge.js +14 -3
- package/esm/chart/ChartProvider.js +2 -2
- package/esm/chart/Path.js +34 -29
- package/esm/chart/PeriodSelector.js +5 -1
- package/esm/chart/__stories__/CartesianChart.stories.js +16 -80
- package/esm/chart/__stories__/ChartAccessibility.stories.js +721 -0
- package/esm/chart/__stories__/ChartTransitions.stories.js +625 -0
- package/esm/chart/__stories__/PeriodSelector.stories.js +99 -1
- package/esm/chart/area/Area.js +21 -9
- package/esm/chart/area/AreaChart.js +18 -13
- package/esm/chart/area/DottedArea.js +28 -18
- package/esm/chart/area/GradientArea.js +14 -7
- package/esm/chart/area/SolidArea.js +6 -2
- package/esm/chart/area/__stories__/AreaChart.stories.js +47 -5
- package/esm/chart/axis/Axis.js +5 -41
- package/esm/chart/axis/XAxis.js +116 -47
- package/esm/chart/axis/YAxis.js +105 -26
- package/esm/chart/axis/__stories__/Axis.stories.js +324 -48
- package/esm/chart/bar/Bar.js +17 -15
- package/esm/chart/bar/BarChart.js +38 -33
- package/esm/chart/bar/BarPlot.js +40 -45
- package/esm/chart/bar/BarStack.js +92 -475
- package/esm/chart/bar/BarStackGroup.js +37 -27
- package/esm/chart/bar/DefaultBar.js +27 -18
- package/esm/chart/bar/DefaultBarStack.js +25 -9
- package/esm/chart/bar/__stories__/BarChart.stories.js +728 -54
- package/esm/chart/gradient/Gradient.js +2 -1
- package/esm/chart/index.js +1 -0
- package/esm/chart/legend/DefaultLegendEntry.js +42 -0
- package/esm/chart/legend/DefaultLegendShape.js +64 -0
- package/esm/chart/legend/Legend.js +59 -0
- package/esm/chart/legend/__stories__/Legend.stories.js +574 -0
- package/esm/chart/legend/index.js +3 -0
- package/esm/chart/line/DottedLine.js +6 -2
- package/esm/chart/line/Line.js +42 -38
- package/esm/chart/line/LineChart.js +36 -12
- package/esm/chart/line/SolidLine.js +6 -2
- package/esm/chart/line/__stories__/LineChart.stories.js +236 -590
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +95 -1
- package/esm/chart/point/Point.js +35 -36
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +41 -38
- package/esm/chart/scrubber/DefaultScrubberLabel.js +26 -10
- package/esm/chart/scrubber/Scrubber.js +67 -35
- package/esm/chart/scrubber/ScrubberAccessibilityView.js +177 -0
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +30 -22
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +35 -8
- package/esm/chart/scrubber/ScrubberProvider.js +29 -24
- package/esm/chart/scrubber/__stories__/Scrubber.stories.js +946 -0
- package/esm/chart/utils/axis.js +88 -44
- package/esm/chart/utils/bar.js +820 -0
- package/esm/chart/utils/chart.js +34 -7
- package/esm/chart/utils/context.js +7 -0
- package/esm/chart/utils/gradient.js +8 -4
- package/esm/chart/utils/path.js +91 -61
- package/esm/chart/utils/point.js +92 -39
- package/esm/chart/utils/scale.js +13 -2
- package/esm/chart/utils/scrubber.js +12 -5
- package/esm/chart/utils/transition.js +108 -60
- package/esm/sparkline/Sparkline.js +2 -1
- package/esm/sparkline/SparklineArea.js +2 -1
- package/esm/sparkline/SparklineGradient.js +2 -1
- package/esm/sparkline/__figma__/Sparkline.figma.js +1 -1
- package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +2 -1
- package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +1 -1
- package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +1 -1
- package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +2 -0
- package/package.json +5 -6
- package/esm/chart/__stories__/Chart.stories.js +0 -77
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
const _excluded = ["children"],
|
|
2
|
-
_excluded2 = ["animate"]
|
|
2
|
+
_excluded2 = ["animate"],
|
|
3
|
+
_excluded3 = ["x", "y", "width", "height", "dataX"],
|
|
4
|
+
_excluded4 = ["data", "height"],
|
|
5
|
+
_excluded5 = ["buy", "sell", "animate", "borderRadius", "height", "inset", "layout", "stackGap", "xAxis", "yAxis", "barMinSize"];
|
|
3
6
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
7
|
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); }
|
|
5
|
-
import { memo, useEffect, useState } from 'react';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
+
import { memo, useCallback, useEffect, useId, useMemo, useState } from 'react';
|
|
9
|
+
import { useDerivedValue } from 'react-native-reanimated';
|
|
10
|
+
import { assets } from '@coinbase/cds-common/internal/data/assets';
|
|
11
|
+
import { candles as btcCandles } from '@coinbase/cds-common/internal/data/candles';
|
|
12
|
+
import { Button, IconButton } from '@coinbase/cds-mobile/buttons';
|
|
13
|
+
import { ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
|
|
8
14
|
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
9
|
-
import { VStack } from '@coinbase/cds-mobile/layout';
|
|
15
|
+
import { Box, HStack, VStack } from '@coinbase/cds-mobile/layout';
|
|
16
|
+
import { Text } from '@coinbase/cds-mobile/typography';
|
|
17
|
+
import { Line as SkiaLine, Rect } from '@shopify/react-native-skia';
|
|
10
18
|
import { XAxis, YAxis } from '../../axis';
|
|
11
19
|
import { CartesianChart } from '../../CartesianChart';
|
|
20
|
+
import { useCartesianChartContext } from '../../ChartProvider';
|
|
21
|
+
import { DefaultLegendEntry } from '../../legend';
|
|
12
22
|
import { ReferenceLine, SolidLine } from '../../line';
|
|
23
|
+
import { Scrubber } from '../../scrubber';
|
|
24
|
+
import { getPointOnSerializableScale, unwrapAnimatedValue, useScrubberContext } from '../../utils';
|
|
13
25
|
import { Bar } from '../Bar';
|
|
14
26
|
import { BarChart } from '../BarChart';
|
|
15
27
|
import { BarPlot } from '../BarPlot';
|
|
16
28
|
import { DefaultBarStack } from '../DefaultBarStack';
|
|
17
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
30
|
const ThinSolidLine = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(SolidLine, _extends({}, props, {
|
|
19
31
|
strokeWidth: 1
|
|
20
32
|
})));
|
|
@@ -104,7 +116,7 @@ const CustomBarStackComponent = /*#__PURE__*/memo(_ref => {
|
|
|
104
116
|
borderRadius: 1000,
|
|
105
117
|
fill: theme.color.bgTertiary,
|
|
106
118
|
height: diameter,
|
|
107
|
-
|
|
119
|
+
origin: props.y,
|
|
108
120
|
width: diameter,
|
|
109
121
|
x: props.x,
|
|
110
122
|
y: props.y - diameter
|
|
@@ -115,6 +127,7 @@ const CustomBarStackComponent = /*#__PURE__*/memo(_ref => {
|
|
|
115
127
|
}));
|
|
116
128
|
});
|
|
117
129
|
const MonthlyRewards = () => {
|
|
130
|
+
const theme = useTheme();
|
|
118
131
|
const months = ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'];
|
|
119
132
|
const purple = [null, 6, 8, 10, 7, 6, 6, 8, null, null, null, null];
|
|
120
133
|
const blue = [null, 10, 12, 11, 10, 9, 10, 11, null, null, null, null];
|
|
@@ -124,19 +137,19 @@ const MonthlyRewards = () => {
|
|
|
124
137
|
const series = [{
|
|
125
138
|
id: 'purple',
|
|
126
139
|
data: purple,
|
|
127
|
-
color:
|
|
140
|
+
color: "rgb(" + theme.spectrum.purple30 + ")"
|
|
128
141
|
}, {
|
|
129
142
|
id: 'blue',
|
|
130
143
|
data: blue,
|
|
131
|
-
color:
|
|
144
|
+
color: "rgb(" + theme.spectrum.blue30 + ")"
|
|
132
145
|
}, {
|
|
133
146
|
id: 'cyan',
|
|
134
147
|
data: cyan,
|
|
135
|
-
color:
|
|
148
|
+
color: "rgb(" + theme.spectrum.teal30 + ")"
|
|
136
149
|
}, {
|
|
137
150
|
id: 'green',
|
|
138
151
|
data: green,
|
|
139
|
-
color:
|
|
152
|
+
color: "rgb(" + theme.spectrum.green30 + ")"
|
|
140
153
|
}];
|
|
141
154
|
return /*#__PURE__*/_jsxs(VStack, {
|
|
142
155
|
gap: 2,
|
|
@@ -155,7 +168,7 @@ const MonthlyRewards = () => {
|
|
|
155
168
|
tickLabelFormatter: index => {
|
|
156
169
|
return months[index];
|
|
157
170
|
},
|
|
158
|
-
categoryPadding: 0.
|
|
171
|
+
categoryPadding: 0.25
|
|
159
172
|
}
|
|
160
173
|
}), /*#__PURE__*/_jsx(Button, {
|
|
161
174
|
onPress: () => setRoundBaseline(!roundBaseline),
|
|
@@ -621,48 +634,709 @@ const ColorMapWithOpacity = () => {
|
|
|
621
634
|
}
|
|
622
635
|
});
|
|
623
636
|
};
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
637
|
+
const BandGridPositionExample = _ref6 => {
|
|
638
|
+
let {
|
|
639
|
+
position
|
|
640
|
+
} = _ref6;
|
|
641
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
642
|
+
height: 180,
|
|
643
|
+
inset: 4,
|
|
644
|
+
series: [{
|
|
645
|
+
id: 'data',
|
|
646
|
+
data: [30, 50, 40, 60, 35]
|
|
647
|
+
}],
|
|
648
|
+
xAxis: {
|
|
649
|
+
scaleType: 'band',
|
|
650
|
+
data: ['A', 'B', 'C', 'D', 'E']
|
|
651
|
+
},
|
|
652
|
+
yAxis: {
|
|
653
|
+
domain: {
|
|
654
|
+
min: 0
|
|
655
|
+
}
|
|
656
|
+
},
|
|
657
|
+
children: [/*#__PURE__*/_jsx(XAxis, {
|
|
658
|
+
showGrid: true,
|
|
659
|
+
showLine: true,
|
|
660
|
+
bandGridLinePlacement: position,
|
|
661
|
+
label: position
|
|
662
|
+
}), /*#__PURE__*/_jsx(BarPlot, {})]
|
|
663
|
+
});
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
// --- Composed Examples ---
|
|
667
|
+
|
|
668
|
+
const candlestickStockData = btcCandles.slice(0, 90).reverse();
|
|
669
|
+
const CandlesticksHeader = /*#__PURE__*/memo(_ref7 => {
|
|
670
|
+
let {
|
|
671
|
+
currentIndex
|
|
672
|
+
} = _ref7;
|
|
673
|
+
const formatPrice = useCallback(price => {
|
|
674
|
+
return new Intl.NumberFormat('en-US', {
|
|
675
|
+
style: 'currency',
|
|
676
|
+
currency: 'USD'
|
|
677
|
+
}).format(parseFloat(price));
|
|
678
|
+
}, []);
|
|
679
|
+
const formatThousandsPriceNumber = useCallback(price => {
|
|
680
|
+
const formattedPrice = new Intl.NumberFormat('en-US', {
|
|
681
|
+
style: 'currency',
|
|
682
|
+
currency: 'USD',
|
|
683
|
+
minimumFractionDigits: 0,
|
|
684
|
+
maximumFractionDigits: 0
|
|
685
|
+
}).format(price / 1000);
|
|
686
|
+
return formattedPrice + "k";
|
|
687
|
+
}, []);
|
|
688
|
+
const currentText = useMemo(() => {
|
|
689
|
+
if (currentIndex !== undefined) {
|
|
690
|
+
return "Open: " + formatThousandsPriceNumber(parseFloat(candlestickStockData[currentIndex].open)) + ", Close: " + formatThousandsPriceNumber(parseFloat(candlestickStockData[currentIndex].close)) + ", Volume: " + (parseFloat(candlestickStockData[currentIndex].volume) / 1000).toFixed(2) + "k";
|
|
691
|
+
}
|
|
692
|
+
return formatPrice(candlestickStockData[candlestickStockData.length - 1].close);
|
|
693
|
+
}, [currentIndex, formatThousandsPriceNumber, formatPrice]);
|
|
694
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
695
|
+
"aria-live": "polite",
|
|
696
|
+
font: "headline",
|
|
697
|
+
children: currentText
|
|
698
|
+
});
|
|
699
|
+
});
|
|
700
|
+
const CandlesticksChart = /*#__PURE__*/memo(_ref8 => {
|
|
701
|
+
let {
|
|
702
|
+
infoTextId,
|
|
703
|
+
onScrubberPositionChange
|
|
704
|
+
} = _ref8;
|
|
705
|
+
const theme = useTheme();
|
|
706
|
+
const min = useMemo(() => Math.min(...candlestickStockData.map(data => parseFloat(data.low))), []);
|
|
707
|
+
const CandleThinSolidLine = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(SolidLine, _extends({}, props, {
|
|
708
|
+
strokeWidth: 1
|
|
709
|
+
})));
|
|
710
|
+
const BandwidthHighlight = /*#__PURE__*/memo(_ref9 => {
|
|
711
|
+
let {
|
|
712
|
+
stroke
|
|
713
|
+
} = _ref9;
|
|
714
|
+
const {
|
|
715
|
+
getXSerializableScale,
|
|
716
|
+
drawingArea
|
|
717
|
+
} = useCartesianChartContext();
|
|
718
|
+
const {
|
|
719
|
+
scrubberPosition
|
|
720
|
+
} = useScrubberContext();
|
|
721
|
+
const xScale = useMemo(() => getXSerializableScale(), [getXSerializableScale]);
|
|
722
|
+
const rectWidth = useMemo(() => {
|
|
723
|
+
if (xScale !== undefined && xScale.type === 'band') {
|
|
724
|
+
return xScale.bandwidth;
|
|
725
|
+
}
|
|
726
|
+
return 0;
|
|
727
|
+
}, [xScale]);
|
|
728
|
+
const xPos = useDerivedValue(() => {
|
|
729
|
+
const position = unwrapAnimatedValue(scrubberPosition);
|
|
730
|
+
const xPos = position !== undefined && xScale ? getPointOnSerializableScale(position, xScale) : undefined;
|
|
731
|
+
return xPos !== undefined ? xPos - rectWidth / 2 : 0;
|
|
732
|
+
}, [scrubberPosition, xScale]);
|
|
733
|
+
const opacity = useDerivedValue(() => xPos.value !== undefined ? 1 : 0, [xPos]);
|
|
734
|
+
return /*#__PURE__*/_jsx(Rect, {
|
|
735
|
+
color: stroke,
|
|
736
|
+
height: drawingArea.height,
|
|
737
|
+
opacity: opacity,
|
|
738
|
+
width: rectWidth,
|
|
739
|
+
x: xPos,
|
|
740
|
+
y: drawingArea.y
|
|
741
|
+
});
|
|
742
|
+
});
|
|
743
|
+
const candlesData = useMemo(() => candlestickStockData.map(data => [parseFloat(data.low), parseFloat(data.high)]), []);
|
|
744
|
+
const CandlestickBarComponent = /*#__PURE__*/memo(_ref0 => {
|
|
745
|
+
var _yScale, _yScale2;
|
|
746
|
+
let {
|
|
747
|
+
x,
|
|
748
|
+
y,
|
|
749
|
+
width,
|
|
750
|
+
height,
|
|
751
|
+
dataX
|
|
752
|
+
} = _ref0,
|
|
753
|
+
props = _objectWithoutPropertiesLoose(_ref0, _excluded3);
|
|
754
|
+
const {
|
|
755
|
+
getYScale
|
|
756
|
+
} = useCartesianChartContext();
|
|
757
|
+
const yScale = getYScale();
|
|
758
|
+
const wickX = x + width / 2;
|
|
759
|
+
const timePeriodValue = candlestickStockData[dataX];
|
|
760
|
+
const open = parseFloat(timePeriodValue.open);
|
|
761
|
+
const close = parseFloat(timePeriodValue.close);
|
|
762
|
+
const bullish = open < close;
|
|
763
|
+
const theme = useTheme();
|
|
764
|
+
const color = bullish ? theme.color.fgPositive : theme.color.fgNegative;
|
|
765
|
+
const openY = (_yScale = yScale == null ? void 0 : yScale(open)) != null ? _yScale : 0;
|
|
766
|
+
const closeY = (_yScale2 = yScale == null ? void 0 : yScale(close)) != null ? _yScale2 : 0;
|
|
767
|
+
const bodyHeight = Math.abs(openY - closeY);
|
|
768
|
+
const bodyY = openY < closeY ? openY : closeY;
|
|
769
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
770
|
+
children: [/*#__PURE__*/_jsx(SkiaLine, {
|
|
771
|
+
color: color,
|
|
772
|
+
p1: {
|
|
773
|
+
x: wickX,
|
|
774
|
+
y
|
|
775
|
+
},
|
|
776
|
+
p2: {
|
|
777
|
+
x: wickX,
|
|
778
|
+
y: y + height
|
|
779
|
+
},
|
|
780
|
+
strokeWidth: 1
|
|
781
|
+
}), /*#__PURE__*/_jsx(Rect, {
|
|
782
|
+
color: color,
|
|
783
|
+
height: bodyHeight,
|
|
784
|
+
width: width,
|
|
785
|
+
x: x,
|
|
786
|
+
y: bodyY
|
|
787
|
+
})]
|
|
788
|
+
});
|
|
789
|
+
});
|
|
790
|
+
const formatThousandsPriceNumber = useCallback(price => {
|
|
791
|
+
const formattedPrice = new Intl.NumberFormat('en-US', {
|
|
792
|
+
style: 'currency',
|
|
793
|
+
currency: 'USD',
|
|
794
|
+
minimumFractionDigits: 0,
|
|
795
|
+
maximumFractionDigits: 0
|
|
796
|
+
}).format(price / 1000);
|
|
797
|
+
return formattedPrice + "k";
|
|
798
|
+
}, []);
|
|
799
|
+
const formatTime = useCallback(index => {
|
|
800
|
+
if (index === null || index === undefined || index >= candlestickStockData.length) return '';
|
|
801
|
+
const ts = parseInt(candlestickStockData[index].start);
|
|
802
|
+
return new Date(ts * 1000).toLocaleDateString('en-US', {
|
|
803
|
+
month: 'short',
|
|
804
|
+
day: 'numeric'
|
|
805
|
+
});
|
|
806
|
+
}, []);
|
|
807
|
+
const getScrubberAccessibilityLabel = useCallback(index => {
|
|
808
|
+
const candle = candlestickStockData[index];
|
|
809
|
+
return formatTime(index) + ": O " + formatThousandsPriceNumber(parseFloat(candle.open)) + " H " + formatThousandsPriceNumber(parseFloat(candle.high)) + " L " + formatThousandsPriceNumber(parseFloat(candle.low)) + " C " + formatThousandsPriceNumber(parseFloat(candle.close));
|
|
810
|
+
}, [formatTime, formatThousandsPriceNumber]);
|
|
811
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
812
|
+
enableScrubbing: true,
|
|
813
|
+
accessibilityLabel: "Candlestick chart with " + candlesData.length + " data points. Swipe to navigate.",
|
|
814
|
+
animate: false,
|
|
815
|
+
"aria-labelledby": infoTextId,
|
|
816
|
+
borderRadius: 0,
|
|
817
|
+
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
818
|
+
height: 150,
|
|
819
|
+
inset: {
|
|
820
|
+
top: 8,
|
|
821
|
+
bottom: 8,
|
|
822
|
+
left: 0,
|
|
823
|
+
right: 0
|
|
824
|
+
},
|
|
825
|
+
onScrubberPositionChange: onScrubberPositionChange,
|
|
826
|
+
series: [{
|
|
827
|
+
id: 'stock-prices',
|
|
828
|
+
data: candlesData
|
|
829
|
+
}],
|
|
830
|
+
xAxis: {
|
|
831
|
+
scaleType: 'band'
|
|
832
|
+
},
|
|
833
|
+
yAxis: {
|
|
834
|
+
domain: {
|
|
835
|
+
min
|
|
836
|
+
}
|
|
837
|
+
},
|
|
838
|
+
children: [/*#__PURE__*/_jsx(XAxis, {
|
|
839
|
+
tickLabelFormatter: formatTime
|
|
840
|
+
}), /*#__PURE__*/_jsx(YAxis, {
|
|
841
|
+
showGrid: true,
|
|
842
|
+
GridLineComponent: CandleThinSolidLine,
|
|
843
|
+
tickLabelFormatter: formatThousandsPriceNumber,
|
|
844
|
+
width: 40
|
|
845
|
+
}), /*#__PURE__*/_jsx(Scrubber, {
|
|
846
|
+
hideOverlay: true,
|
|
847
|
+
LineComponent: BandwidthHighlight,
|
|
848
|
+
lineStroke: theme.color.fgMuted,
|
|
849
|
+
seriesIds: []
|
|
850
|
+
}), /*#__PURE__*/_jsx(BarPlot, {
|
|
851
|
+
BarComponent: CandlestickBarComponent,
|
|
852
|
+
BarStackComponent: _ref1 => {
|
|
853
|
+
let {
|
|
854
|
+
children
|
|
855
|
+
} = _ref1;
|
|
856
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
857
|
+
children: children
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
})]
|
|
861
|
+
});
|
|
862
|
+
});
|
|
863
|
+
const Candlesticks = () => {
|
|
864
|
+
const infoTextId = useId();
|
|
865
|
+
const [currentIndex, setCurrentIndex] = useState();
|
|
866
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
867
|
+
gap: 2,
|
|
868
|
+
children: [/*#__PURE__*/_jsx(CandlesticksHeader, {
|
|
869
|
+
currentIndex: currentIndex
|
|
870
|
+
}), /*#__PURE__*/_jsx(CandlesticksChart, {
|
|
871
|
+
infoTextId: infoTextId,
|
|
872
|
+
onScrubberPositionChange: setCurrentIndex
|
|
665
873
|
})]
|
|
666
874
|
});
|
|
667
875
|
};
|
|
668
|
-
|
|
876
|
+
const DAY_LENGTH_MINUTES = 1440;
|
|
877
|
+
const sunlightData = [{
|
|
878
|
+
label: 'Jan',
|
|
879
|
+
value: 598
|
|
880
|
+
}, {
|
|
881
|
+
label: 'Feb',
|
|
882
|
+
value: 635
|
|
883
|
+
}, {
|
|
884
|
+
label: 'Mar',
|
|
885
|
+
value: 688
|
|
886
|
+
}, {
|
|
887
|
+
label: 'Apr',
|
|
888
|
+
value: 753
|
|
889
|
+
}, {
|
|
890
|
+
label: 'May',
|
|
891
|
+
value: 812
|
|
892
|
+
}, {
|
|
893
|
+
label: 'Jun',
|
|
894
|
+
value: 855
|
|
895
|
+
}, {
|
|
896
|
+
label: 'Jul',
|
|
897
|
+
value: 861
|
|
898
|
+
}, {
|
|
899
|
+
label: 'Aug',
|
|
900
|
+
value: 828
|
|
901
|
+
}, {
|
|
902
|
+
label: 'Sep',
|
|
903
|
+
value: 772
|
|
904
|
+
}, {
|
|
905
|
+
label: 'Oct',
|
|
906
|
+
value: 710
|
|
907
|
+
}, {
|
|
908
|
+
label: 'Nov',
|
|
909
|
+
value: 648
|
|
910
|
+
}, {
|
|
911
|
+
label: 'Dec',
|
|
912
|
+
value: 605
|
|
913
|
+
}];
|
|
914
|
+
const SunlightChartInner = /*#__PURE__*/memo(_ref10 => {
|
|
915
|
+
let {
|
|
916
|
+
data,
|
|
917
|
+
height = 300
|
|
918
|
+
} = _ref10,
|
|
919
|
+
props = _objectWithoutPropertiesLoose(_ref10, _excluded4);
|
|
920
|
+
const theme = useTheme();
|
|
921
|
+
const SunlightThinSolidLine = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(SolidLine, _extends({}, props, {
|
|
922
|
+
strokeWidth: 1
|
|
923
|
+
})));
|
|
924
|
+
return /*#__PURE__*/_jsxs(CartesianChart, _extends({}, props, {
|
|
925
|
+
height: height,
|
|
926
|
+
series: [{
|
|
927
|
+
id: 'sunlight',
|
|
928
|
+
data: data.map(_ref11 => {
|
|
929
|
+
let {
|
|
930
|
+
value
|
|
931
|
+
} = _ref11;
|
|
932
|
+
return value;
|
|
933
|
+
}),
|
|
934
|
+
yAxisId: 'sunlight',
|
|
935
|
+
color: "rgb(" + theme.spectrum.yellow40 + ")"
|
|
936
|
+
}, {
|
|
937
|
+
id: 'day',
|
|
938
|
+
data: data.map(() => DAY_LENGTH_MINUTES),
|
|
939
|
+
yAxisId: 'day',
|
|
940
|
+
color: "rgb(" + theme.spectrum.blue100 + ")"
|
|
941
|
+
}],
|
|
942
|
+
xAxis: _extends({}, props.xAxis, {
|
|
943
|
+
scaleType: 'band',
|
|
944
|
+
data: data.map(_ref12 => {
|
|
945
|
+
let {
|
|
946
|
+
label
|
|
947
|
+
} = _ref12;
|
|
948
|
+
return label;
|
|
949
|
+
})
|
|
950
|
+
}),
|
|
951
|
+
yAxis: [{
|
|
952
|
+
id: 'day',
|
|
953
|
+
domain: {
|
|
954
|
+
min: 0,
|
|
955
|
+
max: DAY_LENGTH_MINUTES
|
|
956
|
+
},
|
|
957
|
+
domainLimit: 'strict'
|
|
958
|
+
}, {
|
|
959
|
+
id: 'sunlight',
|
|
960
|
+
domain: {
|
|
961
|
+
min: 0,
|
|
962
|
+
max: DAY_LENGTH_MINUTES
|
|
963
|
+
},
|
|
964
|
+
domainLimit: 'strict'
|
|
965
|
+
}],
|
|
966
|
+
children: [/*#__PURE__*/_jsx(YAxis, {
|
|
967
|
+
showGrid: true,
|
|
968
|
+
showLine: true,
|
|
969
|
+
GridLineComponent: SunlightThinSolidLine,
|
|
970
|
+
axisId: "day",
|
|
971
|
+
position: "left"
|
|
972
|
+
}), /*#__PURE__*/_jsx(XAxis, {
|
|
973
|
+
showLine: true
|
|
974
|
+
}), /*#__PURE__*/_jsx(BarPlot, {
|
|
975
|
+
seriesIds: ['day'],
|
|
976
|
+
transitions: {
|
|
977
|
+
enter: null
|
|
978
|
+
}
|
|
979
|
+
}), /*#__PURE__*/_jsx(BarPlot, {
|
|
980
|
+
borderRadius: 0,
|
|
981
|
+
seriesIds: ['sunlight'],
|
|
982
|
+
transitions: {
|
|
983
|
+
enter: {
|
|
984
|
+
type: 'spring',
|
|
985
|
+
stiffness: 700,
|
|
986
|
+
damping: 40,
|
|
987
|
+
staggerDelay: 1000
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
})]
|
|
991
|
+
}));
|
|
992
|
+
});
|
|
993
|
+
const SunlightChart = () => {
|
|
994
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
995
|
+
gap: 2,
|
|
996
|
+
children: [/*#__PURE__*/_jsx(SunlightChartInner, {
|
|
997
|
+
data: sunlightData
|
|
998
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
999
|
+
color: "fgMuted",
|
|
1000
|
+
font: "caption",
|
|
1001
|
+
textAlign: "center",
|
|
1002
|
+
children: "2026 Sunlight data for the first day of each month in Atlanta, Georgia, provided by NOAA."
|
|
1003
|
+
})]
|
|
1004
|
+
});
|
|
1005
|
+
};
|
|
1006
|
+
const PriceRange = () => {
|
|
1007
|
+
const candles = btcCandles.slice(0, 180).reverse();
|
|
1008
|
+
const data = useMemo(() => candles.map(candle => [parseFloat(candle.low), parseFloat(candle.high)]), [candles]);
|
|
1009
|
+
const min = useMemo(() => Math.min(...data.map(_ref13 => {
|
|
1010
|
+
let [low] = _ref13;
|
|
1011
|
+
return low;
|
|
1012
|
+
})), [data]);
|
|
1013
|
+
const max = useMemo(() => Math.max(...data.map(_ref14 => {
|
|
1014
|
+
let [, high] = _ref14;
|
|
1015
|
+
return high;
|
|
1016
|
+
})), [data]);
|
|
1017
|
+
const tickFormatter = useCallback(value => new Intl.NumberFormat('en-US', {
|
|
1018
|
+
style: 'currency',
|
|
1019
|
+
currency: 'USD',
|
|
1020
|
+
notation: 'compact',
|
|
1021
|
+
maximumFractionDigits: 0
|
|
1022
|
+
}).format(value), []);
|
|
1023
|
+
return /*#__PURE__*/_jsx(BarChart, {
|
|
1024
|
+
showYAxis: true,
|
|
1025
|
+
height: 150,
|
|
1026
|
+
series: [{
|
|
1027
|
+
id: 'prices',
|
|
1028
|
+
data,
|
|
1029
|
+
color: assets.btc.color
|
|
1030
|
+
}],
|
|
1031
|
+
yAxis: {
|
|
1032
|
+
domain: {
|
|
1033
|
+
min,
|
|
1034
|
+
max
|
|
1035
|
+
},
|
|
1036
|
+
showGrid: true,
|
|
1037
|
+
tickLabelFormatter: tickFormatter
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
};
|
|
1041
|
+
const HorizontalBarChart = () => {
|
|
1042
|
+
const labels = ['BTC', 'ETH', 'SOL', 'ADA'];
|
|
1043
|
+
const allocation = [42, 28, 18, 12];
|
|
1044
|
+
return /*#__PURE__*/_jsx(BarChart, {
|
|
1045
|
+
showXAxis: true,
|
|
1046
|
+
showYAxis: true,
|
|
1047
|
+
height: 220,
|
|
1048
|
+
layout: "horizontal",
|
|
1049
|
+
series: [{
|
|
1050
|
+
id: 'allocation',
|
|
1051
|
+
data: allocation,
|
|
1052
|
+
color: assets.btc.color
|
|
1053
|
+
}],
|
|
1054
|
+
xAxis: {
|
|
1055
|
+
domain: {
|
|
1056
|
+
min: 0,
|
|
1057
|
+
max: 50
|
|
1058
|
+
},
|
|
1059
|
+
tickLabelFormatter: value => value + "%"
|
|
1060
|
+
},
|
|
1061
|
+
yAxis: {
|
|
1062
|
+
data: labels,
|
|
1063
|
+
scaleType: 'band'
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
};
|
|
1067
|
+
function BuyVsSellExample() {
|
|
1068
|
+
function BuyVsSellLegend(_ref15) {
|
|
1069
|
+
let {
|
|
1070
|
+
buy,
|
|
1071
|
+
sell
|
|
1072
|
+
} = _ref15;
|
|
1073
|
+
const theme = useTheme();
|
|
1074
|
+
return /*#__PURE__*/_jsxs(HStack, {
|
|
1075
|
+
gap: 1,
|
|
1076
|
+
justifyContent: "space-between",
|
|
1077
|
+
children: [/*#__PURE__*/_jsx(DefaultLegendEntry, {
|
|
1078
|
+
color: theme.color.fgPositive,
|
|
1079
|
+
label: /*#__PURE__*/_jsxs(Text, {
|
|
1080
|
+
color: "fgMuted",
|
|
1081
|
+
font: "legal",
|
|
1082
|
+
children: [buy, "% bought"]
|
|
1083
|
+
}),
|
|
1084
|
+
seriesId: "buy"
|
|
1085
|
+
}), /*#__PURE__*/_jsx(DefaultLegendEntry, {
|
|
1086
|
+
color: theme.color.fgNegative,
|
|
1087
|
+
label: /*#__PURE__*/_jsxs(Text, {
|
|
1088
|
+
color: "fgMuted",
|
|
1089
|
+
font: "legal",
|
|
1090
|
+
children: [sell, "% sold"]
|
|
1091
|
+
}),
|
|
1092
|
+
seriesId: "sell"
|
|
1093
|
+
})]
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
function BuyVsSellChart(_ref16) {
|
|
1097
|
+
let {
|
|
1098
|
+
buy,
|
|
1099
|
+
sell,
|
|
1100
|
+
animate = true,
|
|
1101
|
+
borderRadius = 3,
|
|
1102
|
+
height = 6,
|
|
1103
|
+
inset = 0,
|
|
1104
|
+
layout = 'horizontal',
|
|
1105
|
+
stackGap = 4,
|
|
1106
|
+
xAxis,
|
|
1107
|
+
yAxis,
|
|
1108
|
+
barMinSize = height
|
|
1109
|
+
} = _ref16,
|
|
1110
|
+
props = _objectWithoutPropertiesLoose(_ref16, _excluded5);
|
|
1111
|
+
const theme = useTheme();
|
|
1112
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
1113
|
+
gap: 1.5,
|
|
1114
|
+
children: [/*#__PURE__*/_jsx(BarChart, _extends({
|
|
1115
|
+
roundBaseline: true,
|
|
1116
|
+
stacked: true,
|
|
1117
|
+
animate: animate,
|
|
1118
|
+
barMinSize: barMinSize,
|
|
1119
|
+
borderRadius: borderRadius,
|
|
1120
|
+
height: height,
|
|
1121
|
+
inset: inset,
|
|
1122
|
+
layout: layout,
|
|
1123
|
+
series: [{
|
|
1124
|
+
id: 'buy',
|
|
1125
|
+
data: [buy],
|
|
1126
|
+
color: theme.color.fgPositive,
|
|
1127
|
+
legendShape: 'circle'
|
|
1128
|
+
}, {
|
|
1129
|
+
id: 'sell',
|
|
1130
|
+
data: [sell],
|
|
1131
|
+
color: theme.color.fgNegative,
|
|
1132
|
+
legendShape: 'circle'
|
|
1133
|
+
}],
|
|
1134
|
+
stackGap: stackGap,
|
|
1135
|
+
transitions: {
|
|
1136
|
+
enter: {
|
|
1137
|
+
type: 'timing',
|
|
1138
|
+
duration: 5000,
|
|
1139
|
+
delay: 2000
|
|
1140
|
+
}
|
|
1141
|
+
},
|
|
1142
|
+
xAxis: _extends({
|
|
1143
|
+
domainLimit: 'strict'
|
|
1144
|
+
}, xAxis),
|
|
1145
|
+
yAxis: _extends({
|
|
1146
|
+
categoryPadding: 0
|
|
1147
|
+
}, yAxis)
|
|
1148
|
+
}, props)), /*#__PURE__*/_jsx(BuyVsSellLegend, {
|
|
1149
|
+
buy: buy,
|
|
1150
|
+
sell: sell
|
|
1151
|
+
})]
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
return /*#__PURE__*/_jsx(BuyVsSellChart, {
|
|
1155
|
+
buy: 76,
|
|
1156
|
+
sell: 24
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
const PopulationPyramid = () => {
|
|
1160
|
+
const theme = useTheme();
|
|
1161
|
+
const ageGroups = ['100+ yrs', '95-99 yrs', '90-94 yrs', '85-89 yrs', '80-84 yrs', '75-79 yrs', '70-74 yrs', '65-69 yrs', '60-64 yrs', '55-59 yrs', '50-54 yrs', '45-49 yrs', '40-44 yrs', '35-39 yrs', '30-34 yrs', '25-29 yrs', '20-24 yrs', '15-19 yrs', '10-14 yrs', '5-9 yrs', '0-4 yrs'];
|
|
1162
|
+
const malePopulation = [14587, 48604, 83560, 128957, 184152, 248505, 498683, 706420, 852333, 939629, 1002195, 1001264, 960282, 1161371, 1105023, 1061755, 1019343, 1023264, 1026330, 984773, 944071];
|
|
1163
|
+
const femalePopulation = [14122, 46974, 80768, 124663, 178043, 240293, 482271, 683270, 824525, 909115, 969807, 969070, 929571, 1122380, 1068050, 1026356, 985483, 989404, 992505, 952453, 913222];
|
|
1164
|
+
const numberWithSuffixFormatter = useMemo(() => new Intl.NumberFormat('en-US', {
|
|
1165
|
+
notation: 'compact'
|
|
1166
|
+
}), []);
|
|
1167
|
+
const tickLabelFormatter = useCallback(value => numberWithSuffixFormatter.format(Math.abs(value)), [numberWithSuffixFormatter]);
|
|
1168
|
+
const domainSymmetric = useCallback(bounds => {
|
|
1169
|
+
const extremum = Math.max(-bounds.min, bounds.max);
|
|
1170
|
+
const roundedExtremum = Math.ceil(extremum / 100000) * 100000;
|
|
1171
|
+
return {
|
|
1172
|
+
min: -roundedExtremum,
|
|
1173
|
+
max: roundedExtremum
|
|
1174
|
+
};
|
|
1175
|
+
}, []);
|
|
1176
|
+
const series = [{
|
|
1177
|
+
id: 'male',
|
|
1178
|
+
label: 'Male',
|
|
1179
|
+
data: malePopulation.map(population => -population),
|
|
1180
|
+
color: "rgb(" + theme.spectrum.blue40 + ")",
|
|
1181
|
+
stackId: 'population'
|
|
1182
|
+
}, {
|
|
1183
|
+
id: 'female',
|
|
1184
|
+
label: 'Female',
|
|
1185
|
+
data: femalePopulation,
|
|
1186
|
+
color: "rgb(" + theme.spectrum.pink40 + ")",
|
|
1187
|
+
stackId: 'population'
|
|
1188
|
+
}];
|
|
1189
|
+
return /*#__PURE__*/_jsx(VStack, {
|
|
1190
|
+
gap: 2,
|
|
1191
|
+
children: /*#__PURE__*/_jsx(BarChart, {
|
|
1192
|
+
showXAxis: true,
|
|
1193
|
+
showYAxis: true,
|
|
1194
|
+
stacked: true,
|
|
1195
|
+
borderRadius: 2,
|
|
1196
|
+
height: 550,
|
|
1197
|
+
inset: 0,
|
|
1198
|
+
layout: "horizontal",
|
|
1199
|
+
series: series,
|
|
1200
|
+
xAxis: {
|
|
1201
|
+
domain: domainSymmetric,
|
|
1202
|
+
GridLineComponent: ThinSolidLine,
|
|
1203
|
+
showGrid: true,
|
|
1204
|
+
showLine: true,
|
|
1205
|
+
showTickMarks: true,
|
|
1206
|
+
tickLabelFormatter
|
|
1207
|
+
},
|
|
1208
|
+
yAxis: {
|
|
1209
|
+
bandTickMarkPlacement: 'edges',
|
|
1210
|
+
data: ageGroups,
|
|
1211
|
+
position: 'left',
|
|
1212
|
+
showLine: true,
|
|
1213
|
+
showTickMarks: true,
|
|
1214
|
+
width: 80
|
|
1215
|
+
},
|
|
1216
|
+
children: /*#__PURE__*/_jsx(ReferenceLine, {
|
|
1217
|
+
LineComponent: SolidLine,
|
|
1218
|
+
dataX: 0
|
|
1219
|
+
})
|
|
1220
|
+
})
|
|
1221
|
+
});
|
|
1222
|
+
};
|
|
1223
|
+
function ExampleNavigator() {
|
|
1224
|
+
const [currentIndex, setCurrentIndex] = useState(0);
|
|
1225
|
+
const examples = useMemo(() => [{
|
|
1226
|
+
title: 'Basic',
|
|
1227
|
+
component: /*#__PURE__*/_jsx(UpdatingChartValues, {})
|
|
1228
|
+
}, {
|
|
1229
|
+
title: 'Animated Auto-Updating',
|
|
1230
|
+
component: /*#__PURE__*/_jsx(AnimatedUpdatingChartValues, {})
|
|
1231
|
+
}, {
|
|
1232
|
+
title: 'Negative Values with Top Axis',
|
|
1233
|
+
component: /*#__PURE__*/_jsx(NegativeValuesWithTopAxis, {})
|
|
1234
|
+
}, {
|
|
1235
|
+
title: 'Positive and Negative Cash Flow',
|
|
1236
|
+
component: /*#__PURE__*/_jsx(PositiveAndNegativeCashFlow, {})
|
|
1237
|
+
}, {
|
|
1238
|
+
title: 'Fiat & Stablecoin Balance',
|
|
1239
|
+
component: /*#__PURE__*/_jsx(FiatAndStablecoinBalance, {})
|
|
1240
|
+
}, {
|
|
1241
|
+
title: 'Monthly Rewards',
|
|
1242
|
+
component: /*#__PURE__*/_jsx(MonthlyRewards, {})
|
|
1243
|
+
}, {
|
|
1244
|
+
title: 'Multiple Y Axes',
|
|
1245
|
+
component: /*#__PURE__*/_jsx(MultipleYAxes, {})
|
|
1246
|
+
}, {
|
|
1247
|
+
title: 'Y-Axis Continuous ColorMap',
|
|
1248
|
+
component: /*#__PURE__*/_jsx(YAxisContinuousColorMap, {})
|
|
1249
|
+
}, {
|
|
1250
|
+
title: 'Y-Axis Discrete ColorMap',
|
|
1251
|
+
component: /*#__PURE__*/_jsx(YAxisDiscreteColorMap, {})
|
|
1252
|
+
}, {
|
|
1253
|
+
title: 'X-Axis Continuous ColorMap',
|
|
1254
|
+
component: /*#__PURE__*/_jsx(XAxisContinuousColorMap, {})
|
|
1255
|
+
}, {
|
|
1256
|
+
title: 'X-Axis Discrete ColorMap',
|
|
1257
|
+
component: /*#__PURE__*/_jsx(XAxisDiscreteColorMap, {})
|
|
1258
|
+
}, {
|
|
1259
|
+
title: 'X-Axis Multi-Segment ColorMap',
|
|
1260
|
+
component: /*#__PURE__*/_jsx(XAxisMultiSegmentColorMap, {})
|
|
1261
|
+
}, {
|
|
1262
|
+
title: 'ColorMap with Opacity',
|
|
1263
|
+
component: /*#__PURE__*/_jsx(ColorMapWithOpacity, {})
|
|
1264
|
+
}, {
|
|
1265
|
+
title: 'Band Grid Position',
|
|
1266
|
+
component: /*#__PURE__*/_jsxs(VStack, {
|
|
1267
|
+
gap: 2,
|
|
1268
|
+
children: [/*#__PURE__*/_jsx(BandGridPositionExample, {
|
|
1269
|
+
position: "edges"
|
|
1270
|
+
}), /*#__PURE__*/_jsx(BandGridPositionExample, {
|
|
1271
|
+
position: "start"
|
|
1272
|
+
}), /*#__PURE__*/_jsx(BandGridPositionExample, {
|
|
1273
|
+
position: "middle"
|
|
1274
|
+
}), /*#__PURE__*/_jsx(BandGridPositionExample, {
|
|
1275
|
+
position: "end"
|
|
1276
|
+
})]
|
|
1277
|
+
})
|
|
1278
|
+
}, {
|
|
1279
|
+
title: 'Candlesticks',
|
|
1280
|
+
component: /*#__PURE__*/_jsx(Candlesticks, {})
|
|
1281
|
+
}, {
|
|
1282
|
+
title: 'Monthly Sunlight',
|
|
1283
|
+
component: /*#__PURE__*/_jsx(SunlightChart, {})
|
|
1284
|
+
}, {
|
|
1285
|
+
title: 'Price Range',
|
|
1286
|
+
component: /*#__PURE__*/_jsx(PriceRange, {})
|
|
1287
|
+
}, {
|
|
1288
|
+
title: 'Horizontal Layout',
|
|
1289
|
+
component: /*#__PURE__*/_jsx(HorizontalBarChart, {})
|
|
1290
|
+
}, {
|
|
1291
|
+
title: 'Buy vs Sell',
|
|
1292
|
+
component: /*#__PURE__*/_jsx(BuyVsSellExample, {})
|
|
1293
|
+
}, {
|
|
1294
|
+
title: 'Population Pyramid',
|
|
1295
|
+
component: /*#__PURE__*/_jsx(PopulationPyramid, {})
|
|
1296
|
+
}], []);
|
|
1297
|
+
const currentExample = examples[currentIndex];
|
|
1298
|
+
const handlePrevious = useCallback(() => {
|
|
1299
|
+
setCurrentIndex(prev => (prev - 1 + examples.length) % examples.length);
|
|
1300
|
+
}, [examples.length]);
|
|
1301
|
+
const handleNext = useCallback(() => {
|
|
1302
|
+
setCurrentIndex(prev => (prev + 1 + examples.length) % examples.length);
|
|
1303
|
+
}, [examples.length]);
|
|
1304
|
+
return /*#__PURE__*/_jsx(ExampleScreen, {
|
|
1305
|
+
paddingX: 0,
|
|
1306
|
+
children: /*#__PURE__*/_jsxs(VStack, {
|
|
1307
|
+
gap: 4,
|
|
1308
|
+
children: [/*#__PURE__*/_jsxs(HStack, {
|
|
1309
|
+
alignItems: "center",
|
|
1310
|
+
justifyContent: "space-between",
|
|
1311
|
+
padding: 2,
|
|
1312
|
+
children: [/*#__PURE__*/_jsx(IconButton, {
|
|
1313
|
+
accessibilityHint: "Navigate to previous example",
|
|
1314
|
+
accessibilityLabel: "Previous",
|
|
1315
|
+
name: "arrowLeft",
|
|
1316
|
+
onPress: handlePrevious,
|
|
1317
|
+
variant: "secondary"
|
|
1318
|
+
}), /*#__PURE__*/_jsxs(VStack, {
|
|
1319
|
+
alignItems: "center",
|
|
1320
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
1321
|
+
font: "title3",
|
|
1322
|
+
children: currentExample.title
|
|
1323
|
+
}), /*#__PURE__*/_jsxs(Text, {
|
|
1324
|
+
color: "fgMuted",
|
|
1325
|
+
font: "label1",
|
|
1326
|
+
children: [currentIndex + 1, " / ", examples.length]
|
|
1327
|
+
})]
|
|
1328
|
+
}), /*#__PURE__*/_jsx(IconButton, {
|
|
1329
|
+
accessibilityHint: "Navigate to next example",
|
|
1330
|
+
accessibilityLabel: "Next",
|
|
1331
|
+
name: "arrowRight",
|
|
1332
|
+
onPress: handleNext,
|
|
1333
|
+
variant: "secondary"
|
|
1334
|
+
})]
|
|
1335
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
1336
|
+
padding: 1,
|
|
1337
|
+
children: currentExample.component
|
|
1338
|
+
})]
|
|
1339
|
+
})
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
export default ExampleNavigator;
|