@coinbase/cds-mobile-visualization 3.4.0-beta.2 → 3.4.0-beta.20
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 +122 -0
- package/dts/chart/CartesianChart.d.ts +92 -34
- package/dts/chart/CartesianChart.d.ts.map +1 -1
- package/dts/chart/ChartContextBridge.d.ts +28 -0
- package/dts/chart/ChartContextBridge.d.ts.map +1 -0
- package/dts/chart/ChartProvider.d.ts +3 -0
- package/dts/chart/ChartProvider.d.ts.map +1 -1
- package/dts/chart/Path.d.ts +97 -32
- package/dts/chart/Path.d.ts.map +1 -1
- package/dts/chart/PeriodSelector.d.ts +6 -13
- package/dts/chart/PeriodSelector.d.ts.map +1 -1
- package/dts/chart/area/Area.d.ts +39 -28
- package/dts/chart/area/Area.d.ts.map +1 -1
- package/dts/chart/area/AreaChart.d.ts +51 -10
- package/dts/chart/area/AreaChart.d.ts.map +1 -1
- package/dts/chart/area/DottedArea.d.ts +21 -2
- package/dts/chart/area/DottedArea.d.ts.map +1 -1
- package/dts/chart/area/GradientArea.d.ts +19 -13
- package/dts/chart/area/GradientArea.d.ts.map +1 -1
- package/dts/chart/area/SolidArea.d.ts +17 -2
- package/dts/chart/area/SolidArea.d.ts.map +1 -1
- package/dts/chart/axis/Axis.d.ts +86 -118
- package/dts/chart/axis/Axis.d.ts.map +1 -1
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
- package/dts/chart/axis/XAxis.d.ts +1 -1
- package/dts/chart/axis/XAxis.d.ts.map +1 -1
- package/dts/chart/axis/YAxis.d.ts +2 -2
- package/dts/chart/axis/YAxis.d.ts.map +1 -1
- package/dts/chart/axis/index.d.ts +1 -0
- package/dts/chart/axis/index.d.ts.map +1 -1
- package/dts/chart/bar/Bar.d.ts +49 -12
- package/dts/chart/bar/Bar.d.ts.map +1 -1
- package/dts/chart/bar/BarChart.d.ts +40 -19
- package/dts/chart/bar/BarChart.d.ts.map +1 -1
- package/dts/chart/bar/BarPlot.d.ts +3 -1
- package/dts/chart/bar/BarPlot.d.ts.map +1 -1
- package/dts/chart/bar/BarStack.d.ts +41 -46
- package/dts/chart/bar/BarStack.d.ts.map +1 -1
- package/dts/chart/bar/BarStackGroup.d.ts +2 -0
- package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
- package/dts/chart/bar/DefaultBar.d.ts +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 +25 -0
- package/dts/chart/gradient/Gradient.d.ts.map +1 -0
- package/dts/chart/gradient/index.d.ts +2 -0
- package/dts/chart/gradient/index.d.ts.map +1 -0
- package/dts/chart/index.d.ts +4 -1
- 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/DefaultReferenceLineLabel.d.ts +9 -0
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
- package/dts/chart/line/DottedLine.d.ts +13 -5
- package/dts/chart/line/DottedLine.d.ts.map +1 -1
- package/dts/chart/line/Line.d.ts +61 -27
- package/dts/chart/line/Line.d.ts.map +1 -1
- package/dts/chart/line/LineChart.d.ts +43 -9
- package/dts/chart/line/LineChart.d.ts.map +1 -1
- package/dts/chart/line/ReferenceLine.d.ts +68 -20
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
- package/dts/chart/line/SolidLine.d.ts +8 -5
- package/dts/chart/line/SolidLine.d.ts.map +1 -1
- package/dts/chart/line/index.d.ts +1 -1
- package/dts/chart/line/index.d.ts.map +1 -1
- package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
- package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
- package/dts/chart/point/Point.d.ts +136 -0
- package/dts/chart/point/Point.d.ts.map +1 -0
- package/dts/chart/point/index.d.ts +3 -0
- package/dts/chart/point/index.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +38 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +11 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/Scrubber.d.ts +230 -42
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +54 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +46 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberProvider.d.ts +6 -3
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -1
- package/dts/chart/scrubber/index.d.ts +3 -0
- package/dts/chart/scrubber/index.d.ts.map +1 -1
- package/dts/chart/text/ChartText.d.ts +151 -77
- package/dts/chart/text/ChartText.d.ts.map +1 -1
- package/dts/chart/text/{SmartChartTextGroup.d.ts → ChartTextGroup.d.ts} +9 -3
- package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
- package/dts/chart/text/index.d.ts +1 -1
- package/dts/chart/text/index.d.ts.map +1 -1
- package/dts/chart/utils/axis.d.ts +25 -1
- package/dts/chart/utils/axis.d.ts.map +1 -1
- package/dts/chart/utils/bar.d.ts +34 -0
- package/dts/chart/utils/bar.d.ts.map +1 -1
- package/dts/chart/utils/chart.d.ts +52 -7
- package/dts/chart/utils/chart.d.ts.map +1 -1
- package/dts/chart/utils/context.d.ts +28 -7
- package/dts/chart/utils/context.d.ts.map +1 -1
- package/dts/chart/utils/gradient.d.ts +117 -0
- package/dts/chart/utils/gradient.d.ts.map +1 -0
- package/dts/chart/utils/index.d.ts +3 -0
- package/dts/chart/utils/index.d.ts.map +1 -1
- package/dts/chart/utils/path.d.ts +59 -0
- package/dts/chart/utils/path.d.ts.map +1 -1
- package/dts/chart/utils/point.d.ts +71 -7
- package/dts/chart/utils/point.d.ts.map +1 -1
- package/dts/chart/utils/scale.d.ts +102 -0
- package/dts/chart/utils/scale.d.ts.map +1 -1
- package/dts/chart/utils/scrubber.d.ts +40 -0
- package/dts/chart/utils/scrubber.d.ts.map +1 -0
- package/dts/chart/utils/transition.d.ts +178 -0
- package/dts/chart/utils/transition.d.ts.map +1 -0
- package/esm/chart/CartesianChart.js +199 -75
- package/esm/chart/ChartContextBridge.js +159 -0
- package/esm/chart/ChartProvider.js +2 -2
- package/esm/chart/Path.js +200 -114
- package/esm/chart/PeriodSelector.js +7 -3
- package/esm/chart/__stories__/CartesianChart.stories.js +307 -134
- package/esm/chart/__stories__/ChartTransitions.stories.js +629 -0
- package/esm/chart/__stories__/PeriodSelector.stories.js +201 -75
- package/esm/chart/area/Area.js +27 -35
- package/esm/chart/area/AreaChart.js +17 -12
- package/esm/chart/area/DottedArea.js +64 -108
- package/esm/chart/area/GradientArea.js +37 -91
- package/esm/chart/area/SolidArea.js +24 -8
- package/esm/chart/area/__stories__/AreaChart.stories.js +1 -1
- package/esm/chart/axis/Axis.js +5 -39
- package/esm/chart/axis/DefaultAxisTickLabel.js +11 -0
- package/esm/chart/axis/XAxis.js +148 -66
- package/esm/chart/axis/YAxis.js +149 -65
- package/esm/chart/axis/__stories__/Axis.stories.js +259 -1
- package/esm/chart/axis/index.js +1 -0
- package/esm/chart/bar/Bar.js +7 -1
- package/esm/chart/bar/BarChart.js +17 -37
- package/esm/chart/bar/BarPlot.js +43 -35
- package/esm/chart/bar/BarStack.js +84 -37
- package/esm/chart/bar/BarStackGroup.js +7 -17
- package/esm/chart/bar/DefaultBar.js +29 -51
- package/esm/chart/bar/DefaultBarStack.js +34 -58
- package/esm/chart/bar/__stories__/BarChart.stories.js +948 -88
- package/esm/chart/gradient/Gradient.js +53 -0
- package/esm/chart/gradient/index.js +1 -0
- package/esm/chart/index.js +4 -1
- 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/DefaultReferenceLineLabel.js +66 -0
- package/esm/chart/line/DottedLine.js +31 -14
- package/esm/chart/line/Line.js +96 -68
- package/esm/chart/line/LineChart.js +21 -14
- package/esm/chart/line/ReferenceLine.js +80 -63
- package/esm/chart/line/SolidLine.js +27 -10
- package/esm/chart/line/__stories__/LineChart.stories.js +1748 -2048
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +177 -28
- package/esm/chart/line/index.js +1 -1
- package/esm/chart/point/DefaultPointLabel.js +39 -0
- package/esm/chart/point/Point.js +186 -0
- package/esm/chart/point/index.js +2 -0
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +180 -0
- package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +43 -0
- package/esm/chart/scrubber/DefaultScrubberLabel.js +28 -0
- package/esm/chart/scrubber/Scrubber.js +130 -144
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +165 -0
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +208 -0
- package/esm/chart/scrubber/ScrubberProvider.js +46 -54
- package/esm/chart/scrubber/__stories__/Scrubber.stories.js +760 -0
- package/esm/chart/scrubber/index.js +3 -1
- package/esm/chart/text/ChartText.js +242 -174
- package/esm/chart/text/{SmartChartTextGroup.js → ChartTextGroup.js} +6 -5
- package/esm/chart/text/index.js +1 -1
- package/esm/chart/utils/axis.js +47 -31
- package/esm/chart/utils/bar.js +43 -0
- package/esm/chart/utils/chart.js +57 -3
- package/esm/chart/utils/gradient.js +305 -0
- package/esm/chart/utils/index.js +3 -0
- package/esm/chart/utils/path.js +84 -8
- package/esm/chart/utils/point.js +171 -17
- package/esm/chart/utils/scale.js +242 -2
- package/esm/chart/utils/scrubber.js +146 -0
- package/esm/chart/utils/transition.js +220 -0
- package/esm/sparkline/__figma__/Sparkline.figma.js +1 -1
- package/esm/sparkline/__stories__/Sparkline.stories.js +11 -7
- package/esm/sparkline/__stories__/SparklineGradient.stories.js +7 -4
- package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +1 -1
- package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +51 -26
- package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +1 -1
- package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +17 -9
- package/package.json +15 -10
- package/dts/chart/Point.d.ts +0 -103
- package/dts/chart/Point.d.ts.map +0 -1
- package/dts/chart/line/GradientLine.d.ts +0 -45
- package/dts/chart/line/GradientLine.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberBeacon.d.ts +0 -75
- package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +0 -1
- package/dts/chart/text/SmartChartTextGroup.d.ts.map +0 -1
- package/esm/chart/Point.js +0 -111
- package/esm/chart/__stories__/Chart.stories.js +0 -79
- package/esm/chart/line/GradientLine.js +0 -62
- package/esm/chart/scrubber/ScrubberBeacon.js +0 -199
|
@@ -1,22 +1,30 @@
|
|
|
1
|
-
const _excluded = ["children"]
|
|
1
|
+
const _excluded = ["children"],
|
|
2
|
+
_excluded2 = ["animate"],
|
|
3
|
+
_excluded3 = ["x", "y", "width", "height", "originY", "dataX"],
|
|
4
|
+
_excluded4 = ["data", "height"];
|
|
2
5
|
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
6
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
4
|
-
import { memo,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import { memo, useCallback, useEffect, useId, useMemo, useState } from 'react';
|
|
8
|
+
import { useDerivedValue } from 'react-native-reanimated';
|
|
9
|
+
import { assets } from '@coinbase/cds-common/internal/data/assets';
|
|
10
|
+
import { candles as btcCandles } from '@coinbase/cds-common/internal/data/candles';
|
|
11
|
+
import { Button, IconButton } from '@coinbase/cds-mobile/buttons';
|
|
12
|
+
import { ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
|
|
8
13
|
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
9
|
-
import { VStack } from '@coinbase/cds-mobile/layout';
|
|
14
|
+
import { Box, HStack, VStack } from '@coinbase/cds-mobile/layout';
|
|
15
|
+
import { Text } from '@coinbase/cds-mobile/typography';
|
|
16
|
+
import { Line as SkiaLine, Rect } from '@shopify/react-native-skia';
|
|
10
17
|
import { XAxis, YAxis } from '../../axis';
|
|
11
18
|
import { CartesianChart } from '../../CartesianChart';
|
|
12
19
|
import { useCartesianChartContext } from '../../ChartProvider';
|
|
13
20
|
import { ReferenceLine, SolidLine } from '../../line';
|
|
14
|
-
import {
|
|
21
|
+
import { Scrubber } from '../../scrubber';
|
|
22
|
+
import { getPointOnSerializableScale, unwrapAnimatedValue, useScrubberContext } from '../../utils';
|
|
15
23
|
import { Bar } from '../Bar';
|
|
16
24
|
import { BarChart } from '../BarChart';
|
|
17
25
|
import { BarPlot } from '../BarPlot';
|
|
18
26
|
import { DefaultBarStack } from '../DefaultBarStack';
|
|
19
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
20
28
|
const ThinSolidLine = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(SolidLine, _extends({}, props, {
|
|
21
29
|
strokeWidth: 1
|
|
22
30
|
})));
|
|
@@ -92,13 +100,37 @@ const FiatAndStablecoinBalance = () => {
|
|
|
92
100
|
}
|
|
93
101
|
});
|
|
94
102
|
};
|
|
95
|
-
const
|
|
103
|
+
const CustomBarStackComponent = /*#__PURE__*/memo(_ref => {
|
|
104
|
+
let {
|
|
105
|
+
children
|
|
106
|
+
} = _ref,
|
|
107
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
96
108
|
const theme = useTheme();
|
|
109
|
+
if (props.height === 0) {
|
|
110
|
+
const diameter = props.width;
|
|
111
|
+
return /*#__PURE__*/_jsx(Bar, {
|
|
112
|
+
roundBottom: true,
|
|
113
|
+
roundTop: true,
|
|
114
|
+
borderRadius: 1000,
|
|
115
|
+
fill: theme.color.bgTertiary,
|
|
116
|
+
height: diameter,
|
|
117
|
+
originY: props.y,
|
|
118
|
+
width: diameter,
|
|
119
|
+
x: props.x,
|
|
120
|
+
y: props.y - diameter
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return /*#__PURE__*/_jsx(DefaultBarStack, _extends({}, props, {
|
|
124
|
+
children: children
|
|
125
|
+
}));
|
|
126
|
+
});
|
|
127
|
+
const MonthlyRewards = () => {
|
|
97
128
|
const months = ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'];
|
|
98
129
|
const purple = [null, 6, 8, 10, 7, 6, 6, 8, null, null, null, null];
|
|
99
130
|
const blue = [null, 10, 12, 11, 10, 9, 10, 11, null, null, null, null];
|
|
100
131
|
const cyan = [null, 7, 10, 12, 11, 10, 8, 11, null, null, null, null];
|
|
101
132
|
const green = [10, null, null, null, 1, null, null, 6, null, null, null, null];
|
|
133
|
+
const [roundBaseline, setRoundBaseline] = useState(true);
|
|
102
134
|
const series = [{
|
|
103
135
|
id: 'purple',
|
|
104
136
|
data: purple,
|
|
@@ -116,46 +148,29 @@ const MonthlyRewards = () => {
|
|
|
116
148
|
data: green,
|
|
117
149
|
color: '#33c481'
|
|
118
150
|
}];
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return /*#__PURE__*/_jsx(BarChart, {
|
|
143
|
-
roundBaseline: true,
|
|
144
|
-
showXAxis: true,
|
|
145
|
-
stacked: true,
|
|
146
|
-
BarStackComponent: CustomBarStackComponent,
|
|
147
|
-
borderRadius: 1000,
|
|
148
|
-
height: 300,
|
|
149
|
-
inset: 0,
|
|
150
|
-
series: series,
|
|
151
|
-
showYAxis: false,
|
|
152
|
-
stackMinSize: 24,
|
|
153
|
-
xAxis: {
|
|
154
|
-
tickLabelFormatter: index => {
|
|
155
|
-
return months[index];
|
|
156
|
-
},
|
|
157
|
-
categoryPadding: 0.27
|
|
158
|
-
}
|
|
151
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
152
|
+
gap: 2,
|
|
153
|
+
children: [/*#__PURE__*/_jsx(BarChart, {
|
|
154
|
+
showXAxis: true,
|
|
155
|
+
stacked: true,
|
|
156
|
+
BarStackComponent: CustomBarStackComponent,
|
|
157
|
+
borderRadius: 1000,
|
|
158
|
+
height: 300,
|
|
159
|
+
inset: 0,
|
|
160
|
+
roundBaseline: roundBaseline,
|
|
161
|
+
series: series,
|
|
162
|
+
showYAxis: false,
|
|
163
|
+
stackMinSize: 24,
|
|
164
|
+
xAxis: {
|
|
165
|
+
tickLabelFormatter: index => {
|
|
166
|
+
return months[index];
|
|
167
|
+
},
|
|
168
|
+
categoryPadding: 0.27
|
|
169
|
+
}
|
|
170
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
171
|
+
onPress: () => setRoundBaseline(!roundBaseline),
|
|
172
|
+
children: "Toggle Round Baseline"
|
|
173
|
+
})]
|
|
159
174
|
});
|
|
160
175
|
};
|
|
161
176
|
const MultipleYAxes = () => {
|
|
@@ -184,37 +199,70 @@ const MultipleYAxes = () => {
|
|
|
184
199
|
}],
|
|
185
200
|
children: [/*#__PURE__*/_jsx(XAxis, {
|
|
186
201
|
showLine: true,
|
|
187
|
-
showTickMarks: true
|
|
202
|
+
showTickMarks: true,
|
|
203
|
+
label: "Month"
|
|
188
204
|
}), /*#__PURE__*/_jsx(YAxis, {
|
|
189
205
|
showGrid: true,
|
|
190
206
|
showLine: true,
|
|
191
207
|
showTickMarks: true,
|
|
192
208
|
axisId: "revenue",
|
|
209
|
+
label: "Revenue",
|
|
193
210
|
position: "left",
|
|
194
211
|
requestedTickCount: 5,
|
|
195
212
|
tickLabelFormatter: value => "$" + value + "k",
|
|
196
|
-
width:
|
|
213
|
+
width: 80
|
|
197
214
|
}), /*#__PURE__*/_jsx(YAxis, {
|
|
198
215
|
showLine: true,
|
|
199
216
|
showTickMarks: true,
|
|
200
217
|
axisId: "profit",
|
|
218
|
+
label: "Profit",
|
|
201
219
|
requestedTickCount: 5,
|
|
202
|
-
tickLabelFormatter: value => "$" + value + "k"
|
|
220
|
+
tickLabelFormatter: value => "$" + value + "k",
|
|
221
|
+
width: 70
|
|
203
222
|
}), /*#__PURE__*/_jsx(BarPlot, {})]
|
|
204
223
|
});
|
|
205
224
|
};
|
|
225
|
+
const initialData = [45, 52, 38, 45, 19, 23, 32];
|
|
226
|
+
const MyCustomLine = /*#__PURE__*/memo(_ref2 => {
|
|
227
|
+
let props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
228
|
+
return /*#__PURE__*/_jsx(SolidLine, _extends({}, props));
|
|
229
|
+
});
|
|
206
230
|
const UpdatingChartValues = () => {
|
|
207
|
-
const [data, setData] = useState(
|
|
231
|
+
const [data, setData] = useState(initialData);
|
|
208
232
|
return /*#__PURE__*/_jsxs(VStack, {
|
|
209
233
|
gap: 2,
|
|
210
234
|
children: [/*#__PURE__*/_jsx(BarChart, {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
235
|
+
height: 100,
|
|
236
|
+
series: [{
|
|
237
|
+
id: 'weekly-data',
|
|
238
|
+
data: data
|
|
239
|
+
}],
|
|
240
|
+
xAxis: {
|
|
241
|
+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
242
|
+
showTickMarks: true,
|
|
243
|
+
showLine: true
|
|
244
|
+
},
|
|
245
|
+
yAxis: {
|
|
246
|
+
requestedTickCount: 5,
|
|
247
|
+
tickLabelFormatter: value => "$" + value + "k",
|
|
248
|
+
showGrid: true,
|
|
249
|
+
showTickMarks: true,
|
|
250
|
+
showLine: true,
|
|
251
|
+
tickMarkSize: 12,
|
|
252
|
+
domain: {
|
|
253
|
+
max: 250
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}), /*#__PURE__*/_jsx(BarChart, {
|
|
257
|
+
height: 100,
|
|
214
258
|
series: [{
|
|
215
259
|
id: 'weekly-data',
|
|
216
260
|
data: data
|
|
217
261
|
}],
|
|
262
|
+
transition: {
|
|
263
|
+
type: 'timing',
|
|
264
|
+
duration: 300
|
|
265
|
+
},
|
|
218
266
|
xAxis: {
|
|
219
267
|
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
220
268
|
showTickMarks: true,
|
|
@@ -226,14 +274,110 @@ const UpdatingChartValues = () => {
|
|
|
226
274
|
showGrid: true,
|
|
227
275
|
showTickMarks: true,
|
|
228
276
|
showLine: true,
|
|
229
|
-
tickMarkSize: 12
|
|
277
|
+
tickMarkSize: 12,
|
|
278
|
+
domain: {
|
|
279
|
+
max: 250
|
|
280
|
+
}
|
|
230
281
|
}
|
|
282
|
+
}), /*#__PURE__*/_jsx(BarChart, {
|
|
283
|
+
height: 100,
|
|
284
|
+
series: [{
|
|
285
|
+
id: 'weekly-data',
|
|
286
|
+
data: data.map((d, i) => i % 2 === 0 ? d : -d)
|
|
287
|
+
}],
|
|
288
|
+
xAxis: {
|
|
289
|
+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
290
|
+
showTickMarks: true,
|
|
291
|
+
showLine: true
|
|
292
|
+
},
|
|
293
|
+
yAxis: {
|
|
294
|
+
requestedTickCount: 5,
|
|
295
|
+
tickLabelFormatter: value => "$" + value + "k",
|
|
296
|
+
showGrid: true,
|
|
297
|
+
showTickMarks: true,
|
|
298
|
+
showLine: true,
|
|
299
|
+
tickMarkSize: 12,
|
|
300
|
+
domain: {
|
|
301
|
+
max: 250
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
children: /*#__PURE__*/_jsx(ReferenceLine, {
|
|
305
|
+
LineComponent: MyCustomLine,
|
|
306
|
+
dataY: 0
|
|
307
|
+
})
|
|
231
308
|
}), /*#__PURE__*/_jsx(Button, {
|
|
232
|
-
onPress: () => setData(data => data.map(d => d +
|
|
309
|
+
onPress: () => setData(data => data[0] > 200 ? initialData : data.map(d => d + 50)),
|
|
233
310
|
children: "Update Data"
|
|
234
311
|
})]
|
|
235
312
|
});
|
|
236
313
|
};
|
|
314
|
+
const AnimatedUpdatingChartValues = () => {
|
|
315
|
+
const [data, setData] = useState([45, 52, 38, 45, 19, 23, 32]);
|
|
316
|
+
useEffect(() => {
|
|
317
|
+
const interval = setInterval(() => {
|
|
318
|
+
setData(prevData => prevData.map(value => {
|
|
319
|
+
// Generate random change between -15 and +15
|
|
320
|
+
const change = Math.floor(Math.random() * 31) - 15;
|
|
321
|
+
// Ensure values stay between 10 and 200
|
|
322
|
+
return Math.max(10, Math.min(200, value + change));
|
|
323
|
+
}));
|
|
324
|
+
}, 1000);
|
|
325
|
+
return () => clearInterval(interval);
|
|
326
|
+
}, []);
|
|
327
|
+
return /*#__PURE__*/_jsx(BarChart, {
|
|
328
|
+
showXAxis: true,
|
|
329
|
+
showYAxis: true,
|
|
330
|
+
height: defaultChartHeight,
|
|
331
|
+
series: [{
|
|
332
|
+
id: 'weekly-data',
|
|
333
|
+
data: data
|
|
334
|
+
}],
|
|
335
|
+
xAxis: {
|
|
336
|
+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
337
|
+
showTickMarks: true,
|
|
338
|
+
showLine: true
|
|
339
|
+
},
|
|
340
|
+
yAxis: {
|
|
341
|
+
requestedTickCount: 5,
|
|
342
|
+
tickLabelFormatter: value => "$" + value + "k",
|
|
343
|
+
showGrid: true,
|
|
344
|
+
showTickMarks: true,
|
|
345
|
+
showLine: true,
|
|
346
|
+
tickMarkSize: 12,
|
|
347
|
+
domain: {
|
|
348
|
+
max: 250
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
const NegativeValuesWithTopAxis = () => {
|
|
354
|
+
const theme = useTheme();
|
|
355
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
356
|
+
height: defaultChartHeight,
|
|
357
|
+
series: [{
|
|
358
|
+
id: 'losses',
|
|
359
|
+
data: [-45, -52, -38, -45, -19, -23, -32],
|
|
360
|
+
color: theme.color.fgNegative
|
|
361
|
+
}],
|
|
362
|
+
xAxis: {
|
|
363
|
+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
364
|
+
scaleType: 'band'
|
|
365
|
+
},
|
|
366
|
+
children: [/*#__PURE__*/_jsx(XAxis, {
|
|
367
|
+
showLine: true,
|
|
368
|
+
showTickMarks: true,
|
|
369
|
+
label: "Day of Week",
|
|
370
|
+
position: "top"
|
|
371
|
+
}), /*#__PURE__*/_jsx(YAxis, {
|
|
372
|
+
showGrid: true,
|
|
373
|
+
showLine: true,
|
|
374
|
+
showTickMarks: true,
|
|
375
|
+
label: "Loss",
|
|
376
|
+
requestedTickCount: 5,
|
|
377
|
+
tickLabelFormatter: value => "$" + value + "k"
|
|
378
|
+
}), /*#__PURE__*/_jsx(BarPlot, {})]
|
|
379
|
+
});
|
|
380
|
+
};
|
|
237
381
|
const tabs = [{
|
|
238
382
|
id: 'week',
|
|
239
383
|
label: '1W'
|
|
@@ -244,39 +388,755 @@ const tabs = [{
|
|
|
244
388
|
id: 'year',
|
|
245
389
|
label: '1Y'
|
|
246
390
|
}];
|
|
247
|
-
const
|
|
248
|
-
var _useContext;
|
|
391
|
+
const YAxisContinuousColorMap = () => {
|
|
249
392
|
const theme = useTheme();
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
393
|
+
return /*#__PURE__*/_jsx(BarChart, {
|
|
394
|
+
showXAxis: true,
|
|
395
|
+
showYAxis: true,
|
|
396
|
+
height: defaultChartHeight,
|
|
397
|
+
series: [{
|
|
398
|
+
id: 'temperature',
|
|
399
|
+
data: [12, 25, 38, 52, 45, 30, 18],
|
|
400
|
+
// Continuous gradient from blue (cold) to red (hot)
|
|
401
|
+
gradient: {
|
|
402
|
+
axis: 'y',
|
|
403
|
+
stops: _ref3 => {
|
|
404
|
+
let {
|
|
405
|
+
min,
|
|
406
|
+
max
|
|
407
|
+
} = _ref3;
|
|
408
|
+
return [{
|
|
409
|
+
offset: min,
|
|
410
|
+
color: theme.color.accentBoldGreen
|
|
411
|
+
}, {
|
|
412
|
+
offset: (min + max) / 2,
|
|
413
|
+
color: theme.color.accentBoldYellow
|
|
414
|
+
}, {
|
|
415
|
+
offset: max,
|
|
416
|
+
color: theme.color.accentBoldRed
|
|
417
|
+
}];
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}],
|
|
421
|
+
xAxis: {
|
|
422
|
+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
|
423
|
+
},
|
|
424
|
+
yAxis: {
|
|
425
|
+
requestedTickCount: 5,
|
|
426
|
+
tickLabelFormatter: value => value + "\xB0C",
|
|
427
|
+
showGrid: true
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
};
|
|
431
|
+
const YAxisDiscreteColorMap = () => {
|
|
432
|
+
const theme = useTheme();
|
|
433
|
+
return /*#__PURE__*/_jsx(BarChart, {
|
|
434
|
+
showXAxis: true,
|
|
435
|
+
showYAxis: true,
|
|
436
|
+
height: defaultChartHeight,
|
|
437
|
+
series: [{
|
|
438
|
+
id: 'temperature',
|
|
439
|
+
data: [12, 25, 38, 52, 45, 30, 18],
|
|
440
|
+
// Hard transitions based on performance thresholds
|
|
441
|
+
gradient: {
|
|
442
|
+
axis: 'y',
|
|
443
|
+
stops: [{
|
|
444
|
+
offset: 20,
|
|
445
|
+
color: theme.color.accentBoldGreen
|
|
446
|
+
}, {
|
|
447
|
+
offset: 20,
|
|
448
|
+
color: theme.color.accentBoldYellow
|
|
449
|
+
}, {
|
|
450
|
+
offset: 40,
|
|
451
|
+
color: theme.color.accentBoldYellow
|
|
452
|
+
}, {
|
|
453
|
+
offset: 40,
|
|
454
|
+
color: theme.color.accentBoldRed
|
|
455
|
+
}, {
|
|
456
|
+
offset: 60,
|
|
457
|
+
color: theme.color.accentBoldRed
|
|
458
|
+
}] // Hard transitions at 20, 40
|
|
459
|
+
}
|
|
460
|
+
}],
|
|
461
|
+
xAxis: {
|
|
462
|
+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
|
463
|
+
},
|
|
464
|
+
yAxis: {
|
|
465
|
+
requestedTickCount: 5,
|
|
466
|
+
tickLabelFormatter: value => value + "\xB0C",
|
|
467
|
+
showGrid: true
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
};
|
|
471
|
+
const XAxisContinuousColorMap = () => {
|
|
472
|
+
const theme = useTheme();
|
|
473
|
+
return /*#__PURE__*/_jsx(BarChart, {
|
|
474
|
+
showXAxis: true,
|
|
475
|
+
showYAxis: true,
|
|
476
|
+
height: defaultChartHeight,
|
|
477
|
+
series: [{
|
|
478
|
+
id: 'weekly-trend',
|
|
479
|
+
data: [45, 52, 38, 45, 48, 50, 55],
|
|
480
|
+
// Gradient from left (start of week) to right (end of week)
|
|
481
|
+
gradient: {
|
|
482
|
+
axis: 'x',
|
|
483
|
+
stops: _ref4 => {
|
|
484
|
+
let {
|
|
485
|
+
min,
|
|
486
|
+
max
|
|
487
|
+
} = _ref4;
|
|
488
|
+
return [{
|
|
489
|
+
offset: min,
|
|
490
|
+
color: theme.color.accentBoldPurple
|
|
491
|
+
}, {
|
|
492
|
+
offset: max,
|
|
493
|
+
color: theme.color.accentBoldBlue
|
|
494
|
+
}];
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}],
|
|
498
|
+
xAxis: {
|
|
499
|
+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
|
500
|
+
},
|
|
501
|
+
yAxis: {
|
|
502
|
+
requestedTickCount: 5,
|
|
503
|
+
tickLabelFormatter: value => "" + value,
|
|
504
|
+
showGrid: true
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
};
|
|
508
|
+
const XAxisDiscreteColorMap = () => {
|
|
509
|
+
const theme = useTheme();
|
|
510
|
+
return /*#__PURE__*/_jsx(BarChart, {
|
|
511
|
+
showXAxis: true,
|
|
512
|
+
showYAxis: true,
|
|
513
|
+
height: defaultChartHeight,
|
|
514
|
+
series: [{
|
|
515
|
+
id: 'weekly-trend',
|
|
516
|
+
data: [45, 52, 38, 45, 48, 50, 55],
|
|
517
|
+
// Hard color transition from purple to blue at midweek
|
|
518
|
+
gradient: {
|
|
519
|
+
axis: 'x',
|
|
520
|
+
stops: [{
|
|
521
|
+
offset: 4,
|
|
522
|
+
color: theme.color.accentBoldPurple
|
|
523
|
+
},
|
|
524
|
+
// First half of week
|
|
525
|
+
{
|
|
526
|
+
offset: 4,
|
|
527
|
+
color: theme.color.accentBoldBlue
|
|
528
|
+
} // Second half of week - hard transition at index 4 (Thursday)
|
|
529
|
+
]
|
|
530
|
+
}
|
|
531
|
+
}],
|
|
532
|
+
xAxis: {
|
|
533
|
+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
|
534
|
+
},
|
|
535
|
+
yAxis: {
|
|
536
|
+
requestedTickCount: 5,
|
|
537
|
+
tickLabelFormatter: value => "" + value,
|
|
538
|
+
showGrid: true
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
};
|
|
542
|
+
const XAxisMultiSegmentColorMap = () => {
|
|
543
|
+
const theme = useTheme();
|
|
544
|
+
return /*#__PURE__*/_jsx(BarChart, {
|
|
545
|
+
showXAxis: true,
|
|
546
|
+
showYAxis: true,
|
|
547
|
+
height: defaultChartHeight,
|
|
548
|
+
series: [{
|
|
549
|
+
id: 'quarters',
|
|
550
|
+
data: [120, 135, 142, 128, 145, 158, 162, 155, 168, 175, 182, 190],
|
|
551
|
+
// Different color for each quarter
|
|
552
|
+
gradient: {
|
|
553
|
+
axis: 'x',
|
|
554
|
+
stops: [{
|
|
555
|
+
offset: 3,
|
|
556
|
+
color: theme.color.accentBoldBlue
|
|
557
|
+
},
|
|
558
|
+
// Q1 (Jan-Mar)
|
|
559
|
+
{
|
|
560
|
+
offset: 3,
|
|
561
|
+
color: theme.color.accentBoldGreen
|
|
562
|
+
},
|
|
563
|
+
// Q2 (Apr-Jun)
|
|
564
|
+
{
|
|
565
|
+
offset: 6,
|
|
566
|
+
color: theme.color.accentBoldGreen
|
|
567
|
+
}, {
|
|
568
|
+
offset: 6,
|
|
569
|
+
color: theme.color.accentBoldYellow
|
|
570
|
+
},
|
|
571
|
+
// Q3 (Jul-Sep)
|
|
572
|
+
{
|
|
573
|
+
offset: 9,
|
|
574
|
+
color: theme.color.accentBoldYellow
|
|
575
|
+
}, {
|
|
576
|
+
offset: 9,
|
|
577
|
+
color: theme.color.accentBoldPurple
|
|
578
|
+
} // Q4 (Oct-Dec)
|
|
579
|
+
] // Hard transitions at indices 3, 6, 9
|
|
580
|
+
}
|
|
581
|
+
}],
|
|
582
|
+
xAxis: {
|
|
583
|
+
data: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
|
584
|
+
},
|
|
585
|
+
yAxis: {
|
|
586
|
+
requestedTickCount: 5,
|
|
587
|
+
tickLabelFormatter: value => "$" + value + "k",
|
|
588
|
+
showGrid: true
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
};
|
|
592
|
+
const ColorMapWithOpacity = () => {
|
|
593
|
+
const theme = useTheme();
|
|
594
|
+
return /*#__PURE__*/_jsx(BarChart, {
|
|
595
|
+
showXAxis: true,
|
|
596
|
+
showYAxis: true,
|
|
597
|
+
height: defaultChartHeight,
|
|
598
|
+
series: [{
|
|
599
|
+
id: 'confidence',
|
|
600
|
+
data: [25, 35, 45, 55, 65, 75, 85],
|
|
601
|
+
// Gradient with opacity changes
|
|
602
|
+
gradient: {
|
|
603
|
+
axis: 'y',
|
|
604
|
+
stops: _ref5 => {
|
|
605
|
+
let {
|
|
606
|
+
min,
|
|
607
|
+
max
|
|
608
|
+
} = _ref5;
|
|
609
|
+
return [{
|
|
610
|
+
offset: min,
|
|
611
|
+
color: theme.color.accentBoldBlue,
|
|
612
|
+
opacity: 0
|
|
613
|
+
},
|
|
614
|
+
// Low values - more transparent
|
|
615
|
+
{
|
|
616
|
+
offset: max,
|
|
617
|
+
color: theme.color.accentBoldBlue,
|
|
618
|
+
opacity: 1.0
|
|
619
|
+
} // High values - more opaque
|
|
620
|
+
];
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}],
|
|
624
|
+
xAxis: {
|
|
625
|
+
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
|
626
|
+
},
|
|
627
|
+
yAxis: {
|
|
628
|
+
requestedTickCount: 5,
|
|
629
|
+
tickLabelFormatter: value => value + "%",
|
|
630
|
+
showGrid: true
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
};
|
|
634
|
+
const BandGridPositionExample = _ref6 => {
|
|
635
|
+
let {
|
|
636
|
+
position
|
|
637
|
+
} = _ref6;
|
|
638
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
639
|
+
height: 180,
|
|
640
|
+
inset: 4,
|
|
641
|
+
series: [{
|
|
642
|
+
id: 'data',
|
|
643
|
+
data: [30, 50, 40, 60, 35]
|
|
644
|
+
}],
|
|
645
|
+
xAxis: {
|
|
646
|
+
scaleType: 'band',
|
|
647
|
+
data: ['A', 'B', 'C', 'D', 'E']
|
|
648
|
+
},
|
|
649
|
+
yAxis: {
|
|
650
|
+
domain: {
|
|
651
|
+
min: 0
|
|
652
|
+
}
|
|
653
|
+
},
|
|
654
|
+
children: [/*#__PURE__*/_jsx(XAxis, {
|
|
655
|
+
showGrid: true,
|
|
656
|
+
showLine: true,
|
|
657
|
+
bandGridLinePlacement: position,
|
|
658
|
+
label: position
|
|
659
|
+
}), /*#__PURE__*/_jsx(BarPlot, {})]
|
|
660
|
+
});
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
// --- Composed Examples ---
|
|
664
|
+
|
|
665
|
+
const candlestickStockData = btcCandles.slice(0, 90).reverse();
|
|
666
|
+
const CandlesticksHeader = /*#__PURE__*/memo(_ref7 => {
|
|
667
|
+
let {
|
|
668
|
+
currentIndex
|
|
669
|
+
} = _ref7;
|
|
670
|
+
const formatPrice = useCallback(price => {
|
|
671
|
+
return new Intl.NumberFormat('en-US', {
|
|
672
|
+
style: 'currency',
|
|
673
|
+
currency: 'USD'
|
|
674
|
+
}).format(parseFloat(price));
|
|
675
|
+
}, []);
|
|
676
|
+
const formatThousandsPriceNumber = useCallback(price => {
|
|
677
|
+
const formattedPrice = new Intl.NumberFormat('en-US', {
|
|
678
|
+
style: 'currency',
|
|
679
|
+
currency: 'USD',
|
|
680
|
+
minimumFractionDigits: 0,
|
|
681
|
+
maximumFractionDigits: 0
|
|
682
|
+
}).format(price / 1000);
|
|
683
|
+
return formattedPrice + "k";
|
|
684
|
+
}, []);
|
|
685
|
+
const currentText = useMemo(() => {
|
|
686
|
+
if (currentIndex !== undefined) {
|
|
687
|
+
return "Open: " + formatThousandsPriceNumber(parseFloat(candlestickStockData[currentIndex].open)) + ", Close: " + formatThousandsPriceNumber(parseFloat(candlestickStockData[currentIndex].close)) + ", Volume: " + (parseFloat(candlestickStockData[currentIndex].volume) / 1000).toFixed(2) + "k";
|
|
688
|
+
}
|
|
689
|
+
return formatPrice(candlestickStockData[candlestickStockData.length - 1].close);
|
|
690
|
+
}, [currentIndex, formatThousandsPriceNumber, formatPrice]);
|
|
691
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
692
|
+
"aria-live": "polite",
|
|
693
|
+
font: "headline",
|
|
694
|
+
children: currentText
|
|
695
|
+
});
|
|
696
|
+
});
|
|
697
|
+
const CandlesticksChart = /*#__PURE__*/memo(_ref8 => {
|
|
698
|
+
let {
|
|
699
|
+
infoTextId,
|
|
700
|
+
onScrubberPositionChange
|
|
701
|
+
} = _ref8;
|
|
702
|
+
const theme = useTheme();
|
|
703
|
+
const min = useMemo(() => Math.min(...candlestickStockData.map(data => parseFloat(data.low))), []);
|
|
704
|
+
const CandleThinSolidLine = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(SolidLine, _extends({}, props, {
|
|
705
|
+
strokeWidth: 1
|
|
706
|
+
})));
|
|
707
|
+
const BandwidthHighlight = /*#__PURE__*/memo(_ref9 => {
|
|
708
|
+
let {
|
|
709
|
+
stroke
|
|
710
|
+
} = _ref9;
|
|
711
|
+
const {
|
|
712
|
+
getXSerializableScale,
|
|
713
|
+
drawingArea
|
|
714
|
+
} = useCartesianChartContext();
|
|
715
|
+
const {
|
|
716
|
+
scrubberPosition
|
|
717
|
+
} = useScrubberContext();
|
|
718
|
+
const xScale = useMemo(() => getXSerializableScale(), [getXSerializableScale]);
|
|
719
|
+
const rectWidth = useMemo(() => {
|
|
720
|
+
if (xScale !== undefined && xScale.type === 'band') {
|
|
721
|
+
return xScale.bandwidth;
|
|
722
|
+
}
|
|
723
|
+
return 0;
|
|
724
|
+
}, [xScale]);
|
|
725
|
+
const xPos = useDerivedValue(() => {
|
|
726
|
+
const position = unwrapAnimatedValue(scrubberPosition);
|
|
727
|
+
const xPos = position !== undefined && xScale ? getPointOnSerializableScale(position, xScale) : undefined;
|
|
728
|
+
return xPos !== undefined ? xPos - rectWidth / 2 : 0;
|
|
729
|
+
}, [scrubberPosition, xScale]);
|
|
730
|
+
const opacity = useDerivedValue(() => xPos.value !== undefined ? 1 : 0, [xPos]);
|
|
731
|
+
return /*#__PURE__*/_jsx(Rect, {
|
|
732
|
+
color: stroke,
|
|
733
|
+
height: drawingArea.height,
|
|
734
|
+
opacity: opacity,
|
|
735
|
+
width: rectWidth,
|
|
736
|
+
x: xPos,
|
|
737
|
+
y: drawingArea.y
|
|
738
|
+
});
|
|
739
|
+
});
|
|
740
|
+
const candlesData = useMemo(() => candlestickStockData.map(data => [parseFloat(data.low), parseFloat(data.high)]), []);
|
|
741
|
+
const CandlestickBarComponent = /*#__PURE__*/memo(_ref0 => {
|
|
742
|
+
var _yScale, _yScale2;
|
|
743
|
+
let {
|
|
744
|
+
x,
|
|
745
|
+
y,
|
|
746
|
+
width,
|
|
747
|
+
height,
|
|
748
|
+
dataX
|
|
749
|
+
} = _ref0,
|
|
750
|
+
props = _objectWithoutPropertiesLoose(_ref0, _excluded3);
|
|
751
|
+
const {
|
|
752
|
+
getYScale
|
|
753
|
+
} = useCartesianChartContext();
|
|
754
|
+
const yScale = getYScale();
|
|
755
|
+
const wickX = x + width / 2;
|
|
756
|
+
const timePeriodValue = candlestickStockData[dataX];
|
|
757
|
+
const open = parseFloat(timePeriodValue.open);
|
|
758
|
+
const close = parseFloat(timePeriodValue.close);
|
|
759
|
+
const bullish = open < close;
|
|
760
|
+
const theme = useTheme();
|
|
761
|
+
const color = bullish ? theme.color.fgPositive : theme.color.fgNegative;
|
|
762
|
+
const openY = (_yScale = yScale == null ? void 0 : yScale(open)) != null ? _yScale : 0;
|
|
763
|
+
const closeY = (_yScale2 = yScale == null ? void 0 : yScale(close)) != null ? _yScale2 : 0;
|
|
764
|
+
const bodyHeight = Math.abs(openY - closeY);
|
|
765
|
+
const bodyY = openY < closeY ? openY : closeY;
|
|
766
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
767
|
+
children: [/*#__PURE__*/_jsx(SkiaLine, {
|
|
768
|
+
color: color,
|
|
769
|
+
p1: {
|
|
770
|
+
x: wickX,
|
|
771
|
+
y
|
|
772
|
+
},
|
|
773
|
+
p2: {
|
|
774
|
+
x: wickX,
|
|
775
|
+
y: y + height
|
|
776
|
+
},
|
|
777
|
+
strokeWidth: 1
|
|
778
|
+
}), /*#__PURE__*/_jsx(Rect, {
|
|
779
|
+
color: color,
|
|
780
|
+
height: bodyHeight,
|
|
781
|
+
width: width,
|
|
782
|
+
x: x,
|
|
783
|
+
y: bodyY
|
|
784
|
+
})]
|
|
785
|
+
});
|
|
786
|
+
});
|
|
787
|
+
const formatThousandsPriceNumber = useCallback(price => {
|
|
788
|
+
const formattedPrice = new Intl.NumberFormat('en-US', {
|
|
789
|
+
style: 'currency',
|
|
790
|
+
currency: 'USD',
|
|
791
|
+
minimumFractionDigits: 0,
|
|
792
|
+
maximumFractionDigits: 0
|
|
793
|
+
}).format(price / 1000);
|
|
794
|
+
return formattedPrice + "k";
|
|
795
|
+
}, []);
|
|
796
|
+
const formatTime = useCallback(index => {
|
|
797
|
+
if (index === null || index === undefined || index >= candlestickStockData.length) return '';
|
|
798
|
+
const ts = parseInt(candlestickStockData[index].start);
|
|
799
|
+
return new Date(ts * 1000).toLocaleDateString('en-US', {
|
|
800
|
+
month: 'short',
|
|
801
|
+
day: 'numeric'
|
|
802
|
+
});
|
|
803
|
+
}, []);
|
|
804
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
805
|
+
enableScrubbing: true,
|
|
806
|
+
animate: false,
|
|
807
|
+
"aria-labelledby": infoTextId,
|
|
808
|
+
borderRadius: 0,
|
|
809
|
+
height: 150,
|
|
810
|
+
inset: {
|
|
811
|
+
top: 8,
|
|
812
|
+
bottom: 8,
|
|
813
|
+
left: 0,
|
|
814
|
+
right: 0
|
|
815
|
+
},
|
|
816
|
+
onScrubberPositionChange: onScrubberPositionChange,
|
|
817
|
+
series: [{
|
|
818
|
+
id: 'stock-prices',
|
|
819
|
+
data: candlesData
|
|
820
|
+
}],
|
|
821
|
+
xAxis: {
|
|
822
|
+
scaleType: 'band'
|
|
823
|
+
},
|
|
824
|
+
yAxis: {
|
|
825
|
+
domain: {
|
|
826
|
+
min
|
|
827
|
+
}
|
|
828
|
+
},
|
|
829
|
+
children: [/*#__PURE__*/_jsx(XAxis, {
|
|
830
|
+
tickLabelFormatter: formatTime
|
|
831
|
+
}), /*#__PURE__*/_jsx(YAxis, {
|
|
832
|
+
showGrid: true,
|
|
833
|
+
GridLineComponent: CandleThinSolidLine,
|
|
834
|
+
tickLabelFormatter: formatThousandsPriceNumber,
|
|
835
|
+
width: 40
|
|
836
|
+
}), /*#__PURE__*/_jsx(Scrubber, {
|
|
837
|
+
hideOverlay: true,
|
|
838
|
+
LineComponent: BandwidthHighlight,
|
|
839
|
+
lineStroke: theme.color.fgMuted,
|
|
840
|
+
seriesIds: []
|
|
841
|
+
}), /*#__PURE__*/_jsx(BarPlot, {
|
|
842
|
+
BarComponent: CandlestickBarComponent,
|
|
843
|
+
BarStackComponent: _ref1 => {
|
|
844
|
+
let {
|
|
845
|
+
children
|
|
846
|
+
} = _ref1;
|
|
847
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
848
|
+
children: children
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
})]
|
|
269
852
|
});
|
|
270
853
|
});
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
854
|
+
const Candlesticks = () => {
|
|
855
|
+
const infoTextId = useId();
|
|
856
|
+
const [currentIndex, setCurrentIndex] = useState();
|
|
857
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
858
|
+
gap: 2,
|
|
859
|
+
children: [/*#__PURE__*/_jsx(CandlesticksHeader, {
|
|
860
|
+
currentIndex: currentIndex
|
|
861
|
+
}), /*#__PURE__*/_jsx(CandlesticksChart, {
|
|
862
|
+
infoTextId: infoTextId,
|
|
863
|
+
onScrubberPositionChange: setCurrentIndex
|
|
279
864
|
})]
|
|
280
865
|
});
|
|
281
866
|
};
|
|
282
|
-
|
|
867
|
+
const DAY_LENGTH_MINUTES = 1440;
|
|
868
|
+
const sunlightData = [{
|
|
869
|
+
label: 'Jan',
|
|
870
|
+
value: 598
|
|
871
|
+
}, {
|
|
872
|
+
label: 'Feb',
|
|
873
|
+
value: 635
|
|
874
|
+
}, {
|
|
875
|
+
label: 'Mar',
|
|
876
|
+
value: 688
|
|
877
|
+
}, {
|
|
878
|
+
label: 'Apr',
|
|
879
|
+
value: 753
|
|
880
|
+
}, {
|
|
881
|
+
label: 'May',
|
|
882
|
+
value: 812
|
|
883
|
+
}, {
|
|
884
|
+
label: 'Jun',
|
|
885
|
+
value: 855
|
|
886
|
+
}, {
|
|
887
|
+
label: 'Jul',
|
|
888
|
+
value: 861
|
|
889
|
+
}, {
|
|
890
|
+
label: 'Aug',
|
|
891
|
+
value: 828
|
|
892
|
+
}, {
|
|
893
|
+
label: 'Sep',
|
|
894
|
+
value: 772
|
|
895
|
+
}, {
|
|
896
|
+
label: 'Oct',
|
|
897
|
+
value: 710
|
|
898
|
+
}, {
|
|
899
|
+
label: 'Nov',
|
|
900
|
+
value: 648
|
|
901
|
+
}, {
|
|
902
|
+
label: 'Dec',
|
|
903
|
+
value: 605
|
|
904
|
+
}];
|
|
905
|
+
const SunlightChartInner = /*#__PURE__*/memo(_ref10 => {
|
|
906
|
+
let {
|
|
907
|
+
data,
|
|
908
|
+
height = 300
|
|
909
|
+
} = _ref10,
|
|
910
|
+
props = _objectWithoutPropertiesLoose(_ref10, _excluded4);
|
|
911
|
+
const theme = useTheme();
|
|
912
|
+
const SunlightThinSolidLine = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(SolidLine, _extends({}, props, {
|
|
913
|
+
strokeWidth: 1
|
|
914
|
+
})));
|
|
915
|
+
return /*#__PURE__*/_jsxs(CartesianChart, _extends({}, props, {
|
|
916
|
+
height: height,
|
|
917
|
+
series: [{
|
|
918
|
+
id: 'sunlight',
|
|
919
|
+
data: data.map(_ref11 => {
|
|
920
|
+
let {
|
|
921
|
+
value
|
|
922
|
+
} = _ref11;
|
|
923
|
+
return value;
|
|
924
|
+
}),
|
|
925
|
+
yAxisId: 'sunlight',
|
|
926
|
+
color: "rgb(" + theme.spectrum.yellow40 + ")"
|
|
927
|
+
}, {
|
|
928
|
+
id: 'day',
|
|
929
|
+
data: data.map(() => DAY_LENGTH_MINUTES),
|
|
930
|
+
yAxisId: 'day',
|
|
931
|
+
color: "rgb(" + theme.spectrum.blue100 + ")"
|
|
932
|
+
}],
|
|
933
|
+
xAxis: _extends({}, props.xAxis, {
|
|
934
|
+
scaleType: 'band',
|
|
935
|
+
data: data.map(_ref12 => {
|
|
936
|
+
let {
|
|
937
|
+
label
|
|
938
|
+
} = _ref12;
|
|
939
|
+
return label;
|
|
940
|
+
})
|
|
941
|
+
}),
|
|
942
|
+
yAxis: [{
|
|
943
|
+
id: 'day',
|
|
944
|
+
domain: {
|
|
945
|
+
min: 0,
|
|
946
|
+
max: DAY_LENGTH_MINUTES
|
|
947
|
+
},
|
|
948
|
+
domainLimit: 'strict'
|
|
949
|
+
}, {
|
|
950
|
+
id: 'sunlight',
|
|
951
|
+
domain: {
|
|
952
|
+
min: 0,
|
|
953
|
+
max: DAY_LENGTH_MINUTES
|
|
954
|
+
},
|
|
955
|
+
domainLimit: 'strict'
|
|
956
|
+
}],
|
|
957
|
+
children: [/*#__PURE__*/_jsx(YAxis, {
|
|
958
|
+
showGrid: true,
|
|
959
|
+
showLine: true,
|
|
960
|
+
GridLineComponent: SunlightThinSolidLine,
|
|
961
|
+
axisId: "day",
|
|
962
|
+
position: "left"
|
|
963
|
+
}), /*#__PURE__*/_jsx(XAxis, {
|
|
964
|
+
showLine: true
|
|
965
|
+
}), /*#__PURE__*/_jsx(BarPlot, {
|
|
966
|
+
seriesIds: ['day'],
|
|
967
|
+
transitions: {
|
|
968
|
+
enter: null
|
|
969
|
+
}
|
|
970
|
+
}), /*#__PURE__*/_jsx(BarPlot, {
|
|
971
|
+
borderRadius: 0,
|
|
972
|
+
seriesIds: ['sunlight'],
|
|
973
|
+
transitions: {
|
|
974
|
+
enter: {
|
|
975
|
+
type: 'spring',
|
|
976
|
+
stiffness: 700,
|
|
977
|
+
damping: 40,
|
|
978
|
+
staggerDelay: 1
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
})]
|
|
982
|
+
}));
|
|
983
|
+
});
|
|
984
|
+
const SunlightChart = () => {
|
|
985
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
986
|
+
gap: 2,
|
|
987
|
+
children: [/*#__PURE__*/_jsx(SunlightChartInner, {
|
|
988
|
+
data: sunlightData
|
|
989
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
990
|
+
color: "fgMuted",
|
|
991
|
+
font: "caption",
|
|
992
|
+
textAlign: "center",
|
|
993
|
+
children: "2026 Sunlight data for the first day of each month in Atlanta, Georgia, provided by NOAA."
|
|
994
|
+
})]
|
|
995
|
+
});
|
|
996
|
+
};
|
|
997
|
+
const PriceRange = () => {
|
|
998
|
+
const candles = btcCandles.slice(0, 180).reverse();
|
|
999
|
+
const data = useMemo(() => candles.map(candle => [parseFloat(candle.low), parseFloat(candle.high)]), [candles]);
|
|
1000
|
+
const min = useMemo(() => Math.min(...data.map(_ref13 => {
|
|
1001
|
+
let [low] = _ref13;
|
|
1002
|
+
return low;
|
|
1003
|
+
})), [data]);
|
|
1004
|
+
const max = useMemo(() => Math.max(...data.map(_ref14 => {
|
|
1005
|
+
let [, high] = _ref14;
|
|
1006
|
+
return high;
|
|
1007
|
+
})), [data]);
|
|
1008
|
+
const tickFormatter = useCallback(value => new Intl.NumberFormat('en-US', {
|
|
1009
|
+
style: 'currency',
|
|
1010
|
+
currency: 'USD',
|
|
1011
|
+
notation: 'compact',
|
|
1012
|
+
maximumFractionDigits: 0
|
|
1013
|
+
}).format(value), []);
|
|
1014
|
+
return /*#__PURE__*/_jsx(BarChart, {
|
|
1015
|
+
showYAxis: true,
|
|
1016
|
+
height: 150,
|
|
1017
|
+
series: [{
|
|
1018
|
+
id: 'prices',
|
|
1019
|
+
data,
|
|
1020
|
+
color: assets.btc.color
|
|
1021
|
+
}],
|
|
1022
|
+
yAxis: {
|
|
1023
|
+
domain: {
|
|
1024
|
+
min,
|
|
1025
|
+
max
|
|
1026
|
+
},
|
|
1027
|
+
showGrid: true,
|
|
1028
|
+
tickLabelFormatter: tickFormatter
|
|
1029
|
+
}
|
|
1030
|
+
});
|
|
1031
|
+
};
|
|
1032
|
+
function ExampleNavigator() {
|
|
1033
|
+
const [currentIndex, setCurrentIndex] = useState(0);
|
|
1034
|
+
const examples = useMemo(() => [{
|
|
1035
|
+
title: 'Basic',
|
|
1036
|
+
component: /*#__PURE__*/_jsx(UpdatingChartValues, {})
|
|
1037
|
+
}, {
|
|
1038
|
+
title: 'Animated Auto-Updating',
|
|
1039
|
+
component: /*#__PURE__*/_jsx(AnimatedUpdatingChartValues, {})
|
|
1040
|
+
}, {
|
|
1041
|
+
title: 'Negative Values with Top Axis',
|
|
1042
|
+
component: /*#__PURE__*/_jsx(NegativeValuesWithTopAxis, {})
|
|
1043
|
+
}, {
|
|
1044
|
+
title: 'Positive and Negative Cash Flow',
|
|
1045
|
+
component: /*#__PURE__*/_jsx(PositiveAndNegativeCashFlow, {})
|
|
1046
|
+
}, {
|
|
1047
|
+
title: 'Fiat & Stablecoin Balance',
|
|
1048
|
+
component: /*#__PURE__*/_jsx(FiatAndStablecoinBalance, {})
|
|
1049
|
+
}, {
|
|
1050
|
+
title: 'Monthly Rewards',
|
|
1051
|
+
component: /*#__PURE__*/_jsx(MonthlyRewards, {})
|
|
1052
|
+
}, {
|
|
1053
|
+
title: 'Multiple Y Axes',
|
|
1054
|
+
component: /*#__PURE__*/_jsx(MultipleYAxes, {})
|
|
1055
|
+
}, {
|
|
1056
|
+
title: 'Y-Axis Continuous ColorMap',
|
|
1057
|
+
component: /*#__PURE__*/_jsx(YAxisContinuousColorMap, {})
|
|
1058
|
+
}, {
|
|
1059
|
+
title: 'Y-Axis Discrete ColorMap',
|
|
1060
|
+
component: /*#__PURE__*/_jsx(YAxisDiscreteColorMap, {})
|
|
1061
|
+
}, {
|
|
1062
|
+
title: 'X-Axis Continuous ColorMap',
|
|
1063
|
+
component: /*#__PURE__*/_jsx(XAxisContinuousColorMap, {})
|
|
1064
|
+
}, {
|
|
1065
|
+
title: 'X-Axis Discrete ColorMap',
|
|
1066
|
+
component: /*#__PURE__*/_jsx(XAxisDiscreteColorMap, {})
|
|
1067
|
+
}, {
|
|
1068
|
+
title: 'X-Axis Multi-Segment ColorMap',
|
|
1069
|
+
component: /*#__PURE__*/_jsx(XAxisMultiSegmentColorMap, {})
|
|
1070
|
+
}, {
|
|
1071
|
+
title: 'ColorMap with Opacity',
|
|
1072
|
+
component: /*#__PURE__*/_jsx(ColorMapWithOpacity, {})
|
|
1073
|
+
}, {
|
|
1074
|
+
title: 'Band Grid Position',
|
|
1075
|
+
component: /*#__PURE__*/_jsxs(VStack, {
|
|
1076
|
+
gap: 2,
|
|
1077
|
+
children: [/*#__PURE__*/_jsx(BandGridPositionExample, {
|
|
1078
|
+
position: "edges"
|
|
1079
|
+
}), /*#__PURE__*/_jsx(BandGridPositionExample, {
|
|
1080
|
+
position: "start"
|
|
1081
|
+
}), /*#__PURE__*/_jsx(BandGridPositionExample, {
|
|
1082
|
+
position: "middle"
|
|
1083
|
+
}), /*#__PURE__*/_jsx(BandGridPositionExample, {
|
|
1084
|
+
position: "end"
|
|
1085
|
+
})]
|
|
1086
|
+
})
|
|
1087
|
+
}, {
|
|
1088
|
+
title: 'Candlesticks',
|
|
1089
|
+
component: /*#__PURE__*/_jsx(Candlesticks, {})
|
|
1090
|
+
}, {
|
|
1091
|
+
title: 'Monthly Sunlight',
|
|
1092
|
+
component: /*#__PURE__*/_jsx(SunlightChart, {})
|
|
1093
|
+
}, {
|
|
1094
|
+
title: 'Price Range',
|
|
1095
|
+
component: /*#__PURE__*/_jsx(PriceRange, {})
|
|
1096
|
+
}], []);
|
|
1097
|
+
const currentExample = examples[currentIndex];
|
|
1098
|
+
const handlePrevious = useCallback(() => {
|
|
1099
|
+
setCurrentIndex(prev => (prev - 1 + examples.length) % examples.length);
|
|
1100
|
+
}, [examples.length]);
|
|
1101
|
+
const handleNext = useCallback(() => {
|
|
1102
|
+
setCurrentIndex(prev => (prev + 1 + examples.length) % examples.length);
|
|
1103
|
+
}, [examples.length]);
|
|
1104
|
+
return /*#__PURE__*/_jsx(ExampleScreen, {
|
|
1105
|
+
paddingX: 0,
|
|
1106
|
+
children: /*#__PURE__*/_jsxs(VStack, {
|
|
1107
|
+
gap: 4,
|
|
1108
|
+
children: [/*#__PURE__*/_jsxs(HStack, {
|
|
1109
|
+
alignItems: "center",
|
|
1110
|
+
justifyContent: "space-between",
|
|
1111
|
+
padding: 2,
|
|
1112
|
+
children: [/*#__PURE__*/_jsx(IconButton, {
|
|
1113
|
+
accessibilityHint: "Navigate to previous example",
|
|
1114
|
+
accessibilityLabel: "Previous",
|
|
1115
|
+
name: "arrowLeft",
|
|
1116
|
+
onPress: handlePrevious,
|
|
1117
|
+
variant: "secondary"
|
|
1118
|
+
}), /*#__PURE__*/_jsxs(VStack, {
|
|
1119
|
+
alignItems: "center",
|
|
1120
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
1121
|
+
font: "title3",
|
|
1122
|
+
children: currentExample.title
|
|
1123
|
+
}), /*#__PURE__*/_jsxs(Text, {
|
|
1124
|
+
color: "fgMuted",
|
|
1125
|
+
font: "label1",
|
|
1126
|
+
children: [currentIndex + 1, " / ", examples.length]
|
|
1127
|
+
})]
|
|
1128
|
+
}), /*#__PURE__*/_jsx(IconButton, {
|
|
1129
|
+
accessibilityHint: "Navigate to next example",
|
|
1130
|
+
accessibilityLabel: "Next",
|
|
1131
|
+
name: "arrowRight",
|
|
1132
|
+
onPress: handleNext,
|
|
1133
|
+
variant: "secondary"
|
|
1134
|
+
})]
|
|
1135
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
1136
|
+
padding: 1,
|
|
1137
|
+
children: currentExample.component
|
|
1138
|
+
})]
|
|
1139
|
+
})
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
export default ExampleNavigator;
|