@coinbase/cds-mobile-visualization 3.8.1 → 4.0.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 +8 -0
- package/dts/chart/index.d.ts +1 -15
- package/dts/chart/index.d.ts.map +1 -1
- package/dts/index.d.ts.map +1 -1
- package/dts/sparkline/index.d.ts +1 -5
- package/dts/sparkline/index.d.ts.map +1 -1
- package/esm/chart/index.js +1 -17
- package/esm/index.js +1 -3
- package/esm/sparkline/index.js +1 -5
- package/package.json +26 -20
- package/dts/chart/CartesianChart.d.ts +0 -206
- package/dts/chart/CartesianChart.d.ts.map +0 -1
- package/dts/chart/ChartContextBridge.d.ts +0 -28
- package/dts/chart/ChartContextBridge.d.ts.map +0 -1
- package/dts/chart/ChartProvider.d.ts +0 -9
- package/dts/chart/ChartProvider.d.ts.map +0 -1
- package/dts/chart/Path.d.ts +0 -121
- package/dts/chart/Path.d.ts.map +0 -1
- package/dts/chart/PeriodSelector.d.ts +0 -100
- package/dts/chart/PeriodSelector.d.ts.map +0 -1
- package/dts/chart/area/Area.d.ts +0 -83
- package/dts/chart/area/Area.d.ts.map +0 -1
- package/dts/chart/area/AreaChart.d.ts +0 -155
- package/dts/chart/area/AreaChart.d.ts.map +0 -1
- package/dts/chart/area/DottedArea.d.ts +0 -46
- package/dts/chart/area/DottedArea.d.ts.map +0 -1
- package/dts/chart/area/GradientArea.d.ts +0 -36
- package/dts/chart/area/GradientArea.d.ts.map +0 -1
- package/dts/chart/area/SolidArea.d.ts +0 -23
- package/dts/chart/area/SolidArea.d.ts.map +0 -1
- package/dts/chart/area/index.d.ts +0 -6
- package/dts/chart/area/index.d.ts.map +0 -1
- package/dts/chart/axis/Axis.d.ts +0 -174
- package/dts/chart/axis/Axis.d.ts.map +0 -1
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts +0 -8
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +0 -1
- package/dts/chart/axis/XAxis.d.ts +0 -22
- package/dts/chart/axis/XAxis.d.ts.map +0 -1
- package/dts/chart/axis/YAxis.d.ts +0 -22
- package/dts/chart/axis/YAxis.d.ts.map +0 -1
- package/dts/chart/axis/index.d.ts +0 -5
- package/dts/chart/axis/index.d.ts.map +0 -1
- package/dts/chart/bar/Bar.d.ts +0 -100
- package/dts/chart/bar/Bar.d.ts.map +0 -1
- package/dts/chart/bar/BarChart.d.ts +0 -158
- package/dts/chart/bar/BarChart.d.ts.map +0 -1
- package/dts/chart/bar/BarPlot.d.ts +0 -31
- package/dts/chart/bar/BarPlot.d.ts.map +0 -1
- package/dts/chart/bar/BarStack.d.ts +0 -127
- package/dts/chart/bar/BarStack.d.ts.map +0 -1
- package/dts/chart/bar/BarStackGroup.d.ts +0 -37
- package/dts/chart/bar/BarStackGroup.d.ts.map +0 -1
- package/dts/chart/bar/DefaultBar.d.ts +0 -7
- package/dts/chart/bar/DefaultBar.d.ts.map +0 -1
- package/dts/chart/bar/DefaultBarStack.d.ts +0 -7
- package/dts/chart/bar/DefaultBarStack.d.ts.map +0 -1
- package/dts/chart/bar/PercentageBarChart.d.ts +0 -106
- package/dts/chart/bar/PercentageBarChart.d.ts.map +0 -1
- package/dts/chart/bar/index.d.ts +0 -9
- package/dts/chart/bar/index.d.ts.map +0 -1
- package/dts/chart/gradient/Gradient.d.ts +0 -41
- package/dts/chart/gradient/Gradient.d.ts.map +0 -1
- package/dts/chart/gradient/index.d.ts +0 -2
- package/dts/chart/gradient/index.d.ts.map +0 -1
- package/dts/chart/legend/DefaultLegendEntry.d.ts +0 -5
- package/dts/chart/legend/DefaultLegendEntry.d.ts.map +0 -1
- package/dts/chart/legend/DefaultLegendShape.d.ts +0 -5
- package/dts/chart/legend/DefaultLegendShape.d.ts.map +0 -1
- package/dts/chart/legend/Legend.d.ts +0 -168
- package/dts/chart/legend/Legend.d.ts.map +0 -1
- package/dts/chart/legend/index.d.ts +0 -4
- package/dts/chart/legend/index.d.ts.map +0 -1
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts +0 -9
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +0 -1
- package/dts/chart/line/DottedLine.d.ts +0 -20
- package/dts/chart/line/DottedLine.d.ts.map +0 -1
- package/dts/chart/line/Line.d.ts +0 -122
- package/dts/chart/line/Line.d.ts.map +0 -1
- package/dts/chart/line/LineChart.d.ts +0 -135
- package/dts/chart/line/LineChart.d.ts.map +0 -1
- package/dts/chart/line/ReferenceLine.d.ts +0 -140
- package/dts/chart/line/ReferenceLine.d.ts.map +0 -1
- package/dts/chart/line/SolidLine.d.ts +0 -15
- package/dts/chart/line/SolidLine.d.ts.map +0 -1
- package/dts/chart/line/index.d.ts +0 -7
- package/dts/chart/line/index.d.ts.map +0 -1
- package/dts/chart/point/DefaultPointLabel.d.ts +0 -10
- package/dts/chart/point/DefaultPointLabel.d.ts.map +0 -1
- package/dts/chart/point/Point.d.ts +0 -144
- package/dts/chart/point/Point.d.ts.map +0 -1
- package/dts/chart/point/index.d.ts +0 -3
- package/dts/chart/point/index.d.ts.map +0 -1
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +0 -38
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +0 -1
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +0 -12
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +0 -1
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +0 -12
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +0 -1
- package/dts/chart/scrubber/Scrubber.d.ts +0 -302
- package/dts/chart/scrubber/Scrubber.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts +0 -12
- package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +0 -54
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +0 -46
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberProvider.d.ts +0 -20
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +0 -1
- package/dts/chart/scrubber/index.d.ts +0 -5
- package/dts/chart/scrubber/index.d.ts.map +0 -1
- package/dts/chart/text/ChartText.d.ts +0 -164
- package/dts/chart/text/ChartText.d.ts.map +0 -1
- package/dts/chart/text/ChartTextGroup.d.ts +0 -61
- package/dts/chart/text/ChartTextGroup.d.ts.map +0 -1
- package/dts/chart/text/index.d.ts +0 -3
- package/dts/chart/text/index.d.ts.map +0 -1
- package/dts/chart/utils/axis.d.ts +0 -387
- package/dts/chart/utils/axis.d.ts.map +0 -1
- package/dts/chart/utils/bar.d.ts +0 -225
- package/dts/chart/utils/bar.d.ts.map +0 -1
- package/dts/chart/utils/chart.d.ts +0 -165
- package/dts/chart/utils/chart.d.ts.map +0 -1
- package/dts/chart/utils/context.d.ts +0 -131
- package/dts/chart/utils/context.d.ts.map +0 -1
- package/dts/chart/utils/gradient.d.ts +0 -129
- package/dts/chart/utils/gradient.d.ts.map +0 -1
- package/dts/chart/utils/index.d.ts +0 -11
- package/dts/chart/utils/index.d.ts.map +0 -1
- package/dts/chart/utils/path.d.ts +0 -186
- package/dts/chart/utils/path.d.ts.map +0 -1
- package/dts/chart/utils/point.d.ts +0 -146
- package/dts/chart/utils/point.d.ts.map +0 -1
- package/dts/chart/utils/scale.d.ts +0 -145
- package/dts/chart/utils/scale.d.ts.map +0 -1
- package/dts/chart/utils/scrubber.d.ts +0 -40
- package/dts/chart/utils/scrubber.d.ts.map +0 -1
- package/dts/chart/utils/transition.d.ts +0 -181
- package/dts/chart/utils/transition.d.ts.map +0 -1
- package/dts/sparkline/Counter.d.ts +0 -8
- package/dts/sparkline/Counter.d.ts.map +0 -1
- package/dts/sparkline/Sparkline.d.ts +0 -74
- package/dts/sparkline/Sparkline.d.ts.map +0 -1
- package/dts/sparkline/SparklineArea.d.ts +0 -15
- package/dts/sparkline/SparklineArea.d.ts.map +0 -1
- package/dts/sparkline/SparklineAreaPattern.d.ts +0 -14
- package/dts/sparkline/SparklineAreaPattern.d.ts.map +0 -1
- package/dts/sparkline/SparklineGradient.d.ts +0 -24
- package/dts/sparkline/SparklineGradient.d.ts.map +0 -1
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts +0 -2
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts.map +0 -1
- package/dts/sparkline/generateSparklineWithId.d.ts +0 -11
- package/dts/sparkline/generateSparklineWithId.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts +0 -23
- package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +0 -185
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +0 -25
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +0 -28
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +0 -13
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +0 -17
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts +0 -11
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts +0 -26
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +0 -25
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +0 -25
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +0 -39
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +0 -31
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts +0 -13
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts +0 -16
- package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts +0 -6
- package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +0 -22
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts +0 -34
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +0 -118
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts +0 -29
- package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts.map +0 -1
- package/esm/chart/CartesianChart.js +0 -431
- package/esm/chart/ChartContextBridge.js +0 -159
- package/esm/chart/ChartProvider.js +0 -10
- package/esm/chart/Path.js +0 -255
- package/esm/chart/PeriodSelector.js +0 -139
- package/esm/chart/__stories__/CartesianChart.stories.js +0 -659
- package/esm/chart/__stories__/ChartAccessibility.stories.js +0 -721
- package/esm/chart/__stories__/ChartTransitions.stories.js +0 -693
- package/esm/chart/__stories__/PeriodSelector.stories.js +0 -420
- package/esm/chart/area/Area.js +0 -85
- package/esm/chart/area/AreaChart.js +0 -152
- package/esm/chart/area/DottedArea.js +0 -92
- package/esm/chart/area/GradientArea.js +0 -63
- package/esm/chart/area/SolidArea.js +0 -45
- package/esm/chart/area/__stories__/AreaChart.stories.js +0 -370
- package/esm/chart/area/index.js +0 -7
- package/esm/chart/axis/Axis.js +0 -9
- package/esm/chart/axis/DefaultAxisTickLabel.js +0 -11
- package/esm/chart/axis/XAxis.js +0 -256
- package/esm/chart/axis/YAxis.js +0 -255
- package/esm/chart/axis/__stories__/Axis.stories.js +0 -552
- package/esm/chart/axis/index.js +0 -6
- package/esm/chart/bar/Bar.js +0 -71
- package/esm/chart/bar/BarChart.js +0 -122
- package/esm/chart/bar/BarPlot.js +0 -106
- package/esm/chart/bar/BarStack.js +0 -173
- package/esm/chart/bar/BarStackGroup.js +0 -89
- package/esm/chart/bar/DefaultBar.js +0 -79
- package/esm/chart/bar/DefaultBarStack.js +0 -68
- package/esm/chart/bar/PercentageBarChart.js +0 -99
- package/esm/chart/bar/__stories__/BarChart.stories.js +0 -1417
- package/esm/chart/bar/__stories__/PercentageBarChart.stories.js +0 -833
- package/esm/chart/bar/index.js +0 -10
- package/esm/chart/gradient/Gradient.js +0 -156
- package/esm/chart/gradient/index.js +0 -1
- package/esm/chart/legend/DefaultLegendEntry.js +0 -42
- package/esm/chart/legend/DefaultLegendShape.js +0 -64
- package/esm/chart/legend/Legend.js +0 -59
- package/esm/chart/legend/__stories__/Legend.stories.js +0 -574
- package/esm/chart/legend/index.js +0 -3
- package/esm/chart/line/DefaultReferenceLineLabel.js +0 -66
- package/esm/chart/line/DottedLine.js +0 -57
- package/esm/chart/line/Line.js +0 -180
- package/esm/chart/line/LineChart.js +0 -149
- package/esm/chart/line/ReferenceLine.js +0 -132
- package/esm/chart/line/SolidLine.js +0 -53
- package/esm/chart/line/__stories__/LineChart.stories.js +0 -2018
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +0 -226
- package/esm/chart/line/index.js +0 -8
- package/esm/chart/point/DefaultPointLabel.js +0 -39
- package/esm/chart/point/Point.js +0 -187
- package/esm/chart/point/index.js +0 -2
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +0 -182
- package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +0 -43
- package/esm/chart/scrubber/DefaultScrubberLabel.js +0 -44
- package/esm/chart/scrubber/Scrubber.js +0 -198
- package/esm/chart/scrubber/ScrubberAccessibilityView.js +0 -177
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +0 -169
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +0 -212
- package/esm/chart/scrubber/ScrubberProvider.js +0 -140
- package/esm/chart/scrubber/__stories__/Scrubber.stories.js +0 -946
- package/esm/chart/scrubber/index.js +0 -4
- package/esm/chart/text/ChartText.js +0 -305
- package/esm/chart/text/ChartTextGroup.js +0 -211
- package/esm/chart/text/index.js +0 -4
- package/esm/chart/utils/axis.js +0 -664
- package/esm/chart/utils/bar.js +0 -906
- package/esm/chart/utils/chart.js +0 -329
- package/esm/chart/utils/context.js +0 -22
- package/esm/chart/utils/gradient.js +0 -319
- package/esm/chart/utils/index.js +0 -12
- package/esm/chart/utils/path.js +0 -304
- package/esm/chart/utils/point.js +0 -282
- package/esm/chart/utils/scale.js +0 -288
- package/esm/chart/utils/scrubber.js +0 -146
- package/esm/chart/utils/transition.js +0 -241
- package/esm/sparkline/Counter.js +0 -45
- package/esm/sparkline/Sparkline.js +0 -165
- package/esm/sparkline/SparklineArea.js +0 -20
- package/esm/sparkline/SparklineAreaPattern.js +0 -38
- package/esm/sparkline/SparklineGradient.js +0 -77
- package/esm/sparkline/__figma__/Sparkline.figma.js +0 -22
- package/esm/sparkline/__stories__/Sparkline.stories.js +0 -124
- package/esm/sparkline/__stories__/SparklineGradient.stories.js +0 -126
- package/esm/sparkline/generateSparklineWithId.js +0 -7
- package/esm/sparkline/sparkline-interactive/SparklineAccessibleView.js +0 -75
- package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +0 -308
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +0 -116
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.js +0 -131
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.js +0 -99
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +0 -82
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMinMax.js +0 -103
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.js +0 -104
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +0 -57
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.js +0 -124
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveProvider.js +0 -80
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.js +0 -109
- package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +0 -85
- package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +0 -526
- package/esm/sparkline/sparkline-interactive/useInterruptiblePathAnimation.js +0 -58
- package/esm/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.js +0 -37
- package/esm/sparkline/sparkline-interactive/useMinMaxTransform.js +0 -56
- package/esm/sparkline/sparkline-interactive/useOpacityAnimation.js +0 -23
- package/esm/sparkline/sparkline-interactive/useSparklineInteractiveConstants.js +0 -47
- package/esm/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.js +0 -34
- package/esm/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.js +0 -233
- package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +0 -104
- package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +0 -565
- package/esm/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.js +0 -117
|
@@ -1,2018 +0,0 @@
|
|
|
1
|
-
const _excluded = ["dataX", "dataY"],
|
|
2
|
-
_excluded2 = ["label"],
|
|
3
|
-
_excluded3 = ["style"];
|
|
4
|
-
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
|
-
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; }
|
|
6
|
-
import { forwardRef, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
|
-
import { useAnimatedReaction, useDerivedValue, useSharedValue, withDelay, withTiming } from 'react-native-reanimated';
|
|
8
|
-
import { assets, ethBackground } from '@coinbase/cds-common/internal/data/assets';
|
|
9
|
-
import { prices } from '@coinbase/cds-common/internal/data/prices';
|
|
10
|
-
import { sparklineInteractiveData } from '@coinbase/cds-common/internal/visualizations/SparklineInteractiveData';
|
|
11
|
-
import { useTabsContext } from '@coinbase/cds-common/tabs/TabsContext';
|
|
12
|
-
import { NoopFn } from '@coinbase/cds-common/utils/mockUtils';
|
|
13
|
-
import { useTheme } from '@coinbase/cds-mobile';
|
|
14
|
-
import { DataCard } from '@coinbase/cds-mobile/alpha/data-card/DataCard';
|
|
15
|
-
import { IconButton } from '@coinbase/cds-mobile/buttons';
|
|
16
|
-
import { ListCell } from '@coinbase/cds-mobile/cells';
|
|
17
|
-
import { ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
|
|
18
|
-
import { Box, HStack, VStack } from '@coinbase/cds-mobile/layout';
|
|
19
|
-
import { Avatar, RemoteImage } from '@coinbase/cds-mobile/media';
|
|
20
|
-
import { SectionHeader } from '@coinbase/cds-mobile/section-header/SectionHeader';
|
|
21
|
-
import { Pressable } from '@coinbase/cds-mobile/system';
|
|
22
|
-
import { SegmentedTab } from '@coinbase/cds-mobile/tabs/SegmentedTab';
|
|
23
|
-
import { Text } from '@coinbase/cds-mobile/typography';
|
|
24
|
-
import { Circle, FontWeight, Group, Skia, TextAlign } from '@shopify/react-native-skia';
|
|
25
|
-
import { Area, DottedArea } from '../../area';
|
|
26
|
-
import { DefaultAxisTickLabel, XAxis, YAxis } from '../../axis';
|
|
27
|
-
import { CartesianChart } from '../../CartesianChart';
|
|
28
|
-
import { useCartesianChartContext } from '../../ChartProvider';
|
|
29
|
-
import { PeriodSelector, PeriodSelectorActiveIndicator } from '../../PeriodSelector';
|
|
30
|
-
import { Point } from '../../point';
|
|
31
|
-
import { DefaultScrubberBeacon, Scrubber } from '../../scrubber';
|
|
32
|
-
import { buildTransition, defaultTransition, projectPointWithSerializableScale, unwrapAnimatedValue, useScrubberContext } from '../../utils';
|
|
33
|
-
import { DottedLine, Line, LineChart, ReferenceLine, SolidLine } from '..';
|
|
34
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
35
|
-
function MultipleLine() {
|
|
36
|
-
const theme = useTheme();
|
|
37
|
-
const pages = useMemo(() => ['Page A', 'Page B', 'Page C', 'Page D', 'Page E', 'Page F', 'Page G'], []);
|
|
38
|
-
const pageViews = useMemo(() => [2400, 1398, 9800, 3908, 4800, 3800, 4300], []);
|
|
39
|
-
const uniqueVisitors = useMemo(() => [4000, 3000, 2000, 2780, 1890, 2390, 3490], []);
|
|
40
|
-
const chartAccessibilityLabel = "Website visitors across " + pageViews.length + " pages.";
|
|
41
|
-
const chartAccessibilityHint = 'Swipe left or right to hear details for each page.';
|
|
42
|
-
const getScrubberAccessibilityLabel = useCallback(index => pages[index] + " has " + pageViews[index] + " views and " + uniqueVisitors[index] + " unique visitors.", [pages, pageViews, uniqueVisitors]);
|
|
43
|
-
const numberFormatter = useCallback(value => new Intl.NumberFormat('en-US', {
|
|
44
|
-
maximumFractionDigits: 0
|
|
45
|
-
}).format(value), []);
|
|
46
|
-
return /*#__PURE__*/_jsx(LineChart, {
|
|
47
|
-
enableScrubbing: true,
|
|
48
|
-
showArea: true,
|
|
49
|
-
showXAxis: true,
|
|
50
|
-
showYAxis: true,
|
|
51
|
-
accessibilityHint: chartAccessibilityHint,
|
|
52
|
-
accessibilityLabel: chartAccessibilityLabel + " " + chartAccessibilityHint,
|
|
53
|
-
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
54
|
-
height: 200,
|
|
55
|
-
series: [{
|
|
56
|
-
id: 'pageViews',
|
|
57
|
-
data: pageViews,
|
|
58
|
-
color: theme.color.accentBoldGreen,
|
|
59
|
-
// Label will render next to scrubber beacon
|
|
60
|
-
label: 'Page Views'
|
|
61
|
-
}, {
|
|
62
|
-
id: 'uniqueVisitors',
|
|
63
|
-
data: uniqueVisitors,
|
|
64
|
-
color: theme.color.accentBoldPurple,
|
|
65
|
-
label: 'Unique Visitors',
|
|
66
|
-
// Default area is gradient
|
|
67
|
-
areaType: 'dotted'
|
|
68
|
-
}],
|
|
69
|
-
xAxis: {
|
|
70
|
-
// Used on the x-axis to provide context for each index from the series data array
|
|
71
|
-
data: pages
|
|
72
|
-
},
|
|
73
|
-
yAxis: {
|
|
74
|
-
showGrid: true,
|
|
75
|
-
tickLabelFormatter: numberFormatter
|
|
76
|
-
},
|
|
77
|
-
children: /*#__PURE__*/_jsx(Scrubber, {})
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
function DataFormat() {
|
|
81
|
-
const yData = useMemo(() => [2, 5.5, 2, 8.5, 1.5, 5], []);
|
|
82
|
-
const xData = useMemo(() => [1, 2, 3, 5, 8, 10], []);
|
|
83
|
-
const chartAccessibilityLabel = "Chart with custom X and Y data. " + yData.length + " data points";
|
|
84
|
-
const getScrubberAccessibilityLabel = useCallback(index => "Point " + (index + 1) + ": X value " + xData[index] + ", Y value " + yData[index], [xData, yData]);
|
|
85
|
-
return /*#__PURE__*/_jsx(LineChart, {
|
|
86
|
-
enableScrubbing: true,
|
|
87
|
-
points: true,
|
|
88
|
-
showArea: true,
|
|
89
|
-
showXAxis: true,
|
|
90
|
-
showYAxis: true,
|
|
91
|
-
accessibilityLabel: chartAccessibilityLabel,
|
|
92
|
-
curve: "natural",
|
|
93
|
-
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
94
|
-
height: 200,
|
|
95
|
-
inset: {
|
|
96
|
-
top: 16,
|
|
97
|
-
right: 16,
|
|
98
|
-
bottom: 0,
|
|
99
|
-
left: 0
|
|
100
|
-
},
|
|
101
|
-
series: [{
|
|
102
|
-
id: 'line',
|
|
103
|
-
data: yData
|
|
104
|
-
}],
|
|
105
|
-
xAxis: {
|
|
106
|
-
data: xData,
|
|
107
|
-
showLine: true,
|
|
108
|
-
showTickMarks: true,
|
|
109
|
-
showGrid: true
|
|
110
|
-
},
|
|
111
|
-
yAxis: {
|
|
112
|
-
domain: {
|
|
113
|
-
min: 0
|
|
114
|
-
},
|
|
115
|
-
position: 'left',
|
|
116
|
-
showLine: true,
|
|
117
|
-
showTickMarks: true,
|
|
118
|
-
showGrid: true
|
|
119
|
-
},
|
|
120
|
-
children: /*#__PURE__*/_jsx(Scrubber, {
|
|
121
|
-
hideOverlay: true
|
|
122
|
-
})
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
function LiveUpdates() {
|
|
126
|
-
const scrubberRef = useRef(null);
|
|
127
|
-
const initialData = useMemo(() => {
|
|
128
|
-
return sparklineInteractiveData.hour.map(d => d.value);
|
|
129
|
-
}, []);
|
|
130
|
-
const [priceData, setPriceData] = useState(initialData);
|
|
131
|
-
const chartAccessibilityLabel = "Live price chart with " + priceData.length + " data points.";
|
|
132
|
-
const getScrubberAccessibilityLabel = useCallback(index => "Point " + (index + 1) + ": " + priceData[index], [priceData]);
|
|
133
|
-
const lastDataPointTimeRef = useRef(Date.now());
|
|
134
|
-
const updateCountRef = useRef(0);
|
|
135
|
-
const intervalSeconds = 3600 / initialData.length;
|
|
136
|
-
const maxPercentChange = Math.abs(initialData[initialData.length - 1] - initialData[0]) * 0.05;
|
|
137
|
-
useEffect(() => {
|
|
138
|
-
const priceUpdateInterval = setInterval(() => {
|
|
139
|
-
var _scrubberRef$current;
|
|
140
|
-
setPriceData(currentData => {
|
|
141
|
-
const newData = [...currentData];
|
|
142
|
-
const lastPrice = newData[newData.length - 1];
|
|
143
|
-
const priceChange = (Math.random() - 0.5) * maxPercentChange;
|
|
144
|
-
const newPrice = Math.round((lastPrice + priceChange) * 100) / 100;
|
|
145
|
-
|
|
146
|
-
// Check if we should roll over to a new data point
|
|
147
|
-
const currentTime = Date.now();
|
|
148
|
-
const timeSinceLastPoint = (currentTime - lastDataPointTimeRef.current) / 1000;
|
|
149
|
-
if (timeSinceLastPoint >= intervalSeconds) {
|
|
150
|
-
// Time for a new data point - remove first, add new at end
|
|
151
|
-
lastDataPointTimeRef.current = currentTime;
|
|
152
|
-
newData.shift(); // Remove oldest data point
|
|
153
|
-
newData.push(newPrice); // Add new data point
|
|
154
|
-
updateCountRef.current = 0;
|
|
155
|
-
} else {
|
|
156
|
-
// Just update the last data point
|
|
157
|
-
newData[newData.length - 1] = newPrice;
|
|
158
|
-
updateCountRef.current++;
|
|
159
|
-
}
|
|
160
|
-
return newData;
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
// Pulse the scrubber on each update
|
|
164
|
-
(_scrubberRef$current = scrubberRef.current) == null || _scrubberRef$current.pulse();
|
|
165
|
-
}, 2000 + Math.random() * 1000);
|
|
166
|
-
return () => clearInterval(priceUpdateInterval);
|
|
167
|
-
}, [intervalSeconds, maxPercentChange]);
|
|
168
|
-
return /*#__PURE__*/_jsx(LineChart, {
|
|
169
|
-
enableScrubbing: true,
|
|
170
|
-
showArea: true,
|
|
171
|
-
accessibilityLabel: chartAccessibilityLabel,
|
|
172
|
-
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
173
|
-
height: 200,
|
|
174
|
-
inset: {
|
|
175
|
-
right: 64
|
|
176
|
-
},
|
|
177
|
-
series: [{
|
|
178
|
-
id: 'btc',
|
|
179
|
-
data: priceData,
|
|
180
|
-
color: assets.btc.color
|
|
181
|
-
}],
|
|
182
|
-
children: /*#__PURE__*/_jsx(Scrubber, {
|
|
183
|
-
ref: scrubberRef
|
|
184
|
-
})
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
function MissingData() {
|
|
188
|
-
const theme = useTheme();
|
|
189
|
-
const pages = useMemo(() => ['Page A', 'Page B', 'Page C', 'Page D', 'Page E', 'Page F', 'Page G'], []);
|
|
190
|
-
const pageViews = useMemo(() => [2400, 1398, null, 3908, 4800, 3800, 4300], []);
|
|
191
|
-
const uniqueVisitors = useMemo(() => [4000, 3000, null, 2780, 1890, 2390, 3490], []);
|
|
192
|
-
const chartAccessibilityLabel = "Website visitors across " + pages.length + " pages. Some data points are missing.";
|
|
193
|
-
const getScrubberAccessibilityLabel = useCallback(index => {
|
|
194
|
-
const pv = pageViews[index];
|
|
195
|
-
const uv = uniqueVisitors[index];
|
|
196
|
-
const pvStr = pv != null ? pv : 'no data';
|
|
197
|
-
const uvStr = uv != null ? uv : 'no data';
|
|
198
|
-
return pages[index] + ": " + pvStr + " views, " + uvStr + " unique visitors.";
|
|
199
|
-
}, [pages, pageViews, uniqueVisitors]);
|
|
200
|
-
const numberFormatter = useCallback(value => new Intl.NumberFormat('en-US', {
|
|
201
|
-
maximumFractionDigits: 0
|
|
202
|
-
}).format(value), []);
|
|
203
|
-
return /*#__PURE__*/_jsx(LineChart, {
|
|
204
|
-
enableScrubbing: true,
|
|
205
|
-
points: true,
|
|
206
|
-
showArea: true,
|
|
207
|
-
showXAxis: true,
|
|
208
|
-
showYAxis: true,
|
|
209
|
-
accessibilityLabel: chartAccessibilityLabel,
|
|
210
|
-
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
211
|
-
height: 200,
|
|
212
|
-
series: [{
|
|
213
|
-
id: 'pageViews',
|
|
214
|
-
data: pageViews,
|
|
215
|
-
color: theme.color.accentBoldGreen,
|
|
216
|
-
// Label will render next to scrubber beacon
|
|
217
|
-
label: 'Page Views',
|
|
218
|
-
connectNulls: true
|
|
219
|
-
}, {
|
|
220
|
-
id: 'uniqueVisitors',
|
|
221
|
-
data: uniqueVisitors,
|
|
222
|
-
color: theme.color.accentBoldPurple,
|
|
223
|
-
label: 'Unique Visitors'
|
|
224
|
-
}],
|
|
225
|
-
xAxis: {
|
|
226
|
-
// Used on the x-axis to provide context for each index from the series data array
|
|
227
|
-
data: pages
|
|
228
|
-
},
|
|
229
|
-
yAxis: {
|
|
230
|
-
showGrid: true,
|
|
231
|
-
tickLabelFormatter: numberFormatter
|
|
232
|
-
},
|
|
233
|
-
children: /*#__PURE__*/_jsx(Scrubber, {
|
|
234
|
-
overlayOffset: 6
|
|
235
|
-
})
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
function Interaction() {
|
|
239
|
-
const [scrubberPosition, setScrubberPosition] = useState();
|
|
240
|
-
const data = useMemo(() => [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58], []);
|
|
241
|
-
const chartAccessibilityLabel = "Price chart with " + data.length + " data points. Swipe to navigate.";
|
|
242
|
-
const getScrubberAccessibilityLabel = useCallback(index => "Point " + (index + 1) + ": " + data[index], [data]);
|
|
243
|
-
return /*#__PURE__*/_jsxs(VStack, {
|
|
244
|
-
gap: 2,
|
|
245
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
246
|
-
font: "label1",
|
|
247
|
-
children: scrubberPosition !== undefined ? "Scrubber position: " + scrubberPosition : 'Not scrubbing'
|
|
248
|
-
}), /*#__PURE__*/_jsx(LineChart, {
|
|
249
|
-
enableScrubbing: true,
|
|
250
|
-
showArea: true,
|
|
251
|
-
accessibilityLabel: chartAccessibilityLabel,
|
|
252
|
-
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
253
|
-
height: 200,
|
|
254
|
-
onScrubberPositionChange: setScrubberPosition,
|
|
255
|
-
series: [{
|
|
256
|
-
id: 'prices',
|
|
257
|
-
data
|
|
258
|
-
}],
|
|
259
|
-
children: /*#__PURE__*/_jsx(Scrubber, {})
|
|
260
|
-
})]
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
function Points() {
|
|
264
|
-
const theme = useTheme();
|
|
265
|
-
const keyMarketShiftIndices = [4, 6, 7, 9, 10];
|
|
266
|
-
const data = [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58];
|
|
267
|
-
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
268
|
-
height: 200,
|
|
269
|
-
series: [{
|
|
270
|
-
id: 'prices',
|
|
271
|
-
data: data
|
|
272
|
-
}],
|
|
273
|
-
children: [/*#__PURE__*/_jsx(Area, {
|
|
274
|
-
fill: "rgb(" + theme.spectrum.blue5 + ")",
|
|
275
|
-
seriesId: "prices"
|
|
276
|
-
}), /*#__PURE__*/_jsx(Line, {
|
|
277
|
-
points: _ref => {
|
|
278
|
-
let {
|
|
279
|
-
dataX,
|
|
280
|
-
dataY
|
|
281
|
-
} = _ref,
|
|
282
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
283
|
-
return keyMarketShiftIndices.includes(dataX) ? _extends({}, props, {
|
|
284
|
-
strokeWidth: 2,
|
|
285
|
-
stroke: theme.color.bg,
|
|
286
|
-
radius: 5,
|
|
287
|
-
onClick: () => alert("You have clicked a key market shift at position " + (dataX + 1) + " with value " + dataY + "!"),
|
|
288
|
-
accessibilityLabel: "Key market shift point at position " + (dataX + 1) + ", value " + dataY + ". Click to view details."
|
|
289
|
-
}) : false;
|
|
290
|
-
},
|
|
291
|
-
seriesId: "prices"
|
|
292
|
-
})]
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
function Transitions() {
|
|
296
|
-
const theme = useTheme();
|
|
297
|
-
const dataCount = 20;
|
|
298
|
-
const maxDataOffset = 15000;
|
|
299
|
-
const minStepOffset = 2500;
|
|
300
|
-
const maxStepOffset = 10000;
|
|
301
|
-
const domainLimit = 20000;
|
|
302
|
-
const updateInterval = 500;
|
|
303
|
-
const myTransitionConfig = {
|
|
304
|
-
type: 'spring',
|
|
305
|
-
stiffness: 700,
|
|
306
|
-
damping: 20
|
|
307
|
-
};
|
|
308
|
-
const negativeColor = "rgb(" + theme.spectrum.gray15 + ")";
|
|
309
|
-
const positiveColor = theme.color.fgPositive;
|
|
310
|
-
function generateNextValue(previousValue) {
|
|
311
|
-
const range = maxStepOffset - minStepOffset;
|
|
312
|
-
const offset = Math.random() * range + minStepOffset;
|
|
313
|
-
let direction;
|
|
314
|
-
if (previousValue >= maxDataOffset) {
|
|
315
|
-
direction = -1;
|
|
316
|
-
} else if (previousValue <= -maxDataOffset) {
|
|
317
|
-
direction = 1;
|
|
318
|
-
} else {
|
|
319
|
-
direction = Math.random() < 0.5 ? -1 : 1;
|
|
320
|
-
}
|
|
321
|
-
let newValue = previousValue + offset * direction;
|
|
322
|
-
newValue = Math.max(-maxDataOffset, Math.min(maxDataOffset, newValue));
|
|
323
|
-
return newValue;
|
|
324
|
-
}
|
|
325
|
-
function generateInitialData() {
|
|
326
|
-
const data = [];
|
|
327
|
-
let previousValue = Math.random() * 2 * maxDataOffset - maxDataOffset;
|
|
328
|
-
data.push(previousValue);
|
|
329
|
-
for (let i = 1; i < dataCount; i++) {
|
|
330
|
-
const newValue = generateNextValue(previousValue);
|
|
331
|
-
data.push(newValue);
|
|
332
|
-
previousValue = newValue;
|
|
333
|
-
}
|
|
334
|
-
return data;
|
|
335
|
-
}
|
|
336
|
-
const MyGradient = /*#__PURE__*/memo(props => {
|
|
337
|
-
const areaGradient = {
|
|
338
|
-
stops: _ref2 => {
|
|
339
|
-
let {
|
|
340
|
-
min,
|
|
341
|
-
max
|
|
342
|
-
} = _ref2;
|
|
343
|
-
return [{
|
|
344
|
-
offset: min,
|
|
345
|
-
color: negativeColor,
|
|
346
|
-
opacity: 1
|
|
347
|
-
}, {
|
|
348
|
-
offset: 0,
|
|
349
|
-
color: negativeColor,
|
|
350
|
-
opacity: 0
|
|
351
|
-
}, {
|
|
352
|
-
offset: 0,
|
|
353
|
-
color: positiveColor,
|
|
354
|
-
opacity: 0
|
|
355
|
-
}, {
|
|
356
|
-
offset: max,
|
|
357
|
-
color: positiveColor,
|
|
358
|
-
opacity: 1
|
|
359
|
-
}];
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
return /*#__PURE__*/_jsx(DottedArea, _extends({}, props, {
|
|
363
|
-
gradient: areaGradient
|
|
364
|
-
}));
|
|
365
|
-
});
|
|
366
|
-
function CustomTransitionsChart() {
|
|
367
|
-
const [data, setData] = useState(generateInitialData);
|
|
368
|
-
useEffect(() => {
|
|
369
|
-
const intervalId = setInterval(() => {
|
|
370
|
-
setData(currentData => {
|
|
371
|
-
var _currentData;
|
|
372
|
-
const lastValue = (_currentData = currentData[currentData.length - 1]) != null ? _currentData : 0;
|
|
373
|
-
const newValue = generateNextValue(lastValue);
|
|
374
|
-
return [...currentData.slice(1), newValue];
|
|
375
|
-
});
|
|
376
|
-
}, updateInterval);
|
|
377
|
-
return () => clearInterval(intervalId);
|
|
378
|
-
}, []);
|
|
379
|
-
const tickLabelFormatter = useCallback(value => new Intl.NumberFormat('en-US', {
|
|
380
|
-
style: 'currency',
|
|
381
|
-
currency: 'USD',
|
|
382
|
-
maximumFractionDigits: 0
|
|
383
|
-
}).format(value), []);
|
|
384
|
-
const valueAtIndexFormatter = useCallback(dataIndex => new Intl.NumberFormat('en-US', {
|
|
385
|
-
style: 'currency',
|
|
386
|
-
currency: 'USD'
|
|
387
|
-
}).format(data[dataIndex]), [data]);
|
|
388
|
-
const lineGradient = {
|
|
389
|
-
stops: [{
|
|
390
|
-
offset: 0,
|
|
391
|
-
color: negativeColor
|
|
392
|
-
}, {
|
|
393
|
-
offset: 0,
|
|
394
|
-
color: positiveColor
|
|
395
|
-
}]
|
|
396
|
-
};
|
|
397
|
-
const chartAccessibilityLabel = "Price chart with " + data.length + " data points. Swipe to navigate.";
|
|
398
|
-
const getScrubberAccessibilityLabel = useCallback(index => "Point " + (index + 1) + ": " + valueAtIndexFormatter(index), [valueAtIndexFormatter]);
|
|
399
|
-
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
400
|
-
enableScrubbing: true,
|
|
401
|
-
accessibilityLabel: chartAccessibilityLabel,
|
|
402
|
-
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
403
|
-
height: 200,
|
|
404
|
-
inset: {
|
|
405
|
-
top: 32,
|
|
406
|
-
bottom: 32,
|
|
407
|
-
left: 16,
|
|
408
|
-
right: 16
|
|
409
|
-
},
|
|
410
|
-
series: [{
|
|
411
|
-
id: 'prices',
|
|
412
|
-
data: data,
|
|
413
|
-
gradient: lineGradient
|
|
414
|
-
}],
|
|
415
|
-
yAxis: {
|
|
416
|
-
domain: {
|
|
417
|
-
min: -domainLimit,
|
|
418
|
-
max: domainLimit
|
|
419
|
-
}
|
|
420
|
-
},
|
|
421
|
-
children: [/*#__PURE__*/_jsx(YAxis, {
|
|
422
|
-
showGrid: true,
|
|
423
|
-
requestedTickCount: 2,
|
|
424
|
-
tickLabelFormatter: tickLabelFormatter
|
|
425
|
-
}), /*#__PURE__*/_jsx(Line, {
|
|
426
|
-
showArea: true,
|
|
427
|
-
AreaComponent: MyGradient,
|
|
428
|
-
seriesId: "prices",
|
|
429
|
-
strokeWidth: 3,
|
|
430
|
-
transition: myTransitionConfig
|
|
431
|
-
}), /*#__PURE__*/_jsx(Scrubber, {
|
|
432
|
-
hideOverlay: true,
|
|
433
|
-
beaconTransitions: {
|
|
434
|
-
update: myTransitionConfig
|
|
435
|
-
},
|
|
436
|
-
label: valueAtIndexFormatter
|
|
437
|
-
})]
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
return /*#__PURE__*/_jsx(CustomTransitionsChart, {});
|
|
441
|
-
}
|
|
442
|
-
function BasicAccessible() {
|
|
443
|
-
const data = useMemo(() => [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58], []);
|
|
444
|
-
|
|
445
|
-
// Chart-level accessibility label provides overview
|
|
446
|
-
const chartAccessibilityLabel = useMemo(() => {
|
|
447
|
-
const currentPrice = data[data.length - 1];
|
|
448
|
-
return "Price chart showing trend over " + data.length + " data points. Current value: " + currentPrice + ". Use arrow keys to adjust view";
|
|
449
|
-
}, [data]);
|
|
450
|
-
const getScrubberAccessibilityLabel = useCallback(index => "Price at position " + (index + 1) + " of " + data.length + ": " + data[index], [data]);
|
|
451
|
-
return /*#__PURE__*/_jsx(LineChart, {
|
|
452
|
-
enableScrubbing: true,
|
|
453
|
-
showArea: true,
|
|
454
|
-
showYAxis: true,
|
|
455
|
-
accessibilityLabel: chartAccessibilityLabel,
|
|
456
|
-
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
457
|
-
height: 200,
|
|
458
|
-
series: [{
|
|
459
|
-
id: 'prices',
|
|
460
|
-
data: data
|
|
461
|
-
}],
|
|
462
|
-
yAxis: {
|
|
463
|
-
showGrid: true
|
|
464
|
-
},
|
|
465
|
-
children: /*#__PURE__*/_jsx(Scrubber, {})
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
function Gradients() {
|
|
469
|
-
const theme = useTheme();
|
|
470
|
-
const spectrumColors = ['blue', 'green', 'orange', 'yellow', 'gray', 'indigo', 'pink', 'purple', 'red', 'teal', 'chartreuse'];
|
|
471
|
-
const data = [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58];
|
|
472
|
-
const [currentSpectrumColor, setCurrentSpectrumColor] = useState('pink');
|
|
473
|
-
return /*#__PURE__*/_jsxs(VStack, {
|
|
474
|
-
gap: 2,
|
|
475
|
-
children: [/*#__PURE__*/_jsx(HStack, {
|
|
476
|
-
flexWrap: "wrap",
|
|
477
|
-
gap: 1,
|
|
478
|
-
justifyContent: "flex-end",
|
|
479
|
-
children: spectrumColors.map(color => /*#__PURE__*/_jsx(Pressable, {
|
|
480
|
-
accessibilityLabel: "Select " + color,
|
|
481
|
-
height: 16,
|
|
482
|
-
onPress: () => setCurrentSpectrumColor(color),
|
|
483
|
-
style: {
|
|
484
|
-
backgroundColor: "rgb(" + theme.spectrum[color + "20"] + ")",
|
|
485
|
-
borderColor: "rgb(" + theme.spectrum[color + "50"] + ")",
|
|
486
|
-
borderWidth: 2
|
|
487
|
-
},
|
|
488
|
-
width: 16
|
|
489
|
-
}, color))
|
|
490
|
-
}), /*#__PURE__*/_jsx(LineChart, {
|
|
491
|
-
points: true,
|
|
492
|
-
showYAxis: true,
|
|
493
|
-
height: 200,
|
|
494
|
-
series: [{
|
|
495
|
-
id: 'continuousGradient',
|
|
496
|
-
data: data,
|
|
497
|
-
gradient: {
|
|
498
|
-
stops: [{
|
|
499
|
-
offset: 0,
|
|
500
|
-
color: "rgb(" + theme.spectrum[currentSpectrumColor + "80"] + ")"
|
|
501
|
-
}, {
|
|
502
|
-
offset: Math.max(...data),
|
|
503
|
-
color: "rgb(" + theme.spectrum[currentSpectrumColor + "20"] + ")"
|
|
504
|
-
}]
|
|
505
|
-
}
|
|
506
|
-
}, {
|
|
507
|
-
id: 'discreteGradient',
|
|
508
|
-
data: data.map(d => d + 50),
|
|
509
|
-
// You can create a "discrete" gradient by having multiple stops at the same offset
|
|
510
|
-
gradient: {
|
|
511
|
-
stops: _ref3 => {
|
|
512
|
-
let {
|
|
513
|
-
min,
|
|
514
|
-
max
|
|
515
|
-
} = _ref3;
|
|
516
|
-
return [
|
|
517
|
-
// Allows a function which accepts min/max or direct array
|
|
518
|
-
{
|
|
519
|
-
offset: min,
|
|
520
|
-
color: "rgb(" + theme.spectrum[currentSpectrumColor + "80"] + ")"
|
|
521
|
-
}, {
|
|
522
|
-
offset: min + (max - min) / 3,
|
|
523
|
-
color: "rgb(" + theme.spectrum[currentSpectrumColor + "80"] + ")"
|
|
524
|
-
}, {
|
|
525
|
-
offset: min + (max - min) / 3,
|
|
526
|
-
color: "rgb(" + theme.spectrum[currentSpectrumColor + "50"] + ")"
|
|
527
|
-
}, {
|
|
528
|
-
offset: min + (max - min) / 3 * 2,
|
|
529
|
-
color: "rgb(" + theme.spectrum[currentSpectrumColor + "50"] + ")"
|
|
530
|
-
}, {
|
|
531
|
-
offset: min + (max - min) / 3 * 2,
|
|
532
|
-
color: "rgb(" + theme.spectrum[currentSpectrumColor + "20"] + ")"
|
|
533
|
-
}, {
|
|
534
|
-
offset: max,
|
|
535
|
-
color: "rgb(" + theme.spectrum[currentSpectrumColor + "20"] + ")"
|
|
536
|
-
}];
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
}, {
|
|
540
|
-
id: 'xAxisGradient',
|
|
541
|
-
data: data.map(d => d + 100),
|
|
542
|
-
gradient: {
|
|
543
|
-
// You can also configure by the x-axis.
|
|
544
|
-
axis: 'x',
|
|
545
|
-
stops: _ref4 => {
|
|
546
|
-
let {
|
|
547
|
-
min,
|
|
548
|
-
max
|
|
549
|
-
} = _ref4;
|
|
550
|
-
return [{
|
|
551
|
-
offset: min,
|
|
552
|
-
color: "rgb(" + theme.spectrum[currentSpectrumColor + "80"] + ")",
|
|
553
|
-
opacity: 0
|
|
554
|
-
}, {
|
|
555
|
-
offset: max,
|
|
556
|
-
color: "rgb(" + theme.spectrum[currentSpectrumColor + "20"] + ")",
|
|
557
|
-
opacity: 1
|
|
558
|
-
}];
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
}],
|
|
562
|
-
strokeWidth: 4,
|
|
563
|
-
yAxis: {
|
|
564
|
-
showGrid: true
|
|
565
|
-
}
|
|
566
|
-
})]
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
function GainLossChart() {
|
|
570
|
-
const theme = useTheme();
|
|
571
|
-
const data = useMemo(() => [-40, -28, -21, -5, 48, -5, -28, 2, -29, -46, 16, -30, -29, 8], []);
|
|
572
|
-
const negativeColor = "rgb(" + theme.spectrum.gray15 + ")";
|
|
573
|
-
const positiveColor = theme.color.fgPositive;
|
|
574
|
-
const tickLabelFormatter = useCallback(value => new Intl.NumberFormat('en-US', {
|
|
575
|
-
style: 'currency',
|
|
576
|
-
currency: 'USD',
|
|
577
|
-
maximumFractionDigits: 0
|
|
578
|
-
}).format(value), []);
|
|
579
|
-
|
|
580
|
-
// Line gradient: hard color change at 0 (full opacity for line)
|
|
581
|
-
const lineGradient = {
|
|
582
|
-
stops: [{
|
|
583
|
-
offset: 0,
|
|
584
|
-
color: negativeColor
|
|
585
|
-
}, {
|
|
586
|
-
offset: 0,
|
|
587
|
-
color: positiveColor
|
|
588
|
-
}]
|
|
589
|
-
};
|
|
590
|
-
const GradientDottedArea = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(DottedArea, _extends({}, props, {
|
|
591
|
-
gradient: {
|
|
592
|
-
stops: _ref5 => {
|
|
593
|
-
let {
|
|
594
|
-
min,
|
|
595
|
-
max
|
|
596
|
-
} = _ref5;
|
|
597
|
-
return [{
|
|
598
|
-
offset: min,
|
|
599
|
-
color: negativeColor,
|
|
600
|
-
opacity: 0.4
|
|
601
|
-
}, {
|
|
602
|
-
offset: 0,
|
|
603
|
-
color: negativeColor,
|
|
604
|
-
opacity: 0
|
|
605
|
-
}, {
|
|
606
|
-
offset: 0,
|
|
607
|
-
color: positiveColor,
|
|
608
|
-
opacity: 0
|
|
609
|
-
}, {
|
|
610
|
-
offset: max,
|
|
611
|
-
color: positiveColor,
|
|
612
|
-
opacity: 0.4
|
|
613
|
-
}];
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
})));
|
|
617
|
-
const chartAccessibilityLabel = "Price chart with " + data.length + " data points. Swipe to navigate.";
|
|
618
|
-
const getScrubberAccessibilityLabel = useCallback(index => "Point " + (index + 1) + ": " + tickLabelFormatter(data[index]), [data, tickLabelFormatter]);
|
|
619
|
-
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
620
|
-
enableScrubbing: true,
|
|
621
|
-
accessibilityLabel: chartAccessibilityLabel,
|
|
622
|
-
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
623
|
-
height: 200,
|
|
624
|
-
series: [{
|
|
625
|
-
id: 'prices',
|
|
626
|
-
data: data,
|
|
627
|
-
gradient: lineGradient
|
|
628
|
-
}],
|
|
629
|
-
children: [/*#__PURE__*/_jsx(YAxis, {
|
|
630
|
-
showGrid: true,
|
|
631
|
-
requestedTickCount: 2,
|
|
632
|
-
tickLabelFormatter: tickLabelFormatter
|
|
633
|
-
}), /*#__PURE__*/_jsx(Line, {
|
|
634
|
-
showArea: true,
|
|
635
|
-
AreaComponent: GradientDottedArea,
|
|
636
|
-
seriesId: "prices",
|
|
637
|
-
strokeWidth: 3
|
|
638
|
-
}), /*#__PURE__*/_jsx(Scrubber, {
|
|
639
|
-
hideOverlay: true
|
|
640
|
-
})]
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
function HighLowPrice() {
|
|
644
|
-
const data = [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58];
|
|
645
|
-
const minPrice = Math.min(...data);
|
|
646
|
-
const maxPrice = Math.max(...data);
|
|
647
|
-
const minPriceIndex = data.indexOf(minPrice);
|
|
648
|
-
const maxPriceIndex = data.indexOf(maxPrice);
|
|
649
|
-
const formatPrice = useCallback(price => {
|
|
650
|
-
return "$" + price.toLocaleString('en-US', {
|
|
651
|
-
minimumFractionDigits: 2,
|
|
652
|
-
maximumFractionDigits: 2
|
|
653
|
-
});
|
|
654
|
-
}, []);
|
|
655
|
-
return /*#__PURE__*/_jsxs(LineChart, {
|
|
656
|
-
showArea: true,
|
|
657
|
-
height: 200,
|
|
658
|
-
series: [{
|
|
659
|
-
id: 'prices',
|
|
660
|
-
data: data
|
|
661
|
-
}],
|
|
662
|
-
children: [/*#__PURE__*/_jsx(Point, {
|
|
663
|
-
dataX: minPriceIndex,
|
|
664
|
-
dataY: minPrice,
|
|
665
|
-
label: formatPrice(minPrice),
|
|
666
|
-
labelPosition: "bottom"
|
|
667
|
-
}), /*#__PURE__*/_jsx(Point, {
|
|
668
|
-
dataX: maxPriceIndex,
|
|
669
|
-
dataY: maxPrice,
|
|
670
|
-
label: formatPrice(maxPrice),
|
|
671
|
-
labelPosition: "top"
|
|
672
|
-
})]
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
|
-
function StylingScrubber() {
|
|
676
|
-
const theme = useTheme();
|
|
677
|
-
const pages = useMemo(() => ['Page A', 'Page B', 'Page C', 'Page D', 'Page E', 'Page F', 'Page G'], []);
|
|
678
|
-
const pageViews = useMemo(() => [2400, 1398, 9800, 3908, 4800, 3800, 4300], []);
|
|
679
|
-
const uniqueVisitors = useMemo(() => [4000, 3000, 2000, 2780, 1890, 2390, 3490], []);
|
|
680
|
-
const chartAccessibilityLabel = "Website visitors across " + pageViews.length + " pages.";
|
|
681
|
-
const getScrubberAccessibilityLabel = useCallback(index => pages[index] + ": " + pageViews[index] + " views, " + uniqueVisitors[index] + " unique visitors.", [pages, pageViews, uniqueVisitors]);
|
|
682
|
-
const numberFormatter = useCallback(value => new Intl.NumberFormat('en-US', {
|
|
683
|
-
maximumFractionDigits: 0
|
|
684
|
-
}).format(value), []);
|
|
685
|
-
return /*#__PURE__*/_jsx(LineChart, {
|
|
686
|
-
enableScrubbing: true,
|
|
687
|
-
showArea: true,
|
|
688
|
-
showXAxis: true,
|
|
689
|
-
showYAxis: true,
|
|
690
|
-
accessibilityLabel: chartAccessibilityLabel,
|
|
691
|
-
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
692
|
-
height: 200,
|
|
693
|
-
series: [{
|
|
694
|
-
id: 'pageViews',
|
|
695
|
-
data: pageViews,
|
|
696
|
-
color: theme.color.accentBoldGreen,
|
|
697
|
-
// Label will render next to scrubber beacon
|
|
698
|
-
label: 'Page Views'
|
|
699
|
-
}, {
|
|
700
|
-
id: 'uniqueVisitors',
|
|
701
|
-
data: uniqueVisitors,
|
|
702
|
-
color: theme.color.accentBoldPurple,
|
|
703
|
-
label: 'Unique Visitors',
|
|
704
|
-
// Default area is gradient
|
|
705
|
-
areaType: 'dotted'
|
|
706
|
-
}],
|
|
707
|
-
xAxis: {
|
|
708
|
-
// Used on the x-axis to provide context for each index from the series data array
|
|
709
|
-
data: pages
|
|
710
|
-
},
|
|
711
|
-
yAxis: {
|
|
712
|
-
showGrid: true,
|
|
713
|
-
tickLabelFormatter: numberFormatter
|
|
714
|
-
},
|
|
715
|
-
children: /*#__PURE__*/_jsx(Scrubber, {
|
|
716
|
-
idlePulse: true,
|
|
717
|
-
LineComponent: SolidLine,
|
|
718
|
-
seriesIds: ['pageViews']
|
|
719
|
-
})
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
|
-
function Compact() {
|
|
723
|
-
const theme = useTheme();
|
|
724
|
-
const dimensions = {
|
|
725
|
-
width: 62,
|
|
726
|
-
height: 18
|
|
727
|
-
};
|
|
728
|
-
const sparklineData = prices.map(price => parseFloat(price)).filter((price, index) => index % 10 === 0);
|
|
729
|
-
const positiveFloor = Math.min(...sparklineData) - 10;
|
|
730
|
-
const negativeData = sparklineData.map(price => -1 * price).reverse();
|
|
731
|
-
const negativeCeiling = Math.max(...negativeData) + 10;
|
|
732
|
-
const formatPrice = useCallback(price => {
|
|
733
|
-
return "$" + price.toLocaleString('en-US', {
|
|
734
|
-
minimumFractionDigits: 2,
|
|
735
|
-
maximumFractionDigits: 2
|
|
736
|
-
});
|
|
737
|
-
}, []);
|
|
738
|
-
const CompactChart = /*#__PURE__*/memo(_ref6 => {
|
|
739
|
-
let {
|
|
740
|
-
data,
|
|
741
|
-
showArea,
|
|
742
|
-
color,
|
|
743
|
-
referenceY
|
|
744
|
-
} = _ref6;
|
|
745
|
-
return /*#__PURE__*/_jsx(Box, {
|
|
746
|
-
style: {
|
|
747
|
-
padding: 1
|
|
748
|
-
},
|
|
749
|
-
children: /*#__PURE__*/_jsx(LineChart, _extends({}, dimensions, {
|
|
750
|
-
enableScrubbing: false,
|
|
751
|
-
inset: 0,
|
|
752
|
-
series: [{
|
|
753
|
-
id: 'btc',
|
|
754
|
-
data,
|
|
755
|
-
color
|
|
756
|
-
}],
|
|
757
|
-
showArea: showArea,
|
|
758
|
-
children: /*#__PURE__*/_jsx(ReferenceLine, {
|
|
759
|
-
dataY: referenceY
|
|
760
|
-
})
|
|
761
|
-
}))
|
|
762
|
-
});
|
|
763
|
-
});
|
|
764
|
-
const ChartCell = /*#__PURE__*/memo(_ref7 => {
|
|
765
|
-
let {
|
|
766
|
-
data,
|
|
767
|
-
showArea,
|
|
768
|
-
color,
|
|
769
|
-
referenceY,
|
|
770
|
-
subdetail
|
|
771
|
-
} = _ref7;
|
|
772
|
-
return /*#__PURE__*/_jsx(ListCell, {
|
|
773
|
-
accessibilityLabel: "Compact chart cell",
|
|
774
|
-
detail: formatPrice(parseFloat(prices[0])),
|
|
775
|
-
intermediary: /*#__PURE__*/_jsx(CompactChart, {
|
|
776
|
-
color: color,
|
|
777
|
-
data: data,
|
|
778
|
-
referenceY: referenceY,
|
|
779
|
-
showArea: showArea
|
|
780
|
-
}),
|
|
781
|
-
media: /*#__PURE__*/_jsx(Avatar, {
|
|
782
|
-
src: assets.btc.imageUrl
|
|
783
|
-
}),
|
|
784
|
-
onPress: () => console.log('clicked'),
|
|
785
|
-
spacingVariant: "condensed",
|
|
786
|
-
style: {
|
|
787
|
-
padding: 0
|
|
788
|
-
},
|
|
789
|
-
subdetail: subdetail
|
|
790
|
-
});
|
|
791
|
-
});
|
|
792
|
-
return /*#__PURE__*/_jsxs(VStack, {
|
|
793
|
-
children: [/*#__PURE__*/_jsx(ChartCell, {
|
|
794
|
-
color: assets.btc.color,
|
|
795
|
-
data: sparklineData,
|
|
796
|
-
referenceY: parseFloat(prices[Math.floor(prices.length / 4)]),
|
|
797
|
-
subdetail: "-4.55%"
|
|
798
|
-
}), /*#__PURE__*/_jsx(ChartCell, {
|
|
799
|
-
showArea: true,
|
|
800
|
-
color: assets.btc.color,
|
|
801
|
-
data: sparklineData,
|
|
802
|
-
referenceY: parseFloat(prices[Math.floor(prices.length / 4)]),
|
|
803
|
-
subdetail: "-4.55%"
|
|
804
|
-
}), /*#__PURE__*/_jsx(ChartCell, {
|
|
805
|
-
showArea: true,
|
|
806
|
-
color: theme.color.fgPositive,
|
|
807
|
-
data: sparklineData,
|
|
808
|
-
referenceY: positiveFloor,
|
|
809
|
-
subdetail: "+0.25%"
|
|
810
|
-
}), /*#__PURE__*/_jsx(ChartCell, {
|
|
811
|
-
showArea: true,
|
|
812
|
-
color: theme.color.fgNegative,
|
|
813
|
-
data: negativeData,
|
|
814
|
-
referenceY: negativeCeiling,
|
|
815
|
-
subdetail: "-4.55%"
|
|
816
|
-
})]
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
function AssetPriceWithDottedArea() {
|
|
820
|
-
const fontMgr = useMemo(() => {
|
|
821
|
-
const fontProvider = Skia.TypefaceFontProvider.Make();
|
|
822
|
-
// Register system fonts if available, otherwise Skia will use defaults
|
|
823
|
-
return fontProvider;
|
|
824
|
-
}, []);
|
|
825
|
-
const BTCTab = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref8, ref) => {
|
|
826
|
-
let {
|
|
827
|
-
label
|
|
828
|
-
} = _ref8,
|
|
829
|
-
props = _objectWithoutPropertiesLoose(_ref8, _excluded2);
|
|
830
|
-
const {
|
|
831
|
-
activeTab
|
|
832
|
-
} = useTabsContext();
|
|
833
|
-
const isActive = (activeTab == null ? void 0 : activeTab.id) === props.id;
|
|
834
|
-
return /*#__PURE__*/_jsx(SegmentedTab, _extends({
|
|
835
|
-
ref: ref,
|
|
836
|
-
label: /*#__PURE__*/_jsx(Text, {
|
|
837
|
-
font: "label1",
|
|
838
|
-
style: {
|
|
839
|
-
color: isActive ? assets.btc.color : undefined
|
|
840
|
-
},
|
|
841
|
-
children: label
|
|
842
|
-
})
|
|
843
|
-
}, props));
|
|
844
|
-
}));
|
|
845
|
-
const BTCActiveIndicator = /*#__PURE__*/memo(_ref9 => {
|
|
846
|
-
let {
|
|
847
|
-
style
|
|
848
|
-
} = _ref9,
|
|
849
|
-
props = _objectWithoutPropertiesLoose(_ref9, _excluded3);
|
|
850
|
-
return /*#__PURE__*/_jsx(PeriodSelectorActiveIndicator, _extends({}, props, {
|
|
851
|
-
style: [style, {
|
|
852
|
-
backgroundColor: assets.btc.color + "1A"
|
|
853
|
-
}]
|
|
854
|
-
}));
|
|
855
|
-
});
|
|
856
|
-
const AssetPriceDotted = /*#__PURE__*/memo(() => {
|
|
857
|
-
const theme = useTheme();
|
|
858
|
-
const currentPrice = sparklineInteractiveData.hour[sparklineInteractiveData.hour.length - 1].value;
|
|
859
|
-
const tabs = useMemo(() => [{
|
|
860
|
-
id: 'hour',
|
|
861
|
-
label: '1H'
|
|
862
|
-
}, {
|
|
863
|
-
id: 'day',
|
|
864
|
-
label: '1D'
|
|
865
|
-
}, {
|
|
866
|
-
id: 'week',
|
|
867
|
-
label: '1W'
|
|
868
|
-
}, {
|
|
869
|
-
id: 'month',
|
|
870
|
-
label: '1M'
|
|
871
|
-
}, {
|
|
872
|
-
id: 'year',
|
|
873
|
-
label: '1Y'
|
|
874
|
-
}, {
|
|
875
|
-
id: 'all',
|
|
876
|
-
label: 'All'
|
|
877
|
-
}], []);
|
|
878
|
-
const [timePeriod, setTimePeriod] = useState(tabs[0]);
|
|
879
|
-
const sparklineTimePeriodData = useMemo(() => {
|
|
880
|
-
return sparklineInteractiveData[timePeriod.id];
|
|
881
|
-
}, [timePeriod]);
|
|
882
|
-
const sparklineTimePeriodDataValues = useMemo(() => {
|
|
883
|
-
return sparklineTimePeriodData.map(d => d.value);
|
|
884
|
-
}, [sparklineTimePeriodData]);
|
|
885
|
-
const sparklineTimePeriodDataTimestamps = useMemo(() => {
|
|
886
|
-
return sparklineTimePeriodData.map(d => d.date);
|
|
887
|
-
}, [sparklineTimePeriodData]);
|
|
888
|
-
const onPeriodChange = useCallback(period => {
|
|
889
|
-
setTimePeriod(period || tabs[0]);
|
|
890
|
-
}, [tabs, setTimePeriod]);
|
|
891
|
-
const priceFormatter = useMemo(() => new Intl.NumberFormat('en-US', {
|
|
892
|
-
style: 'currency',
|
|
893
|
-
currency: 'USD'
|
|
894
|
-
}), []);
|
|
895
|
-
const formatPrice = useCallback(price => {
|
|
896
|
-
return priceFormatter.format(price);
|
|
897
|
-
}, [priceFormatter]);
|
|
898
|
-
const formatDate = useCallback(date => {
|
|
899
|
-
const dayOfWeek = date.toLocaleDateString('en-US', {
|
|
900
|
-
weekday: 'short'
|
|
901
|
-
});
|
|
902
|
-
const monthDay = date.toLocaleDateString('en-US', {
|
|
903
|
-
month: 'short',
|
|
904
|
-
day: 'numeric'
|
|
905
|
-
});
|
|
906
|
-
const time = date.toLocaleTimeString('en-US', {
|
|
907
|
-
hour: 'numeric',
|
|
908
|
-
minute: '2-digit',
|
|
909
|
-
hour12: true
|
|
910
|
-
});
|
|
911
|
-
return dayOfWeek + ", " + monthDay + ", " + time;
|
|
912
|
-
}, []);
|
|
913
|
-
const chartAccessibilityLabel = "Bitcoin price chart for " + timePeriod.label + " period. Current price: " + formatPrice(currentPrice) + ".";
|
|
914
|
-
const getScrubberAccessibilityLabel = useCallback(index => {
|
|
915
|
-
const price = formatPrice(sparklineTimePeriodDataValues[index]);
|
|
916
|
-
const date = formatDate(sparklineTimePeriodDataTimestamps[index]);
|
|
917
|
-
return price + " " + date;
|
|
918
|
-
}, [formatDate, formatPrice, sparklineTimePeriodDataTimestamps, sparklineTimePeriodDataValues]);
|
|
919
|
-
return /*#__PURE__*/_jsxs(VStack, {
|
|
920
|
-
gap: 2,
|
|
921
|
-
children: [/*#__PURE__*/_jsx(SectionHeader, {
|
|
922
|
-
balance: /*#__PURE__*/_jsx(Text, {
|
|
923
|
-
font: "title2",
|
|
924
|
-
children: formatPrice(currentPrice)
|
|
925
|
-
}),
|
|
926
|
-
end: /*#__PURE__*/_jsx(VStack, {
|
|
927
|
-
justifyContent: "center",
|
|
928
|
-
children: /*#__PURE__*/_jsx(RemoteImage, {
|
|
929
|
-
shape: "circle",
|
|
930
|
-
size: "xl",
|
|
931
|
-
source: assets.btc.imageUrl
|
|
932
|
-
})
|
|
933
|
-
}),
|
|
934
|
-
title: /*#__PURE__*/_jsx(Text, {
|
|
935
|
-
font: "title1",
|
|
936
|
-
children: "Bitcoin"
|
|
937
|
-
})
|
|
938
|
-
}), /*#__PURE__*/_jsx(LineChart, {
|
|
939
|
-
enableScrubbing: true,
|
|
940
|
-
showArea: true,
|
|
941
|
-
accessibilityLabel: chartAccessibilityLabel,
|
|
942
|
-
areaType: "dotted",
|
|
943
|
-
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
944
|
-
height: 200,
|
|
945
|
-
inset: {
|
|
946
|
-
top: 52
|
|
947
|
-
},
|
|
948
|
-
series: [{
|
|
949
|
-
id: 'btc',
|
|
950
|
-
data: sparklineTimePeriodDataValues,
|
|
951
|
-
color: assets.btc.color
|
|
952
|
-
}],
|
|
953
|
-
children: /*#__PURE__*/_jsx(Scrubber, {
|
|
954
|
-
idlePulse: true,
|
|
955
|
-
labelElevated: true,
|
|
956
|
-
label: d => {
|
|
957
|
-
const date = formatDate(sparklineTimePeriodDataTimestamps[d]);
|
|
958
|
-
const price = formatPrice(sparklineTimePeriodDataValues[d]);
|
|
959
|
-
const regularStyle = {
|
|
960
|
-
fontFamilies: ['Inter'],
|
|
961
|
-
fontSize: 14,
|
|
962
|
-
fontStyle: {
|
|
963
|
-
weight: FontWeight.Normal
|
|
964
|
-
},
|
|
965
|
-
color: Skia.Color(theme.color.fgMuted)
|
|
966
|
-
};
|
|
967
|
-
const boldStyle = _extends({
|
|
968
|
-
fontFamilies: ['Inter']
|
|
969
|
-
}, regularStyle, {
|
|
970
|
-
fontStyle: {
|
|
971
|
-
weight: FontWeight.Bold
|
|
972
|
-
}
|
|
973
|
-
});
|
|
974
|
-
|
|
975
|
-
// 3. Use the ParagraphBuilder
|
|
976
|
-
const builder = Skia.ParagraphBuilder.Make({
|
|
977
|
-
textAlign: TextAlign.Left
|
|
978
|
-
}, fontMgr);
|
|
979
|
-
builder.pushStyle(boldStyle);
|
|
980
|
-
builder.addText(price);
|
|
981
|
-
builder.pushStyle(regularStyle);
|
|
982
|
-
builder.addText(" " + date);
|
|
983
|
-
const para = builder.build();
|
|
984
|
-
para.layout(512);
|
|
985
|
-
return para;
|
|
986
|
-
}
|
|
987
|
-
})
|
|
988
|
-
}), /*#__PURE__*/_jsx(PeriodSelector, {
|
|
989
|
-
TabComponent: BTCTab,
|
|
990
|
-
TabsActiveIndicatorComponent: BTCActiveIndicator,
|
|
991
|
-
activeTab: timePeriod,
|
|
992
|
-
onChange: onPeriodChange,
|
|
993
|
-
tabs: tabs
|
|
994
|
-
})]
|
|
995
|
-
});
|
|
996
|
-
});
|
|
997
|
-
return /*#__PURE__*/_jsx(AssetPriceDotted, {});
|
|
998
|
-
}
|
|
999
|
-
const LegendDot = /*#__PURE__*/memo(props => {
|
|
1000
|
-
return /*#__PURE__*/_jsx(Box, _extends({
|
|
1001
|
-
borderRadius: 1000,
|
|
1002
|
-
height: 10,
|
|
1003
|
-
width: 10
|
|
1004
|
-
}, props));
|
|
1005
|
-
});
|
|
1006
|
-
const LegendEntry = /*#__PURE__*/memo(_ref0 => {
|
|
1007
|
-
let {
|
|
1008
|
-
color = assets.btc.color,
|
|
1009
|
-
label,
|
|
1010
|
-
value
|
|
1011
|
-
} = _ref0;
|
|
1012
|
-
return /*#__PURE__*/_jsxs(Box, {
|
|
1013
|
-
alignItems: "center",
|
|
1014
|
-
flexDirection: "row",
|
|
1015
|
-
gap: 0.5,
|
|
1016
|
-
children: [/*#__PURE__*/_jsx(LegendDot, {
|
|
1017
|
-
style: {
|
|
1018
|
-
backgroundColor: color
|
|
1019
|
-
}
|
|
1020
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
1021
|
-
font: "label2",
|
|
1022
|
-
children: label
|
|
1023
|
-
}), value && /*#__PURE__*/_jsx(Text, {
|
|
1024
|
-
color: "fgMuted",
|
|
1025
|
-
font: "label2",
|
|
1026
|
-
style: {
|
|
1027
|
-
fontWeight: 'bold'
|
|
1028
|
-
},
|
|
1029
|
-
children: value
|
|
1030
|
-
})]
|
|
1031
|
-
});
|
|
1032
|
-
});
|
|
1033
|
-
const PerformanceHeader = /*#__PURE__*/memo(_ref1 => {
|
|
1034
|
-
let {
|
|
1035
|
-
scrubberPosition,
|
|
1036
|
-
sparklineTimePeriodDataValues
|
|
1037
|
-
} = _ref1;
|
|
1038
|
-
const theme = useTheme();
|
|
1039
|
-
const formatPriceThousands = useCallback(price => {
|
|
1040
|
-
return new Intl.NumberFormat('en-US', {
|
|
1041
|
-
style: 'currency',
|
|
1042
|
-
currency: 'USD',
|
|
1043
|
-
minimumFractionDigits: 0,
|
|
1044
|
-
maximumFractionDigits: 0
|
|
1045
|
-
}).format(price / 1000) + "k";
|
|
1046
|
-
}, []);
|
|
1047
|
-
const shownPosition = scrubberPosition !== undefined ? scrubberPosition : sparklineTimePeriodDataValues.length - 1;
|
|
1048
|
-
return /*#__PURE__*/_jsxs(HStack, {
|
|
1049
|
-
gap: 1,
|
|
1050
|
-
paddingX: 1,
|
|
1051
|
-
children: [/*#__PURE__*/_jsx(LegendEntry, {
|
|
1052
|
-
color: theme.color.fgPositive,
|
|
1053
|
-
label: "High Price",
|
|
1054
|
-
value: formatPriceThousands(sparklineTimePeriodDataValues[shownPosition] * 1.2)
|
|
1055
|
-
}), /*#__PURE__*/_jsx(LegendEntry, {
|
|
1056
|
-
color: assets.btc.color,
|
|
1057
|
-
label: "Actual Price",
|
|
1058
|
-
value: formatPriceThousands(sparklineTimePeriodDataValues[shownPosition])
|
|
1059
|
-
}), /*#__PURE__*/_jsx(LegendEntry, {
|
|
1060
|
-
color: theme.color.fgNegative,
|
|
1061
|
-
label: "Low Price",
|
|
1062
|
-
value: formatPriceThousands(sparklineTimePeriodDataValues[shownPosition] * 0.8)
|
|
1063
|
-
})]
|
|
1064
|
-
});
|
|
1065
|
-
});
|
|
1066
|
-
const PerformanceChart = /*#__PURE__*/memo(_ref10 => {
|
|
1067
|
-
let {
|
|
1068
|
-
timePeriod,
|
|
1069
|
-
onScrubberPositionChange
|
|
1070
|
-
} = _ref10;
|
|
1071
|
-
const theme = useTheme();
|
|
1072
|
-
const sparklineTimePeriodData = useMemo(() => {
|
|
1073
|
-
return sparklineInteractiveData[timePeriod.id];
|
|
1074
|
-
}, [timePeriod]);
|
|
1075
|
-
const sparklineTimePeriodDataValues = useMemo(() => {
|
|
1076
|
-
return sparklineTimePeriodData.map(d => d.value);
|
|
1077
|
-
}, [sparklineTimePeriodData]);
|
|
1078
|
-
const sparklineTimePeriodDataTimestamps = useMemo(() => {
|
|
1079
|
-
return sparklineTimePeriodData.map(d => d.date);
|
|
1080
|
-
}, [sparklineTimePeriodData]);
|
|
1081
|
-
const formatPriceThousands = useCallback(price => {
|
|
1082
|
-
return new Intl.NumberFormat('en-US', {
|
|
1083
|
-
style: 'currency',
|
|
1084
|
-
currency: 'USD',
|
|
1085
|
-
minimumFractionDigits: 0,
|
|
1086
|
-
maximumFractionDigits: 0
|
|
1087
|
-
}).format(price / 1000) + "k";
|
|
1088
|
-
}, []);
|
|
1089
|
-
const formatDate = useCallback(date => {
|
|
1090
|
-
const dayOfWeek = date.toLocaleDateString('en-US', {
|
|
1091
|
-
weekday: 'short'
|
|
1092
|
-
});
|
|
1093
|
-
const monthDay = date.toLocaleDateString('en-US', {
|
|
1094
|
-
month: 'short',
|
|
1095
|
-
day: 'numeric'
|
|
1096
|
-
});
|
|
1097
|
-
const time = date.toLocaleTimeString('en-US', {
|
|
1098
|
-
hour: 'numeric',
|
|
1099
|
-
minute: '2-digit',
|
|
1100
|
-
hour12: true
|
|
1101
|
-
});
|
|
1102
|
-
return dayOfWeek + ", " + monthDay + ", " + time;
|
|
1103
|
-
}, []);
|
|
1104
|
-
const getScrubberLabel = useCallback(d => formatDate(sparklineTimePeriodDataTimestamps[d]), [formatDate, sparklineTimePeriodDataTimestamps]);
|
|
1105
|
-
const chartAccessibilityLabel = "Bitcoin price chart with high, actual, and low series. " + sparklineTimePeriodDataValues.length + " data points. Swipe to navigate.";
|
|
1106
|
-
const getScrubberAccessibilityLabel = useCallback(index => {
|
|
1107
|
-
const price = formatPriceThousands(sparklineTimePeriodDataValues[index]);
|
|
1108
|
-
const date = formatDate(sparklineTimePeriodDataTimestamps[index]);
|
|
1109
|
-
return "Point " + (index + 1) + ": " + price + ", " + date;
|
|
1110
|
-
}, [formatDate, formatPriceThousands, sparklineTimePeriodDataTimestamps, sparklineTimePeriodDataValues]);
|
|
1111
|
-
return /*#__PURE__*/_jsx(LineChart, {
|
|
1112
|
-
enableScrubbing: true,
|
|
1113
|
-
showArea: true,
|
|
1114
|
-
showYAxis: true,
|
|
1115
|
-
accessibilityLabel: chartAccessibilityLabel,
|
|
1116
|
-
areaType: "dotted",
|
|
1117
|
-
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
1118
|
-
height: 300,
|
|
1119
|
-
inset: {
|
|
1120
|
-
top: 52,
|
|
1121
|
-
left: 0,
|
|
1122
|
-
right: 0
|
|
1123
|
-
},
|
|
1124
|
-
onScrubberPositionChange: onScrubberPositionChange,
|
|
1125
|
-
series: [{
|
|
1126
|
-
id: 'high',
|
|
1127
|
-
data: sparklineTimePeriodDataValues.map(d => d * 1.2),
|
|
1128
|
-
color: theme.color.fgPositive,
|
|
1129
|
-
label: 'High Price'
|
|
1130
|
-
}, {
|
|
1131
|
-
id: 'btc',
|
|
1132
|
-
data: sparklineTimePeriodDataValues,
|
|
1133
|
-
color: assets.btc.color,
|
|
1134
|
-
label: 'Actual Price'
|
|
1135
|
-
}, {
|
|
1136
|
-
id: 'low',
|
|
1137
|
-
data: sparklineTimePeriodDataValues.map(d => d * 0.8),
|
|
1138
|
-
color: theme.color.fgNegative,
|
|
1139
|
-
label: 'Low Price'
|
|
1140
|
-
}],
|
|
1141
|
-
yAxis: {
|
|
1142
|
-
showGrid: true,
|
|
1143
|
-
tickLabelFormatter: formatPriceThousands
|
|
1144
|
-
},
|
|
1145
|
-
children: /*#__PURE__*/_jsx(Scrubber, {
|
|
1146
|
-
idlePulse: true,
|
|
1147
|
-
label: getScrubberLabel
|
|
1148
|
-
})
|
|
1149
|
-
});
|
|
1150
|
-
});
|
|
1151
|
-
function Performance() {
|
|
1152
|
-
const tabs = useMemo(() => [{
|
|
1153
|
-
id: 'hour',
|
|
1154
|
-
label: '1H'
|
|
1155
|
-
}, {
|
|
1156
|
-
id: 'day',
|
|
1157
|
-
label: '1D'
|
|
1158
|
-
}, {
|
|
1159
|
-
id: 'week',
|
|
1160
|
-
label: '1W'
|
|
1161
|
-
}, {
|
|
1162
|
-
id: 'month',
|
|
1163
|
-
label: '1M'
|
|
1164
|
-
}, {
|
|
1165
|
-
id: 'year',
|
|
1166
|
-
label: '1Y'
|
|
1167
|
-
}, {
|
|
1168
|
-
id: 'all',
|
|
1169
|
-
label: 'All'
|
|
1170
|
-
}], []);
|
|
1171
|
-
const [timePeriod, setTimePeriod] = useState(tabs[0]);
|
|
1172
|
-
const [scrubberPosition, setScrubberPosition] = useState();
|
|
1173
|
-
const sparklineTimePeriodData = useMemo(() => {
|
|
1174
|
-
return sparklineInteractiveData[timePeriod.id];
|
|
1175
|
-
}, [timePeriod]);
|
|
1176
|
-
const sparklineTimePeriodDataValues = useMemo(() => {
|
|
1177
|
-
return sparklineTimePeriodData.map(d => d.value);
|
|
1178
|
-
}, [sparklineTimePeriodData]);
|
|
1179
|
-
const onPeriodChange = useCallback(period => {
|
|
1180
|
-
setTimePeriod(period || tabs[0]);
|
|
1181
|
-
}, [tabs]);
|
|
1182
|
-
return /*#__PURE__*/_jsxs(VStack, {
|
|
1183
|
-
gap: 2,
|
|
1184
|
-
style: {
|
|
1185
|
-
marginLeft: -8,
|
|
1186
|
-
marginRight: -8
|
|
1187
|
-
},
|
|
1188
|
-
children: [/*#__PURE__*/_jsx(PerformanceHeader, {
|
|
1189
|
-
scrubberPosition: scrubberPosition,
|
|
1190
|
-
sparklineTimePeriodDataValues: sparklineTimePeriodDataValues
|
|
1191
|
-
}), /*#__PURE__*/_jsx(PerformanceChart, {
|
|
1192
|
-
onScrubberPositionChange: setScrubberPosition,
|
|
1193
|
-
timePeriod: timePeriod
|
|
1194
|
-
}), /*#__PURE__*/_jsx(PeriodSelector, {
|
|
1195
|
-
activeTab: timePeriod,
|
|
1196
|
-
onChange: onPeriodChange,
|
|
1197
|
-
tabs: tabs
|
|
1198
|
-
})]
|
|
1199
|
-
});
|
|
1200
|
-
}
|
|
1201
|
-
function MonotoneAssetPrice() {
|
|
1202
|
-
const theme = useTheme();
|
|
1203
|
-
const prices = sparklineInteractiveData.hour;
|
|
1204
|
-
const fontMgr = useMemo(() => {
|
|
1205
|
-
const fontProvider = Skia.TypefaceFontProvider.Make();
|
|
1206
|
-
// Register system fonts if available, otherwise Skia will use defaults
|
|
1207
|
-
return fontProvider;
|
|
1208
|
-
}, []);
|
|
1209
|
-
const priceFormatter = useMemo(() => new Intl.NumberFormat('en-US', {
|
|
1210
|
-
style: 'currency',
|
|
1211
|
-
currency: 'USD'
|
|
1212
|
-
}), []);
|
|
1213
|
-
const scrubberPriceFormatter = useMemo(() => new Intl.NumberFormat('en-US', {
|
|
1214
|
-
minimumFractionDigits: 2,
|
|
1215
|
-
maximumFractionDigits: 2
|
|
1216
|
-
}), []);
|
|
1217
|
-
const formatPrice = useCallback(price => {
|
|
1218
|
-
return priceFormatter.format(price);
|
|
1219
|
-
}, [priceFormatter]);
|
|
1220
|
-
const formatDate = useCallback(date => {
|
|
1221
|
-
const dayOfWeek = date.toLocaleDateString('en-US', {
|
|
1222
|
-
weekday: 'short'
|
|
1223
|
-
});
|
|
1224
|
-
const monthDay = date.toLocaleDateString('en-US', {
|
|
1225
|
-
month: 'short',
|
|
1226
|
-
day: 'numeric'
|
|
1227
|
-
});
|
|
1228
|
-
const time = date.toLocaleTimeString('en-US', {
|
|
1229
|
-
hour: 'numeric',
|
|
1230
|
-
minute: '2-digit',
|
|
1231
|
-
hour12: true
|
|
1232
|
-
});
|
|
1233
|
-
return dayOfWeek + ", " + monthDay + ", " + time;
|
|
1234
|
-
}, []);
|
|
1235
|
-
const scrubberLabel = useCallback(index => {
|
|
1236
|
-
const price = scrubberPriceFormatter.format(prices[index].value);
|
|
1237
|
-
const date = formatDate(prices[index].date);
|
|
1238
|
-
const regularStyle = {
|
|
1239
|
-
fontFamilies: ['Inter'],
|
|
1240
|
-
fontSize: 14,
|
|
1241
|
-
fontStyle: {
|
|
1242
|
-
weight: FontWeight.Normal
|
|
1243
|
-
},
|
|
1244
|
-
color: Skia.Color(theme.color.fgMuted)
|
|
1245
|
-
};
|
|
1246
|
-
const boldStyle = _extends({
|
|
1247
|
-
fontFamilies: ['Inter']
|
|
1248
|
-
}, regularStyle, {
|
|
1249
|
-
fontStyle: {
|
|
1250
|
-
weight: FontWeight.Bold
|
|
1251
|
-
}
|
|
1252
|
-
});
|
|
1253
|
-
const builder = Skia.ParagraphBuilder.Make({
|
|
1254
|
-
textAlign: TextAlign.Left
|
|
1255
|
-
}, fontMgr);
|
|
1256
|
-
builder.pushStyle(boldStyle);
|
|
1257
|
-
builder.addText(price + " USD");
|
|
1258
|
-
builder.pushStyle(regularStyle);
|
|
1259
|
-
builder.addText(" " + date);
|
|
1260
|
-
const para = builder.build();
|
|
1261
|
-
para.layout(512);
|
|
1262
|
-
return para;
|
|
1263
|
-
}, [scrubberPriceFormatter, prices, formatDate, theme.color.fgMuted, fontMgr]);
|
|
1264
|
-
const formatAxisLabelPrice = useCallback(price => {
|
|
1265
|
-
return formatPrice(price);
|
|
1266
|
-
}, [formatPrice]);
|
|
1267
|
-
|
|
1268
|
-
// Custom tick label component with offset positioning
|
|
1269
|
-
const CustomYAxisTickLabel = useCallback(props => /*#__PURE__*/_jsx(DefaultAxisTickLabel, _extends({}, props, {
|
|
1270
|
-
dx: 4,
|
|
1271
|
-
dy: -12,
|
|
1272
|
-
horizontalAlignment: "left"
|
|
1273
|
-
})), []);
|
|
1274
|
-
const chartAccessibilityLabel = "Price chart with " + prices.length + " data points. Swipe to navigate.";
|
|
1275
|
-
const getScrubberAccessibilityLabel = useCallback(index => {
|
|
1276
|
-
const price = scrubberPriceFormatter.format(prices[index].value);
|
|
1277
|
-
const date = formatDate(prices[index].date);
|
|
1278
|
-
return price + " USD " + date;
|
|
1279
|
-
}, [formatDate, prices, scrubberPriceFormatter]);
|
|
1280
|
-
const CustomScrubberBeacon = /*#__PURE__*/memo(_ref11 => {
|
|
1281
|
-
let {
|
|
1282
|
-
dataX,
|
|
1283
|
-
dataY,
|
|
1284
|
-
seriesId,
|
|
1285
|
-
isIdle,
|
|
1286
|
-
animate = true
|
|
1287
|
-
} = _ref11;
|
|
1288
|
-
const {
|
|
1289
|
-
getSeries,
|
|
1290
|
-
getXSerializableScale,
|
|
1291
|
-
getYSerializableScale
|
|
1292
|
-
} = useCartesianChartContext();
|
|
1293
|
-
const targetSeries = useMemo(() => getSeries(seriesId), [getSeries, seriesId]);
|
|
1294
|
-
const xScale = useMemo(() => getXSerializableScale(), [getXSerializableScale]);
|
|
1295
|
-
const yScale = useMemo(() => getYSerializableScale(targetSeries == null ? void 0 : targetSeries.yAxisId), [getYSerializableScale, targetSeries == null ? void 0 : targetSeries.yAxisId]);
|
|
1296
|
-
const animatedX = useSharedValue(0);
|
|
1297
|
-
const animatedY = useSharedValue(0);
|
|
1298
|
-
|
|
1299
|
-
// Calculate the target point position - project data to pixels
|
|
1300
|
-
const targetPoint = useDerivedValue(() => {
|
|
1301
|
-
if (!xScale || !yScale) return {
|
|
1302
|
-
x: 0,
|
|
1303
|
-
y: 0
|
|
1304
|
-
};
|
|
1305
|
-
return projectPointWithSerializableScale({
|
|
1306
|
-
x: unwrapAnimatedValue(dataX),
|
|
1307
|
-
y: unwrapAnimatedValue(dataY),
|
|
1308
|
-
xScale,
|
|
1309
|
-
yScale
|
|
1310
|
-
});
|
|
1311
|
-
}, [dataX, dataY, xScale, yScale]);
|
|
1312
|
-
useAnimatedReaction(() => {
|
|
1313
|
-
return {
|
|
1314
|
-
point: targetPoint.value,
|
|
1315
|
-
isIdle: unwrapAnimatedValue(isIdle)
|
|
1316
|
-
};
|
|
1317
|
-
}, (current, previous) => {
|
|
1318
|
-
// When animation is disabled, on initial render, or when we are starting,
|
|
1319
|
-
// continuing, or finishing scrubbing we should immediately transition
|
|
1320
|
-
if (!animate || previous === null || !previous.isIdle || !current.isIdle) {
|
|
1321
|
-
animatedX.value = current.point.x;
|
|
1322
|
-
animatedY.value = current.point.y;
|
|
1323
|
-
return;
|
|
1324
|
-
}
|
|
1325
|
-
animatedX.value = buildTransition(current.point.x, defaultTransition);
|
|
1326
|
-
animatedY.value = buildTransition(current.point.y, defaultTransition);
|
|
1327
|
-
}, [animate]);
|
|
1328
|
-
|
|
1329
|
-
// Create animated point using the animated values
|
|
1330
|
-
const animatedPoint = useDerivedValue(() => {
|
|
1331
|
-
return {
|
|
1332
|
-
x: animatedX.value,
|
|
1333
|
-
y: animatedY.value
|
|
1334
|
-
};
|
|
1335
|
-
}, [animatedX, animatedY]);
|
|
1336
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
1337
|
-
children: [/*#__PURE__*/_jsx(Circle, {
|
|
1338
|
-
c: animatedPoint,
|
|
1339
|
-
color: theme.color.bg,
|
|
1340
|
-
r: 5
|
|
1341
|
-
}), /*#__PURE__*/_jsx(Circle, {
|
|
1342
|
-
c: animatedPoint,
|
|
1343
|
-
color: theme.color.fg,
|
|
1344
|
-
r: 5,
|
|
1345
|
-
strokeWidth: 3,
|
|
1346
|
-
style: "stroke"
|
|
1347
|
-
})]
|
|
1348
|
-
});
|
|
1349
|
-
});
|
|
1350
|
-
return /*#__PURE__*/_jsx(LineChart, {
|
|
1351
|
-
enableScrubbing: true,
|
|
1352
|
-
showYAxis: true,
|
|
1353
|
-
accessibilityLabel: chartAccessibilityLabel,
|
|
1354
|
-
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
1355
|
-
height: 200,
|
|
1356
|
-
inset: {
|
|
1357
|
-
top: 64
|
|
1358
|
-
},
|
|
1359
|
-
series: [{
|
|
1360
|
-
id: 'btc',
|
|
1361
|
-
data: prices.map(price => price.value),
|
|
1362
|
-
color: theme.color.fg,
|
|
1363
|
-
gradient: {
|
|
1364
|
-
axis: 'x',
|
|
1365
|
-
stops: _ref12 => {
|
|
1366
|
-
let {
|
|
1367
|
-
min
|
|
1368
|
-
} = _ref12;
|
|
1369
|
-
return [{
|
|
1370
|
-
offset: min,
|
|
1371
|
-
color: theme.color.fg,
|
|
1372
|
-
opacity: 0
|
|
1373
|
-
}, {
|
|
1374
|
-
offset: 32,
|
|
1375
|
-
color: theme.color.fg,
|
|
1376
|
-
opacity: 1
|
|
1377
|
-
}];
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
}],
|
|
1381
|
-
xAxis: {
|
|
1382
|
-
range: _ref13 => {
|
|
1383
|
-
let {
|
|
1384
|
-
max
|
|
1385
|
-
} = _ref13;
|
|
1386
|
-
return {
|
|
1387
|
-
min: 96,
|
|
1388
|
-
max
|
|
1389
|
-
};
|
|
1390
|
-
}
|
|
1391
|
-
},
|
|
1392
|
-
yAxis: {
|
|
1393
|
-
position: 'left',
|
|
1394
|
-
width: 0,
|
|
1395
|
-
showGrid: true,
|
|
1396
|
-
tickLabelFormatter: formatAxisLabelPrice,
|
|
1397
|
-
TickLabelComponent: CustomYAxisTickLabel
|
|
1398
|
-
},
|
|
1399
|
-
children: /*#__PURE__*/_jsx(Scrubber, {
|
|
1400
|
-
hideOverlay: true,
|
|
1401
|
-
labelElevated: true,
|
|
1402
|
-
BeaconComponent: CustomScrubberBeacon,
|
|
1403
|
-
LineComponent: SolidLine,
|
|
1404
|
-
label: scrubberLabel
|
|
1405
|
-
})
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
function ServiceAvailability() {
|
|
1409
|
-
const theme = useTheme();
|
|
1410
|
-
const availabilityEvents = useMemo(() => [{
|
|
1411
|
-
date: new Date('2022-01-01'),
|
|
1412
|
-
availability: 79
|
|
1413
|
-
}, {
|
|
1414
|
-
date: new Date('2022-01-03'),
|
|
1415
|
-
availability: 81
|
|
1416
|
-
}, {
|
|
1417
|
-
date: new Date('2022-01-04'),
|
|
1418
|
-
availability: 82
|
|
1419
|
-
}, {
|
|
1420
|
-
date: new Date('2022-01-06'),
|
|
1421
|
-
availability: 91
|
|
1422
|
-
}, {
|
|
1423
|
-
date: new Date('2022-01-07'),
|
|
1424
|
-
availability: 92
|
|
1425
|
-
}, {
|
|
1426
|
-
date: new Date('2022-01-10'),
|
|
1427
|
-
availability: 86
|
|
1428
|
-
}], []);
|
|
1429
|
-
const chartAccessibilityLabel = "Service availability chart with " + availabilityEvents.length + " data points. Swipe to navigate.";
|
|
1430
|
-
const getScrubberAccessibilityLabel = useCallback(index => "Point " + (index + 1) + ": " + availabilityEvents[index].availability + "% availability on " + availabilityEvents[index].date.toLocaleDateString(), [availabilityEvents]);
|
|
1431
|
-
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
1432
|
-
enableScrubbing: true,
|
|
1433
|
-
accessibilityLabel: chartAccessibilityLabel,
|
|
1434
|
-
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
1435
|
-
height: 200,
|
|
1436
|
-
series: [{
|
|
1437
|
-
id: 'availability',
|
|
1438
|
-
data: availabilityEvents.map(event => event.availability),
|
|
1439
|
-
gradient: {
|
|
1440
|
-
stops: _ref14 => {
|
|
1441
|
-
let {
|
|
1442
|
-
min,
|
|
1443
|
-
max
|
|
1444
|
-
} = _ref14;
|
|
1445
|
-
return [{
|
|
1446
|
-
offset: min,
|
|
1447
|
-
color: theme.color.fgNegative
|
|
1448
|
-
}, {
|
|
1449
|
-
offset: 85,
|
|
1450
|
-
color: theme.color.fgNegative
|
|
1451
|
-
}, {
|
|
1452
|
-
offset: 85,
|
|
1453
|
-
color: theme.color.fgWarning
|
|
1454
|
-
}, {
|
|
1455
|
-
offset: 90,
|
|
1456
|
-
color: theme.color.fgWarning
|
|
1457
|
-
}, {
|
|
1458
|
-
offset: 90,
|
|
1459
|
-
color: theme.color.fgPositive
|
|
1460
|
-
}, {
|
|
1461
|
-
offset: max,
|
|
1462
|
-
color: theme.color.fgPositive
|
|
1463
|
-
}];
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
}],
|
|
1467
|
-
xAxis: {
|
|
1468
|
-
data: availabilityEvents.map(event => event.date.getTime())
|
|
1469
|
-
},
|
|
1470
|
-
yAxis: {
|
|
1471
|
-
domain: _ref15 => {
|
|
1472
|
-
let {
|
|
1473
|
-
min,
|
|
1474
|
-
max
|
|
1475
|
-
} = _ref15;
|
|
1476
|
-
return {
|
|
1477
|
-
min: Math.max(min - 2, 0),
|
|
1478
|
-
max: Math.min(max + 2, 100)
|
|
1479
|
-
};
|
|
1480
|
-
}
|
|
1481
|
-
},
|
|
1482
|
-
children: [/*#__PURE__*/_jsx(XAxis, {
|
|
1483
|
-
showGrid: true,
|
|
1484
|
-
showLine: true,
|
|
1485
|
-
showTickMarks: true,
|
|
1486
|
-
tickLabelFormatter: value => new Date(value).toLocaleDateString()
|
|
1487
|
-
}), /*#__PURE__*/_jsx(YAxis, {
|
|
1488
|
-
showGrid: true,
|
|
1489
|
-
showLine: true,
|
|
1490
|
-
showTickMarks: true,
|
|
1491
|
-
position: "left",
|
|
1492
|
-
tickLabelFormatter: value => value + "%"
|
|
1493
|
-
}), /*#__PURE__*/_jsx(Line, {
|
|
1494
|
-
curve: "stepAfter",
|
|
1495
|
-
points: props => _extends({}, props, {
|
|
1496
|
-
fill: theme.color.bg,
|
|
1497
|
-
stroke: props.fill
|
|
1498
|
-
}),
|
|
1499
|
-
seriesId: "availability"
|
|
1500
|
-
}), /*#__PURE__*/_jsx(Scrubber, {
|
|
1501
|
-
hideOverlay: true
|
|
1502
|
-
})]
|
|
1503
|
-
});
|
|
1504
|
-
}
|
|
1505
|
-
function ForecastAssetPrice() {
|
|
1506
|
-
const startYear = 2020;
|
|
1507
|
-
const data = useMemo(() => [50, 45, 47, 46, 54, 54, 60, 61, 63, 66, 70], []);
|
|
1508
|
-
const currentIndex = 6;
|
|
1509
|
-
const strokeWidth = 3;
|
|
1510
|
-
// To prevent cutting off the edge of our lines
|
|
1511
|
-
const clipOffset = strokeWidth;
|
|
1512
|
-
const axisFormatter = useCallback(dataIndex => {
|
|
1513
|
-
return "" + (startYear + dataIndex);
|
|
1514
|
-
}, [startYear]);
|
|
1515
|
-
const HistoricalLineComponent = /*#__PURE__*/memo(props => {
|
|
1516
|
-
const {
|
|
1517
|
-
drawingArea,
|
|
1518
|
-
getXScale
|
|
1519
|
-
} = useCartesianChartContext();
|
|
1520
|
-
const xScale = getXScale();
|
|
1521
|
-
const historicalClipPath = useMemo(() => {
|
|
1522
|
-
if (!xScale || !drawingArea) return null;
|
|
1523
|
-
const currentX = xScale(currentIndex);
|
|
1524
|
-
if (currentX === undefined) return null;
|
|
1525
|
-
|
|
1526
|
-
// Create clip path for historical data (left side)
|
|
1527
|
-
const clip = Skia.Path.Make();
|
|
1528
|
-
clip.addRect({
|
|
1529
|
-
x: drawingArea.x - clipOffset,
|
|
1530
|
-
y: drawingArea.y - clipOffset,
|
|
1531
|
-
width: currentX + clipOffset - drawingArea.x,
|
|
1532
|
-
height: drawingArea.height + clipOffset * 2
|
|
1533
|
-
});
|
|
1534
|
-
return clip;
|
|
1535
|
-
}, [xScale, drawingArea]);
|
|
1536
|
-
if (!historicalClipPath) return null;
|
|
1537
|
-
return /*#__PURE__*/_jsx(Group, {
|
|
1538
|
-
clip: historicalClipPath,
|
|
1539
|
-
children: /*#__PURE__*/_jsx(SolidLine, _extends({
|
|
1540
|
-
strokeWidth: strokeWidth
|
|
1541
|
-
}, props))
|
|
1542
|
-
});
|
|
1543
|
-
});
|
|
1544
|
-
|
|
1545
|
-
// Since the solid and dotted line have different curves,
|
|
1546
|
-
// we need two separate line components. Otherwise we could
|
|
1547
|
-
// have one line component with SolidLine and DottedLine inside
|
|
1548
|
-
// of it and two clipPaths.
|
|
1549
|
-
const ForecastLineComponent = /*#__PURE__*/memo(props => {
|
|
1550
|
-
const {
|
|
1551
|
-
drawingArea,
|
|
1552
|
-
getXScale
|
|
1553
|
-
} = useCartesianChartContext();
|
|
1554
|
-
const xScale = getXScale();
|
|
1555
|
-
const forecastClipPath = useMemo(() => {
|
|
1556
|
-
if (!xScale || !drawingArea) return null;
|
|
1557
|
-
const currentX = xScale(currentIndex);
|
|
1558
|
-
if (currentX === undefined) return null;
|
|
1559
|
-
|
|
1560
|
-
// Create clip path for forecast data (right side)
|
|
1561
|
-
const clip = Skia.Path.Make();
|
|
1562
|
-
clip.addRect({
|
|
1563
|
-
x: currentX,
|
|
1564
|
-
y: drawingArea.y - clipOffset,
|
|
1565
|
-
width: drawingArea.x + drawingArea.width - currentX + clipOffset * 2,
|
|
1566
|
-
height: drawingArea.height + clipOffset * 2
|
|
1567
|
-
});
|
|
1568
|
-
return clip;
|
|
1569
|
-
}, [xScale, drawingArea]);
|
|
1570
|
-
if (!forecastClipPath) return null;
|
|
1571
|
-
return /*#__PURE__*/_jsx(Group, {
|
|
1572
|
-
clip: forecastClipPath,
|
|
1573
|
-
children: /*#__PURE__*/_jsx(DottedLine, _extends({
|
|
1574
|
-
dashIntervals: [0, strokeWidth * 2],
|
|
1575
|
-
strokeWidth: strokeWidth
|
|
1576
|
-
}, props))
|
|
1577
|
-
});
|
|
1578
|
-
});
|
|
1579
|
-
const CustomScrubber = /*#__PURE__*/memo(() => {
|
|
1580
|
-
const {
|
|
1581
|
-
scrubberPosition
|
|
1582
|
-
} = useScrubberContext();
|
|
1583
|
-
const idleScrubberOpacity = useDerivedValue(() => scrubberPosition.value === undefined ? 1 : 0, [scrubberPosition]);
|
|
1584
|
-
const scrubberOpacity = useDerivedValue(() => scrubberPosition.value !== undefined ? 1 : 0, [scrubberPosition]);
|
|
1585
|
-
|
|
1586
|
-
// Fade in animation for the Scrubber
|
|
1587
|
-
const fadeInOpacity = useSharedValue(0);
|
|
1588
|
-
useEffect(() => {
|
|
1589
|
-
fadeInOpacity.value = withDelay(350, withTiming(1, {
|
|
1590
|
-
duration: 150
|
|
1591
|
-
}));
|
|
1592
|
-
}, [fadeInOpacity]);
|
|
1593
|
-
return /*#__PURE__*/_jsxs(Group, {
|
|
1594
|
-
opacity: fadeInOpacity,
|
|
1595
|
-
children: [/*#__PURE__*/_jsx(Group, {
|
|
1596
|
-
opacity: scrubberOpacity,
|
|
1597
|
-
children: /*#__PURE__*/_jsx(Scrubber, {
|
|
1598
|
-
hideOverlay: true
|
|
1599
|
-
})
|
|
1600
|
-
}), /*#__PURE__*/_jsx(Group, {
|
|
1601
|
-
opacity: idleScrubberOpacity,
|
|
1602
|
-
children: /*#__PURE__*/_jsx(DefaultScrubberBeacon, {
|
|
1603
|
-
isIdle: true,
|
|
1604
|
-
dataX: currentIndex,
|
|
1605
|
-
dataY: data[currentIndex],
|
|
1606
|
-
seriesId: "price"
|
|
1607
|
-
})
|
|
1608
|
-
})]
|
|
1609
|
-
});
|
|
1610
|
-
});
|
|
1611
|
-
const chartAccessibilityLabel = "Forecast chart with " + data.length + " data points. Swipe to navigate.";
|
|
1612
|
-
const getScrubberAccessibilityLabel = useCallback(index => "Point " + (index + 1) + ": " + axisFormatter(index) + ", value " + data[index], [axisFormatter, data]);
|
|
1613
|
-
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
1614
|
-
enableScrubbing: true,
|
|
1615
|
-
accessibilityLabel: chartAccessibilityLabel,
|
|
1616
|
-
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
1617
|
-
height: 200,
|
|
1618
|
-
series: [{
|
|
1619
|
-
id: 'price',
|
|
1620
|
-
data,
|
|
1621
|
-
color: assets.btc.color
|
|
1622
|
-
}],
|
|
1623
|
-
children: [/*#__PURE__*/_jsx(Line, {
|
|
1624
|
-
LineComponent: HistoricalLineComponent,
|
|
1625
|
-
curve: "linear",
|
|
1626
|
-
seriesId: "price"
|
|
1627
|
-
}), /*#__PURE__*/_jsx(Line, {
|
|
1628
|
-
LineComponent: ForecastLineComponent,
|
|
1629
|
-
curve: "monotone",
|
|
1630
|
-
seriesId: "price",
|
|
1631
|
-
type: "dotted"
|
|
1632
|
-
}), /*#__PURE__*/_jsx(XAxis, {
|
|
1633
|
-
position: "bottom",
|
|
1634
|
-
requestedTickCount: 3,
|
|
1635
|
-
tickLabelFormatter: axisFormatter
|
|
1636
|
-
}), /*#__PURE__*/_jsx(CustomScrubber, {})]
|
|
1637
|
-
});
|
|
1638
|
-
}
|
|
1639
|
-
function DataCardWithLineChart() {
|
|
1640
|
-
const {
|
|
1641
|
-
spectrum
|
|
1642
|
-
} = useTheme();
|
|
1643
|
-
const exampleThumbnail = /*#__PURE__*/_jsx(RemoteImage, {
|
|
1644
|
-
accessibilityLabel: "Ethereum",
|
|
1645
|
-
shape: "circle",
|
|
1646
|
-
size: "xl",
|
|
1647
|
-
source: ethBackground,
|
|
1648
|
-
testID: "thumbnail"
|
|
1649
|
-
});
|
|
1650
|
-
const getLineChartSeries = useCallback(() => [{
|
|
1651
|
-
id: 'price',
|
|
1652
|
-
data: prices.slice(0, 30).map(price => parseFloat(price)),
|
|
1653
|
-
color: "rgb(" + spectrum.green70 + ")"
|
|
1654
|
-
}], [spectrum.green70]);
|
|
1655
|
-
const lineChartSeries = useMemo(() => getLineChartSeries(), [getLineChartSeries]);
|
|
1656
|
-
const lineChartSeries2 = useMemo(() => getLineChartSeries(), [getLineChartSeries]);
|
|
1657
|
-
const ref = useRef(null);
|
|
1658
|
-
return /*#__PURE__*/_jsxs(VStack, {
|
|
1659
|
-
gap: 2,
|
|
1660
|
-
children: [/*#__PURE__*/_jsx(DataCard, {
|
|
1661
|
-
layout: "vertical",
|
|
1662
|
-
subtitle: "Price trend",
|
|
1663
|
-
thumbnail: exampleThumbnail,
|
|
1664
|
-
title: "Line Chart Card",
|
|
1665
|
-
children: /*#__PURE__*/_jsx(LineChart, {
|
|
1666
|
-
showArea: true,
|
|
1667
|
-
accessibilityLabel: "Ethereum price chart",
|
|
1668
|
-
areaType: "dotted",
|
|
1669
|
-
height: 120,
|
|
1670
|
-
inset: 0,
|
|
1671
|
-
series: lineChartSeries
|
|
1672
|
-
})
|
|
1673
|
-
}), /*#__PURE__*/_jsx(DataCard, {
|
|
1674
|
-
layout: "vertical",
|
|
1675
|
-
subtitle: "Price trend",
|
|
1676
|
-
thumbnail: exampleThumbnail,
|
|
1677
|
-
title: "Line Chart with Tag",
|
|
1678
|
-
titleAccessory: /*#__PURE__*/_jsx(Text, {
|
|
1679
|
-
dangerouslySetColor: "rgb(" + spectrum.green70 + ")",
|
|
1680
|
-
font: "label1",
|
|
1681
|
-
children: "\u2197 25.25%"
|
|
1682
|
-
}),
|
|
1683
|
-
children: /*#__PURE__*/_jsx(LineChart, {
|
|
1684
|
-
showArea: true,
|
|
1685
|
-
accessibilityLabel: "Ethereum price chart",
|
|
1686
|
-
areaType: "dotted",
|
|
1687
|
-
height: 100,
|
|
1688
|
-
inset: 0,
|
|
1689
|
-
series: lineChartSeries
|
|
1690
|
-
})
|
|
1691
|
-
}), /*#__PURE__*/_jsx(DataCard, {
|
|
1692
|
-
ref: ref,
|
|
1693
|
-
renderAsPressable: true,
|
|
1694
|
-
layout: "vertical",
|
|
1695
|
-
onPress: NoopFn,
|
|
1696
|
-
subtitle: "Clickable line chart card",
|
|
1697
|
-
thumbnail: exampleThumbnail,
|
|
1698
|
-
title: "Actionable Line Chart",
|
|
1699
|
-
titleAccessory: /*#__PURE__*/_jsx(Text, {
|
|
1700
|
-
dangerouslySetColor: "rgb(" + spectrum.green70 + ")",
|
|
1701
|
-
font: "label1",
|
|
1702
|
-
children: "\u2197 8.5%"
|
|
1703
|
-
}),
|
|
1704
|
-
children: /*#__PURE__*/_jsx(LineChart, {
|
|
1705
|
-
showArea: true,
|
|
1706
|
-
accessibilityLabel: "Ethereum price chart",
|
|
1707
|
-
areaType: "dotted",
|
|
1708
|
-
height: 120,
|
|
1709
|
-
inset: 0,
|
|
1710
|
-
series: lineChartSeries,
|
|
1711
|
-
showXAxis: false,
|
|
1712
|
-
showYAxis: false
|
|
1713
|
-
})
|
|
1714
|
-
}), /*#__PURE__*/_jsx(DataCard, {
|
|
1715
|
-
layout: "vertical",
|
|
1716
|
-
subtitle: "Price trend",
|
|
1717
|
-
thumbnail: /*#__PURE__*/_jsx(RemoteImage, {
|
|
1718
|
-
accessibilityLabel: "Bitcoin",
|
|
1719
|
-
shape: "circle",
|
|
1720
|
-
size: "xl",
|
|
1721
|
-
source: assets.btc.imageUrl,
|
|
1722
|
-
testID: "thumbnail"
|
|
1723
|
-
}),
|
|
1724
|
-
title: "Card with Line Chart",
|
|
1725
|
-
titleAccessory: /*#__PURE__*/_jsx(Text, {
|
|
1726
|
-
dangerouslySetColor: "rgb(" + spectrum.green70 + ")",
|
|
1727
|
-
font: "label1",
|
|
1728
|
-
children: "\u2197 25.25%"
|
|
1729
|
-
}),
|
|
1730
|
-
children: /*#__PURE__*/_jsx(LineChart, {
|
|
1731
|
-
showArea: true,
|
|
1732
|
-
accessibilityLabel: "Price chart",
|
|
1733
|
-
areaType: "dotted",
|
|
1734
|
-
height: 100,
|
|
1735
|
-
inset: 0,
|
|
1736
|
-
series: lineChartSeries2,
|
|
1737
|
-
showXAxis: false,
|
|
1738
|
-
showYAxis: false
|
|
1739
|
-
})
|
|
1740
|
-
})]
|
|
1741
|
-
});
|
|
1742
|
-
}
|
|
1743
|
-
function HorizontalLayoutLineChart() {
|
|
1744
|
-
const symbols = ['BTC', 'ETH', 'SOL', 'DOGE', 'ADA'];
|
|
1745
|
-
const allocations = [72, 46, 33, 21, 14];
|
|
1746
|
-
return /*#__PURE__*/_jsx(LineChart, {
|
|
1747
|
-
points: true,
|
|
1748
|
-
showArea: true,
|
|
1749
|
-
showXAxis: true,
|
|
1750
|
-
showYAxis: true,
|
|
1751
|
-
height: 240,
|
|
1752
|
-
layout: "horizontal",
|
|
1753
|
-
series: [{
|
|
1754
|
-
id: 'allocations',
|
|
1755
|
-
data: allocations,
|
|
1756
|
-
color: assets.btc.color
|
|
1757
|
-
}],
|
|
1758
|
-
xAxis: {
|
|
1759
|
-
domain: {
|
|
1760
|
-
min: 0,
|
|
1761
|
-
max: 80
|
|
1762
|
-
},
|
|
1763
|
-
tickLabelFormatter: value => value + "%"
|
|
1764
|
-
},
|
|
1765
|
-
yAxis: {
|
|
1766
|
-
data: symbols,
|
|
1767
|
-
scaleType: 'band'
|
|
1768
|
-
}
|
|
1769
|
-
});
|
|
1770
|
-
}
|
|
1771
|
-
function ExampleNavigator() {
|
|
1772
|
-
const theme = useTheme();
|
|
1773
|
-
const [currentIndex, setCurrentIndex] = useState(0);
|
|
1774
|
-
const examples = useMemo(() => [{
|
|
1775
|
-
title: 'Basic',
|
|
1776
|
-
component: /*#__PURE__*/_jsx(LineChart, {
|
|
1777
|
-
showArea: true,
|
|
1778
|
-
height: 200,
|
|
1779
|
-
series: [{
|
|
1780
|
-
id: 'prices',
|
|
1781
|
-
data: [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58]
|
|
1782
|
-
}]
|
|
1783
|
-
})
|
|
1784
|
-
}, {
|
|
1785
|
-
title: 'Horizontal Layout',
|
|
1786
|
-
component: /*#__PURE__*/_jsx(HorizontalLayoutLineChart, {})
|
|
1787
|
-
}, {
|
|
1788
|
-
title: 'Multiple Lines',
|
|
1789
|
-
component: /*#__PURE__*/_jsx(MultipleLine, {})
|
|
1790
|
-
}, {
|
|
1791
|
-
title: 'Data Format',
|
|
1792
|
-
component: /*#__PURE__*/_jsx(DataFormat, {})
|
|
1793
|
-
}, {
|
|
1794
|
-
title: 'Live Updates',
|
|
1795
|
-
component: /*#__PURE__*/_jsx(LiveUpdates, {})
|
|
1796
|
-
}, {
|
|
1797
|
-
title: 'Missing Data',
|
|
1798
|
-
component: /*#__PURE__*/_jsx(MissingData, {})
|
|
1799
|
-
}, {
|
|
1800
|
-
title: 'Empty State',
|
|
1801
|
-
component: /*#__PURE__*/_jsx(LineChart, {
|
|
1802
|
-
height: 200,
|
|
1803
|
-
series: [{
|
|
1804
|
-
id: 'line',
|
|
1805
|
-
color: "rgb(" + theme.spectrum.gray50 + ")",
|
|
1806
|
-
data: [1, 1],
|
|
1807
|
-
showArea: true
|
|
1808
|
-
}],
|
|
1809
|
-
yAxis: {
|
|
1810
|
-
domain: {
|
|
1811
|
-
min: -1,
|
|
1812
|
-
max: 3
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
})
|
|
1816
|
-
}, {
|
|
1817
|
-
title: 'Scales',
|
|
1818
|
-
component: /*#__PURE__*/_jsx(LineChart, {
|
|
1819
|
-
showArea: true,
|
|
1820
|
-
showYAxis: true,
|
|
1821
|
-
height: 200,
|
|
1822
|
-
series: [{
|
|
1823
|
-
id: 'prices',
|
|
1824
|
-
data: [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58]
|
|
1825
|
-
}],
|
|
1826
|
-
yAxis: {
|
|
1827
|
-
scaleType: 'log',
|
|
1828
|
-
showGrid: true,
|
|
1829
|
-
ticks: [1, 10, 100]
|
|
1830
|
-
}
|
|
1831
|
-
})
|
|
1832
|
-
}, {
|
|
1833
|
-
title: 'Interaction',
|
|
1834
|
-
component: /*#__PURE__*/_jsx(Interaction, {})
|
|
1835
|
-
}, {
|
|
1836
|
-
title: 'Points',
|
|
1837
|
-
component: /*#__PURE__*/_jsx(Points, {})
|
|
1838
|
-
}, {
|
|
1839
|
-
title: 'Transitions',
|
|
1840
|
-
component: /*#__PURE__*/_jsx(Transitions, {})
|
|
1841
|
-
}, {
|
|
1842
|
-
title: 'Basic Accessible',
|
|
1843
|
-
component: /*#__PURE__*/_jsx(BasicAccessible, {})
|
|
1844
|
-
}, {
|
|
1845
|
-
title: 'Styling Axes',
|
|
1846
|
-
component: /*#__PURE__*/_jsx(LineChart, {
|
|
1847
|
-
showArea: true,
|
|
1848
|
-
showXAxis: true,
|
|
1849
|
-
showYAxis: true,
|
|
1850
|
-
height: 200,
|
|
1851
|
-
series: [{
|
|
1852
|
-
id: 'prices',
|
|
1853
|
-
data: [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58]
|
|
1854
|
-
}],
|
|
1855
|
-
xAxis: {
|
|
1856
|
-
showGrid: true,
|
|
1857
|
-
showLine: true,
|
|
1858
|
-
showTickMarks: true,
|
|
1859
|
-
tickLabelFormatter: dataX => "Day " + dataX
|
|
1860
|
-
},
|
|
1861
|
-
yAxis: {
|
|
1862
|
-
showGrid: true,
|
|
1863
|
-
showLine: true,
|
|
1864
|
-
showTickMarks: true
|
|
1865
|
-
}
|
|
1866
|
-
})
|
|
1867
|
-
}, {
|
|
1868
|
-
title: 'Gradients',
|
|
1869
|
-
component: /*#__PURE__*/_jsx(Gradients, {})
|
|
1870
|
-
}, {
|
|
1871
|
-
title: 'Gain/Loss',
|
|
1872
|
-
component: /*#__PURE__*/_jsx(GainLossChart, {})
|
|
1873
|
-
}, {
|
|
1874
|
-
title: 'Styling Lines',
|
|
1875
|
-
component: /*#__PURE__*/_jsx(LineChart, {
|
|
1876
|
-
height: 200,
|
|
1877
|
-
series: [{
|
|
1878
|
-
id: 'top',
|
|
1879
|
-
data: [15, 28, 32, 44, 46, 36, 40, 45, 48, 38]
|
|
1880
|
-
}, {
|
|
1881
|
-
id: 'upperMiddle',
|
|
1882
|
-
data: [12, 23, 21, 29, 34, 28, 31, 38, 42, 35],
|
|
1883
|
-
color: '#ef4444',
|
|
1884
|
-
type: 'dotted'
|
|
1885
|
-
}, {
|
|
1886
|
-
id: 'lowerMiddle',
|
|
1887
|
-
data: [8, 15, 14, 25, 20, 18, 22, 28, 24, 30],
|
|
1888
|
-
color: '#f59e0b',
|
|
1889
|
-
curve: 'natural',
|
|
1890
|
-
gradient: {
|
|
1891
|
-
axis: 'x',
|
|
1892
|
-
stops: [{
|
|
1893
|
-
offset: 0,
|
|
1894
|
-
color: '#E3D74D'
|
|
1895
|
-
}, {
|
|
1896
|
-
offset: 9,
|
|
1897
|
-
color: '#F7931A'
|
|
1898
|
-
}]
|
|
1899
|
-
},
|
|
1900
|
-
strokeWidth: 6
|
|
1901
|
-
}, {
|
|
1902
|
-
id: 'bottom',
|
|
1903
|
-
data: [4, 8, 11, 15, 16, 14, 16, 10, 12, 14],
|
|
1904
|
-
color: '#800080',
|
|
1905
|
-
curve: 'step',
|
|
1906
|
-
AreaComponent: DottedArea,
|
|
1907
|
-
showArea: true
|
|
1908
|
-
}]
|
|
1909
|
-
})
|
|
1910
|
-
}, {
|
|
1911
|
-
title: 'Styling Reference Lines',
|
|
1912
|
-
component: /*#__PURE__*/_jsxs(LineChart, {
|
|
1913
|
-
enableScrubbing: true,
|
|
1914
|
-
showArea: true,
|
|
1915
|
-
accessibilityLabel: "Price chart with reference line. 14 data points. Swipe to navigate.",
|
|
1916
|
-
getScrubberAccessibilityLabel: index => "Point " + (index + 1),
|
|
1917
|
-
height: 200,
|
|
1918
|
-
series: [{
|
|
1919
|
-
id: 'prices',
|
|
1920
|
-
data: [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58],
|
|
1921
|
-
color: theme.color.fgPositive
|
|
1922
|
-
}],
|
|
1923
|
-
xAxis: {
|
|
1924
|
-
// Give space before the end of the chart for the scrubber
|
|
1925
|
-
range: _ref16 => {
|
|
1926
|
-
let {
|
|
1927
|
-
min,
|
|
1928
|
-
max
|
|
1929
|
-
} = _ref16;
|
|
1930
|
-
return {
|
|
1931
|
-
min,
|
|
1932
|
-
max: max - 24
|
|
1933
|
-
};
|
|
1934
|
-
}
|
|
1935
|
-
},
|
|
1936
|
-
children: [/*#__PURE__*/_jsx(ReferenceLine, {
|
|
1937
|
-
LineComponent: props => /*#__PURE__*/_jsx(DottedLine, _extends({}, props, {
|
|
1938
|
-
dashIntervals: [0, 16],
|
|
1939
|
-
strokeWidth: 3
|
|
1940
|
-
})),
|
|
1941
|
-
dataY: 10,
|
|
1942
|
-
stroke: theme.color.fg
|
|
1943
|
-
}), /*#__PURE__*/_jsx(Scrubber, {})]
|
|
1944
|
-
})
|
|
1945
|
-
}, {
|
|
1946
|
-
title: 'High/Low Price',
|
|
1947
|
-
component: /*#__PURE__*/_jsx(HighLowPrice, {})
|
|
1948
|
-
}, {
|
|
1949
|
-
title: 'Styling Scrubber',
|
|
1950
|
-
component: /*#__PURE__*/_jsx(StylingScrubber, {})
|
|
1951
|
-
}, {
|
|
1952
|
-
title: 'Compact',
|
|
1953
|
-
component: /*#__PURE__*/_jsx(Compact, {})
|
|
1954
|
-
}, {
|
|
1955
|
-
title: 'Asset Price With Dotted Area',
|
|
1956
|
-
component: /*#__PURE__*/_jsx(AssetPriceWithDottedArea, {})
|
|
1957
|
-
}, {
|
|
1958
|
-
title: 'Performance',
|
|
1959
|
-
component: /*#__PURE__*/_jsx(Performance, {})
|
|
1960
|
-
}, {
|
|
1961
|
-
title: 'Monotone Asset Price',
|
|
1962
|
-
component: /*#__PURE__*/_jsx(MonotoneAssetPrice, {})
|
|
1963
|
-
}, {
|
|
1964
|
-
title: 'Service Availability',
|
|
1965
|
-
component: /*#__PURE__*/_jsx(ServiceAvailability, {})
|
|
1966
|
-
}, {
|
|
1967
|
-
title: 'Forecast Asset Price',
|
|
1968
|
-
component: /*#__PURE__*/_jsx(ForecastAssetPrice, {})
|
|
1969
|
-
}, {
|
|
1970
|
-
title: 'In DataCard',
|
|
1971
|
-
component: /*#__PURE__*/_jsx(DataCardWithLineChart, {})
|
|
1972
|
-
}], [theme.color.fg, theme.color.fgPositive, theme.spectrum.gray50]);
|
|
1973
|
-
const currentExample = examples[currentIndex];
|
|
1974
|
-
const handlePrevious = useCallback(() => {
|
|
1975
|
-
setCurrentIndex(prev => (prev - 1 + examples.length) % examples.length);
|
|
1976
|
-
}, [examples.length]);
|
|
1977
|
-
const handleNext = useCallback(() => {
|
|
1978
|
-
setCurrentIndex(prev => (prev + 1 + examples.length) % examples.length);
|
|
1979
|
-
}, [examples.length]);
|
|
1980
|
-
return /*#__PURE__*/_jsx(ExampleScreen, {
|
|
1981
|
-
paddingX: 0,
|
|
1982
|
-
children: /*#__PURE__*/_jsxs(VStack, {
|
|
1983
|
-
gap: 4,
|
|
1984
|
-
children: [/*#__PURE__*/_jsxs(HStack, {
|
|
1985
|
-
alignItems: "center",
|
|
1986
|
-
justifyContent: "space-between",
|
|
1987
|
-
padding: 2,
|
|
1988
|
-
children: [/*#__PURE__*/_jsx(IconButton, {
|
|
1989
|
-
accessibilityHint: "Navigate to previous example",
|
|
1990
|
-
accessibilityLabel: "Previous",
|
|
1991
|
-
name: "arrowLeft",
|
|
1992
|
-
onPress: handlePrevious,
|
|
1993
|
-
variant: "secondary"
|
|
1994
|
-
}), /*#__PURE__*/_jsxs(VStack, {
|
|
1995
|
-
alignItems: "center",
|
|
1996
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
1997
|
-
font: "title3",
|
|
1998
|
-
children: currentExample.title
|
|
1999
|
-
}), /*#__PURE__*/_jsxs(Text, {
|
|
2000
|
-
color: "fgMuted",
|
|
2001
|
-
font: "label1",
|
|
2002
|
-
children: [currentIndex + 1, " / ", examples.length]
|
|
2003
|
-
})]
|
|
2004
|
-
}), /*#__PURE__*/_jsx(IconButton, {
|
|
2005
|
-
accessibilityHint: "Navigate to next example",
|
|
2006
|
-
accessibilityLabel: "Next",
|
|
2007
|
-
name: "arrowRight",
|
|
2008
|
-
onPress: handleNext,
|
|
2009
|
-
variant: "secondary"
|
|
2010
|
-
})]
|
|
2011
|
-
}), /*#__PURE__*/_jsx(Box, {
|
|
2012
|
-
padding: 1,
|
|
2013
|
-
children: currentExample.component
|
|
2014
|
-
})]
|
|
2015
|
-
})
|
|
2016
|
-
});
|
|
2017
|
-
}
|
|
2018
|
-
export default ExampleNavigator;
|