@coinbase/cds-mobile-visualization 3.3.0 → 3.4.0-beta.10
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 +80 -0
- package/dts/chart/CartesianChart.d.ts +125 -0
- package/dts/chart/CartesianChart.d.ts.map +1 -0
- package/dts/chart/ChartContextBridge.d.ts +28 -0
- package/dts/chart/ChartContextBridge.d.ts.map +1 -0
- package/dts/chart/ChartProvider.d.ts +6 -0
- package/dts/chart/ChartProvider.d.ts.map +1 -0
- package/dts/chart/Path.d.ts +91 -0
- package/dts/chart/Path.d.ts.map +1 -0
- package/dts/chart/PeriodSelector.d.ts +85 -0
- package/dts/chart/PeriodSelector.d.ts.map +1 -0
- package/dts/chart/area/Area.d.ts +77 -0
- package/dts/chart/area/Area.d.ts.map +1 -0
- package/dts/chart/area/AreaChart.d.ts +131 -0
- package/dts/chart/area/AreaChart.d.ts.map +1 -0
- package/dts/chart/area/DottedArea.d.ts +46 -0
- package/dts/chart/area/DottedArea.d.ts.map +1 -0
- package/dts/chart/area/GradientArea.d.ts +36 -0
- package/dts/chart/area/GradientArea.d.ts.map +1 -0
- package/dts/chart/area/SolidArea.d.ts +23 -0
- package/dts/chart/area/SolidArea.d.ts.map +1 -0
- package/dts/chart/area/index.d.ts +6 -0
- package/dts/chart/area/index.d.ts.map +1 -0
- package/dts/chart/axis/Axis.d.ts +194 -0
- package/dts/chart/axis/Axis.d.ts.map +1 -0
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
- package/dts/chart/axis/XAxis.d.ts +16 -0
- package/dts/chart/axis/XAxis.d.ts.map +1 -0
- package/dts/chart/axis/YAxis.d.ts +21 -0
- package/dts/chart/axis/YAxis.d.ts.map +1 -0
- package/dts/chart/axis/index.d.ts +5 -0
- package/dts/chart/axis/index.d.ts.map +1 -0
- package/dts/chart/bar/Bar.d.ts +92 -0
- package/dts/chart/bar/Bar.d.ts.map +1 -0
- package/dts/chart/bar/BarChart.d.ts +113 -0
- package/dts/chart/bar/BarChart.d.ts.map +1 -0
- package/dts/chart/bar/BarPlot.d.ts +30 -0
- package/dts/chart/bar/BarPlot.d.ts.map +1 -0
- package/dts/chart/bar/BarStack.d.ts +102 -0
- package/dts/chart/bar/BarStack.d.ts.map +1 -0
- package/dts/chart/bar/BarStackGroup.d.ts +36 -0
- package/dts/chart/bar/BarStackGroup.d.ts.map +1 -0
- package/dts/chart/bar/DefaultBar.d.ts +7 -0
- package/dts/chart/bar/DefaultBar.d.ts.map +1 -0
- package/dts/chart/bar/DefaultBarStack.d.ts +7 -0
- package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -0
- package/dts/chart/bar/index.d.ts +8 -0
- package/dts/chart/bar/index.d.ts.map +1 -0
- package/dts/chart/gradient/Gradient.d.ts +25 -0
- package/dts/chart/gradient/Gradient.d.ts.map +1 -0
- package/dts/chart/gradient/index.d.ts +2 -0
- package/dts/chart/gradient/index.d.ts.map +1 -0
- package/dts/chart/index.d.ts +15 -0
- package/dts/chart/index.d.ts.map +1 -0
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
- package/dts/chart/line/DottedLine.d.ts +20 -0
- package/dts/chart/line/DottedLine.d.ts.map +1 -0
- package/dts/chart/line/Line.d.ts +115 -0
- package/dts/chart/line/Line.d.ts.map +1 -0
- package/dts/chart/line/LineChart.d.ts +118 -0
- package/dts/chart/line/LineChart.d.ts.map +1 -0
- package/dts/chart/line/ReferenceLine.d.ts +139 -0
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -0
- package/dts/chart/line/SolidLine.d.ts +15 -0
- package/dts/chart/line/SolidLine.d.ts.map +1 -0
- package/dts/chart/line/index.d.ts +7 -0
- package/dts/chart/line/index.d.ts.map +1 -0
- package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
- package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
- package/dts/chart/point/Point.d.ts +120 -0
- package/dts/chart/point/Point.d.ts.map +1 -0
- package/dts/chart/point/index.d.ts +3 -0
- package/dts/chart/point/index.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +8 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +11 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/Scrubber.d.ts +233 -0
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +44 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +31 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberProvider.d.ts +20 -0
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -0
- package/dts/chart/scrubber/index.d.ts +5 -0
- package/dts/chart/scrubber/index.d.ts.map +1 -0
- package/dts/chart/text/ChartText.d.ts +164 -0
- package/dts/chart/text/ChartText.d.ts.map +1 -0
- package/dts/chart/text/ChartTextGroup.d.ts +61 -0
- package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
- package/dts/chart/text/index.d.ts +3 -0
- package/dts/chart/text/index.d.ts.map +1 -0
- package/dts/chart/utils/axis.d.ts +342 -0
- package/dts/chart/utils/axis.d.ts.map +1 -0
- package/dts/chart/utils/bar.d.ts +20 -0
- package/dts/chart/utils/bar.d.ts.map +1 -0
- package/dts/chart/utils/chart.d.ts +124 -0
- package/dts/chart/utils/chart.d.ts.map +1 -0
- package/dts/chart/utils/context.d.ts +116 -0
- package/dts/chart/utils/context.d.ts.map +1 -0
- package/dts/chart/utils/gradient.d.ts +117 -0
- package/dts/chart/utils/gradient.d.ts.map +1 -0
- package/dts/chart/utils/index.d.ts +11 -0
- package/dts/chart/utils/index.d.ts.map +1 -0
- package/dts/chart/utils/path.d.ts +160 -0
- package/dts/chart/utils/path.d.ts.map +1 -0
- package/dts/chart/utils/point.d.ts +134 -0
- package/dts/chart/utils/point.d.ts.map +1 -0
- package/dts/chart/utils/scale.d.ts +134 -0
- package/dts/chart/utils/scale.d.ts.map +1 -0
- package/dts/chart/utils/scrubber.d.ts +39 -0
- package/dts/chart/utils/scrubber.d.ts.map +1 -0
- package/dts/chart/utils/transition.d.ts +140 -0
- package/dts/chart/utils/transition.d.ts.map +1 -0
- package/dts/index.d.ts +2 -1
- package/dts/index.d.ts.map +1 -1
- package/dts/sparkline/Counter.d.ts +7 -2
- package/dts/sparkline/Sparkline.d.ts +67 -16
- package/dts/sparkline/Sparkline.d.ts.map +1 -1
- package/dts/sparkline/SparklineArea.d.ts +10 -4
- package/dts/sparkline/SparklineArea.d.ts.map +1 -1
- package/dts/sparkline/SparklineAreaPattern.d.ts +12 -4
- package/dts/sparkline/SparklineAreaPattern.d.ts.map +1 -1
- package/dts/sparkline/SparklineGradient.d.ts +21 -10
- package/dts/sparkline/SparklineGradient.d.ts.map +1 -1
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts +1 -1
- package/dts/sparkline/generateSparklineWithId.d.ts +8 -2
- package/dts/sparkline/generateSparklineWithId.d.ts.map +1 -1
- package/dts/sparkline/index.d.ts +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts +8 -3
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +132 -110
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +22 -9
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +18 -7
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +9 -4
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +11 -6
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts +7 -5
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts +22 -10
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +21 -7
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +21 -16
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +29 -23
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +22 -14
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +1 -1
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts +9 -5
- package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts +11 -6
- package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts +5 -2
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +17 -17
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts +16 -13
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +106 -98
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +1 -1
- package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts +22 -19
- package/esm/chart/CartesianChart.js +335 -0
- package/esm/chart/ChartContextBridge.js +148 -0
- package/esm/chart/ChartProvider.js +10 -0
- package/esm/chart/Path.js +218 -0
- package/esm/chart/PeriodSelector.js +136 -0
- package/esm/chart/__stories__/CartesianChart.stories.js +723 -0
- package/esm/chart/__stories__/Chart.stories.js +77 -0
- package/esm/chart/__stories__/PeriodSelector.stories.js +322 -0
- package/esm/chart/area/Area.js +75 -0
- package/esm/chart/area/AreaChart.js +151 -0
- package/esm/chart/area/DottedArea.js +80 -0
- package/esm/chart/area/GradientArea.js +54 -0
- package/esm/chart/area/SolidArea.js +38 -0
- package/esm/chart/area/__stories__/AreaChart.stories.js +100 -0
- package/esm/chart/area/index.js +7 -0
- package/esm/chart/axis/Axis.js +45 -0
- package/esm/chart/axis/DefaultAxisTickLabel.js +11 -0
- package/esm/chart/axis/XAxis.js +188 -0
- package/esm/chart/axis/YAxis.js +177 -0
- package/esm/chart/axis/__stories__/Axis.stories.js +276 -0
- package/esm/chart/axis/index.js +6 -0
- package/esm/chart/bar/Bar.js +69 -0
- package/esm/chart/bar/BarChart.js +125 -0
- package/esm/chart/bar/BarPlot.js +102 -0
- package/esm/chart/bar/BarStack.js +551 -0
- package/esm/chart/bar/BarStackGroup.js +79 -0
- package/esm/chart/bar/DefaultBar.js +56 -0
- package/esm/chart/bar/DefaultBarStack.js +47 -0
- package/esm/chart/bar/__stories__/BarChart.stories.js +668 -0
- package/esm/chart/bar/index.js +9 -0
- package/esm/chart/gradient/Gradient.js +53 -0
- package/esm/chart/gradient/index.js +1 -0
- package/esm/chart/index.js +16 -0
- package/esm/chart/line/DefaultReferenceLineLabel.js +66 -0
- package/esm/chart/line/DottedLine.js +50 -0
- package/esm/chart/line/Line.js +178 -0
- package/esm/chart/line/LineChart.js +121 -0
- package/esm/chart/line/ReferenceLine.js +132 -0
- package/esm/chart/line/SolidLine.js +46 -0
- package/esm/chart/line/__stories__/LineChart.stories.js +2372 -0
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +132 -0
- package/esm/chart/line/index.js +8 -0
- package/esm/chart/point/DefaultPointLabel.js +39 -0
- package/esm/chart/point/Point.js +188 -0
- package/esm/chart/point/index.js +2 -0
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +179 -0
- package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +43 -0
- package/esm/chart/scrubber/DefaultScrubberLabel.js +28 -0
- package/esm/chart/scrubber/Scrubber.js +166 -0
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +161 -0
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +185 -0
- package/esm/chart/scrubber/ScrubberProvider.js +135 -0
- package/esm/chart/scrubber/index.js +4 -0
- package/esm/chart/text/ChartText.js +305 -0
- package/esm/chart/text/ChartTextGroup.js +211 -0
- package/esm/chart/text/index.js +4 -0
- package/esm/chart/utils/axis.js +592 -0
- package/esm/chart/utils/bar.js +24 -0
- package/esm/chart/utils/chart.js +270 -0
- package/esm/chart/utils/context.js +15 -0
- package/esm/chart/utils/gradient.js +305 -0
- package/esm/chart/utils/index.js +12 -0
- package/esm/chart/utils/path.js +274 -0
- package/esm/chart/utils/point.js +229 -0
- package/esm/chart/utils/scale.js +277 -0
- package/esm/chart/utils/scrubber.js +139 -0
- package/esm/chart/utils/transition.js +185 -0
- package/esm/index.js +4 -1
- package/esm/sparkline/Sparkline.js +129 -16
- package/esm/sparkline/SparklineArea.js +7 -2
- package/esm/sparkline/SparklineAreaPattern.js +4 -2
- package/esm/sparkline/SparklineGradient.js +4 -0
- package/esm/sparkline/__stories__/Sparkline.stories.js +11 -7
- package/esm/sparkline/__stories__/SparklineGradient.stories.js +7 -4
- package/esm/sparkline/generateSparklineWithId.js +3 -2
- package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +5 -1
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +5 -2
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +4 -0
- package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +76 -24
- package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +17 -9
- package/package.json +17 -11
- package/dts/sparkline/__stories__/Sparkline.stories.d.ts +0 -3
- package/dts/sparkline/__stories__/Sparkline.stories.d.ts.map +0 -1
- package/dts/sparkline/__stories__/SparklineGradient.stories.d.ts +0 -3
- package/dts/sparkline/__stories__/SparklineGradient.stories.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts +0 -3
- package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveHoverDate.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveHoverDate.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePanGestureHandler.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePanGestureHandler.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveTimeseriesPaths.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveTimeseriesPaths.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/useMinMaxTransform.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/useMinMaxTransform.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts +0 -4
- package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/__tests__/useSparklineInteractiveHeaderStyles.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive-header/__tests__/useSparklineInteractiveHeaderStyles.test.d.ts.map +0 -1
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import { memo, useCallback, useMemo, useState } from 'react';
|
|
3
|
+
import { Image, ScrollView, StyleSheet } from 'react-native';
|
|
4
|
+
import { assets } from '@coinbase/cds-common/internal/data/assets';
|
|
5
|
+
import { candles as btcCandles } from '@coinbase/cds-common/internal/data/candles';
|
|
6
|
+
import { Example, ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
|
|
7
|
+
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
8
|
+
import { Box, HStack, VStack } from '@coinbase/cds-mobile/layout';
|
|
9
|
+
import { Text } from '@coinbase/cds-mobile/typography';
|
|
10
|
+
import { Circle, Group, Skia } from '@shopify/react-native-skia';
|
|
11
|
+
import { Area } from '../area/Area';
|
|
12
|
+
import { XAxis, YAxis } from '../axis';
|
|
13
|
+
import { BarPlot } from '../bar/BarPlot';
|
|
14
|
+
import { useCartesianChartContext } from '../ChartProvider';
|
|
15
|
+
import { Line } from '../line/Line';
|
|
16
|
+
import { Point } from '../point/Point';
|
|
17
|
+
import { Scrubber } from '../scrubber/Scrubber';
|
|
18
|
+
import { ChartText } from '../text';
|
|
19
|
+
import { isCategoricalScale } from '../utils';
|
|
20
|
+
import { CartesianChart, DottedArea, ReferenceLine, SolidLine } from '../';
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
const defaultChartHeight = 250;
|
|
23
|
+
const LineStyles = () => {
|
|
24
|
+
const topChartData = [15, 28, 32, 44, 46, 36, 40, 45, 48, 38];
|
|
25
|
+
const upperMiddleChartData = [12, 23, 21, 29, 34, 28, 31, 38, 42, 35];
|
|
26
|
+
const lowerMiddleChartData = [8, 15, 14, 25, 20, 18, 22, 28, 24, 30];
|
|
27
|
+
const bottomChartData = [4, 8, 11, 15, 16, 14, 16, 10, 12, 14];
|
|
28
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
29
|
+
height: defaultChartHeight,
|
|
30
|
+
series: [{
|
|
31
|
+
id: 'top',
|
|
32
|
+
data: topChartData
|
|
33
|
+
}, {
|
|
34
|
+
id: 'upperMiddle',
|
|
35
|
+
data: upperMiddleChartData,
|
|
36
|
+
color: '#ef4444'
|
|
37
|
+
}, {
|
|
38
|
+
id: 'lowerMiddle',
|
|
39
|
+
data: lowerMiddleChartData,
|
|
40
|
+
color: '#f59e0b'
|
|
41
|
+
}, {
|
|
42
|
+
id: 'bottom',
|
|
43
|
+
data: bottomChartData,
|
|
44
|
+
color: '#800080'
|
|
45
|
+
}],
|
|
46
|
+
children: [/*#__PURE__*/_jsx(Line, {
|
|
47
|
+
seriesId: "top"
|
|
48
|
+
}), /*#__PURE__*/_jsx(Line, {
|
|
49
|
+
seriesId: "upperMiddle",
|
|
50
|
+
type: "dotted"
|
|
51
|
+
}), /*#__PURE__*/_jsx(Line, {
|
|
52
|
+
LineComponent: lineProps => /*#__PURE__*/_jsx(SolidLine, _extends({}, lineProps, {
|
|
53
|
+
strokeWidth: 4
|
|
54
|
+
})),
|
|
55
|
+
curve: "natural",
|
|
56
|
+
seriesId: "lowerMiddle"
|
|
57
|
+
}), /*#__PURE__*/_jsx(Line, {
|
|
58
|
+
showArea: true,
|
|
59
|
+
AreaComponent: DottedArea,
|
|
60
|
+
curve: "step",
|
|
61
|
+
seriesId: "bottom"
|
|
62
|
+
})]
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
const MultipleChart = () => {
|
|
66
|
+
const barData = [1, 2, 3, 2, 1];
|
|
67
|
+
const lineData = [4, 3, 1, 3, 4];
|
|
68
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
69
|
+
height: defaultChartHeight,
|
|
70
|
+
series: [{
|
|
71
|
+
id: 'bar',
|
|
72
|
+
data: barData
|
|
73
|
+
}, {
|
|
74
|
+
id: 'line',
|
|
75
|
+
data: lineData
|
|
76
|
+
}],
|
|
77
|
+
children: [/*#__PURE__*/_jsx(Area, {
|
|
78
|
+
seriesId: "bar",
|
|
79
|
+
type: "dotted"
|
|
80
|
+
}), /*#__PURE__*/_jsx(Line, {
|
|
81
|
+
curve: "natural",
|
|
82
|
+
seriesId: "line"
|
|
83
|
+
})]
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const EarningsHistory = () => {
|
|
87
|
+
const theme = useTheme();
|
|
88
|
+
const CirclePlot = /*#__PURE__*/memo(_ref => {
|
|
89
|
+
let {
|
|
90
|
+
seriesId,
|
|
91
|
+
opacity = 1
|
|
92
|
+
} = _ref;
|
|
93
|
+
const {
|
|
94
|
+
getSeries,
|
|
95
|
+
getSeriesData,
|
|
96
|
+
getXScale,
|
|
97
|
+
getYScale
|
|
98
|
+
} = useCartesianChartContext();
|
|
99
|
+
const series = getSeries(seriesId);
|
|
100
|
+
const data = getSeriesData(seriesId);
|
|
101
|
+
const xScale = getXScale();
|
|
102
|
+
const yScale = getYScale(series == null ? void 0 : series.yAxisId);
|
|
103
|
+
if (!xScale || !yScale || !data || !isCategoricalScale(xScale)) return null;
|
|
104
|
+
const yScaleSize = Math.abs(yScale.range()[1] - yScale.range()[0]);
|
|
105
|
+
|
|
106
|
+
// Have circle diameter be the smaller of the x scale bandwidth or 10% of the y space available
|
|
107
|
+
const diameter = Math.min(xScale.bandwidth(), yScaleSize / 10);
|
|
108
|
+
return /*#__PURE__*/_jsx(Group, {
|
|
109
|
+
children: data.map((value, index) => {
|
|
110
|
+
if (value === null || value === undefined) return null;
|
|
111
|
+
|
|
112
|
+
// Get x position from band scale - center of the band
|
|
113
|
+
const xPos = xScale(index);
|
|
114
|
+
if (xPos === undefined) return null;
|
|
115
|
+
const centerX = xPos + xScale.bandwidth() / 2;
|
|
116
|
+
|
|
117
|
+
// Get y position from value
|
|
118
|
+
const yValue = Array.isArray(value) ? value[1] : value;
|
|
119
|
+
const centerY = yScale(yValue);
|
|
120
|
+
if (centerY === undefined) return null;
|
|
121
|
+
return /*#__PURE__*/_jsx(Circle, {
|
|
122
|
+
color: (series == null ? void 0 : series.color) || theme.color.fgPrimary,
|
|
123
|
+
cx: centerX,
|
|
124
|
+
cy: centerY,
|
|
125
|
+
opacity: opacity,
|
|
126
|
+
r: diameter / 2
|
|
127
|
+
}, seriesId + "-" + index);
|
|
128
|
+
})
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
const quarters = useMemo(() => ['Q1', 'Q2', 'Q3', 'Q4'], []);
|
|
132
|
+
const estimatedEPS = useMemo(() => [1.71, 1.82, 1.93, 2.34], []);
|
|
133
|
+
const actualEPS = useMemo(() => [1.68, 1.83, 2.01, 2.24], []);
|
|
134
|
+
const formatEarningAmount = useCallback(value => {
|
|
135
|
+
return "$" + value.toLocaleString('en-US', {
|
|
136
|
+
minimumFractionDigits: 2,
|
|
137
|
+
maximumFractionDigits: 2
|
|
138
|
+
});
|
|
139
|
+
}, []);
|
|
140
|
+
const surprisePercentage = useCallback(index => {
|
|
141
|
+
const percentage = (actualEPS[index] - estimatedEPS[index]) / estimatedEPS[index];
|
|
142
|
+
const percentageString = percentage.toLocaleString('en-US', {
|
|
143
|
+
style: 'percent',
|
|
144
|
+
minimumFractionDigits: 2,
|
|
145
|
+
maximumFractionDigits: 2
|
|
146
|
+
});
|
|
147
|
+
const prefix = percentage > 0 ? '+' : '';
|
|
148
|
+
return "" + prefix + percentageString;
|
|
149
|
+
}, [actualEPS, estimatedEPS]);
|
|
150
|
+
const styles = StyleSheet.create({
|
|
151
|
+
legendDot: {
|
|
152
|
+
width: 10,
|
|
153
|
+
height: 10,
|
|
154
|
+
borderRadius: 1000,
|
|
155
|
+
backgroundColor: theme.color.bgPositive
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
const LegendItem = /*#__PURE__*/memo(_ref2 => {
|
|
159
|
+
let {
|
|
160
|
+
opacity = 1,
|
|
161
|
+
label
|
|
162
|
+
} = _ref2;
|
|
163
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
164
|
+
alignItems: "center",
|
|
165
|
+
flexDirection: "row",
|
|
166
|
+
gap: 0.5,
|
|
167
|
+
children: [/*#__PURE__*/_jsx(Box, {
|
|
168
|
+
style: [styles.legendDot, {
|
|
169
|
+
opacity
|
|
170
|
+
}]
|
|
171
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
172
|
+
font: "label2",
|
|
173
|
+
children: label
|
|
174
|
+
})]
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
178
|
+
gap: 0.5,
|
|
179
|
+
children: [/*#__PURE__*/_jsxs(CartesianChart, {
|
|
180
|
+
height: defaultChartHeight,
|
|
181
|
+
inset: {
|
|
182
|
+
top: 32,
|
|
183
|
+
bottom: 0,
|
|
184
|
+
left: 0,
|
|
185
|
+
right: 0
|
|
186
|
+
},
|
|
187
|
+
series: [{
|
|
188
|
+
id: 'estimatedEPS',
|
|
189
|
+
data: estimatedEPS,
|
|
190
|
+
color: theme.color.bgPositive
|
|
191
|
+
}, {
|
|
192
|
+
id: 'actualEPS',
|
|
193
|
+
data: actualEPS,
|
|
194
|
+
color: theme.color.bgPositive
|
|
195
|
+
}],
|
|
196
|
+
xAxis: {
|
|
197
|
+
scaleType: 'band',
|
|
198
|
+
categoryPadding: 0.25
|
|
199
|
+
},
|
|
200
|
+
children: [/*#__PURE__*/_jsx(YAxis, {
|
|
201
|
+
showGrid: true,
|
|
202
|
+
position: "left",
|
|
203
|
+
requestedTickCount: 3,
|
|
204
|
+
tickLabelFormatter: formatEarningAmount
|
|
205
|
+
}), /*#__PURE__*/_jsx(XAxis, {
|
|
206
|
+
height: 20,
|
|
207
|
+
tickLabelFormatter: index => quarters[index]
|
|
208
|
+
}), /*#__PURE__*/_jsx(XAxis, {
|
|
209
|
+
height: 20,
|
|
210
|
+
tickLabelFormatter: surprisePercentage
|
|
211
|
+
}), /*#__PURE__*/_jsx(CirclePlot, {
|
|
212
|
+
opacity: 0.5,
|
|
213
|
+
seriesId: "estimatedEPS"
|
|
214
|
+
}), /*#__PURE__*/_jsx(CirclePlot, {
|
|
215
|
+
seriesId: "actualEPS"
|
|
216
|
+
})]
|
|
217
|
+
}), /*#__PURE__*/_jsxs(HStack, {
|
|
218
|
+
gap: 2,
|
|
219
|
+
justifyContent: "flex-end",
|
|
220
|
+
children: [/*#__PURE__*/_jsx(LegendItem, {
|
|
221
|
+
label: "Estimated EPS",
|
|
222
|
+
opacity: 0.5
|
|
223
|
+
}), /*#__PURE__*/_jsx(LegendItem, {
|
|
224
|
+
label: "Actual EPS"
|
|
225
|
+
})]
|
|
226
|
+
})]
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
const btcData = btcCandles.slice(0, 180).reverse();
|
|
230
|
+
const btcPrices = btcData.map(candle => parseFloat(candle.close));
|
|
231
|
+
const btcVolumes = btcData.map(candle => parseFloat(candle.volume));
|
|
232
|
+
const btcDates = btcData.map(candle => new Date(parseInt(candle.start) * 1000));
|
|
233
|
+
const displayIndex = btcPrices.length - 1;
|
|
234
|
+
const currentPrice = btcPrices[displayIndex];
|
|
235
|
+
const currentDate = btcDates[displayIndex];
|
|
236
|
+
const PriceWithVolumeChart = /*#__PURE__*/memo(_ref3 => {
|
|
237
|
+
let {
|
|
238
|
+
onScrubberPositionChange
|
|
239
|
+
} = _ref3;
|
|
240
|
+
const theme = useTheme();
|
|
241
|
+
const formatPriceInThousands = useCallback(price => {
|
|
242
|
+
return "$" + (price / 1000).toLocaleString('en-US', {
|
|
243
|
+
minimumFractionDigits: 0,
|
|
244
|
+
maximumFractionDigits: 2
|
|
245
|
+
}) + "k";
|
|
246
|
+
}, []);
|
|
247
|
+
const formatDate = useCallback(date => {
|
|
248
|
+
return date.toLocaleDateString('en-US', {
|
|
249
|
+
month: 'short',
|
|
250
|
+
day: 'numeric'
|
|
251
|
+
});
|
|
252
|
+
}, []);
|
|
253
|
+
const scrubberLabel = useCallback(dataIndex => {
|
|
254
|
+
return formatDate(btcDates[dataIndex]);
|
|
255
|
+
}, [formatDate]);
|
|
256
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
257
|
+
enableScrubbing: true,
|
|
258
|
+
height: defaultChartHeight,
|
|
259
|
+
onScrubberPositionChange: onScrubberPositionChange,
|
|
260
|
+
series: [{
|
|
261
|
+
id: 'prices',
|
|
262
|
+
data: btcPrices,
|
|
263
|
+
color: assets.btc.color,
|
|
264
|
+
yAxisId: 'price'
|
|
265
|
+
}, {
|
|
266
|
+
id: 'volume',
|
|
267
|
+
data: btcVolumes,
|
|
268
|
+
color: theme.color.fgMuted,
|
|
269
|
+
yAxisId: 'volume'
|
|
270
|
+
}],
|
|
271
|
+
xAxis: {
|
|
272
|
+
scaleType: 'band',
|
|
273
|
+
range: _ref4 => {
|
|
274
|
+
let {
|
|
275
|
+
min,
|
|
276
|
+
max
|
|
277
|
+
} = _ref4;
|
|
278
|
+
return {
|
|
279
|
+
min,
|
|
280
|
+
max: max - 8
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
yAxis: [{
|
|
285
|
+
id: 'price',
|
|
286
|
+
domain: _ref5 => {
|
|
287
|
+
let {
|
|
288
|
+
min,
|
|
289
|
+
max
|
|
290
|
+
} = _ref5;
|
|
291
|
+
return {
|
|
292
|
+
min: min * 0.9,
|
|
293
|
+
max
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}, {
|
|
297
|
+
id: 'volume',
|
|
298
|
+
range: _ref6 => {
|
|
299
|
+
let {
|
|
300
|
+
min,
|
|
301
|
+
max
|
|
302
|
+
} = _ref6;
|
|
303
|
+
return {
|
|
304
|
+
min: max - 32,
|
|
305
|
+
max
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
}],
|
|
309
|
+
children: [/*#__PURE__*/_jsx(YAxis, {
|
|
310
|
+
showGrid: true,
|
|
311
|
+
axisId: "price",
|
|
312
|
+
tickLabelFormatter: formatPriceInThousands,
|
|
313
|
+
width: 20
|
|
314
|
+
}), /*#__PURE__*/_jsx(BarPlot, {
|
|
315
|
+
seriesIds: ['volume']
|
|
316
|
+
}), /*#__PURE__*/_jsx(Line, {
|
|
317
|
+
showArea: true,
|
|
318
|
+
seriesId: "prices"
|
|
319
|
+
}), /*#__PURE__*/_jsx(Scrubber, {
|
|
320
|
+
label: scrubberLabel,
|
|
321
|
+
seriesIds: ['prices']
|
|
322
|
+
})]
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
const PriceWithVolumeHeader = /*#__PURE__*/memo(_ref7 => {
|
|
326
|
+
let {
|
|
327
|
+
currentIndex
|
|
328
|
+
} = _ref7;
|
|
329
|
+
const theme = useTheme();
|
|
330
|
+
const formatPrice = useCallback(price => {
|
|
331
|
+
return "$" + price.toLocaleString('en-US', {
|
|
332
|
+
minimumFractionDigits: 2,
|
|
333
|
+
maximumFractionDigits: 2
|
|
334
|
+
});
|
|
335
|
+
}, []);
|
|
336
|
+
const formatDate = useCallback(date => {
|
|
337
|
+
return date.toLocaleDateString('en-US', {
|
|
338
|
+
month: 'short',
|
|
339
|
+
day: 'numeric'
|
|
340
|
+
});
|
|
341
|
+
}, []);
|
|
342
|
+
const formatVolume = useCallback(volume => {
|
|
343
|
+
return (volume / 1000).toFixed(2) + "K";
|
|
344
|
+
}, []);
|
|
345
|
+
const volumeText = useMemo(() => {
|
|
346
|
+
return formatVolume(currentIndex !== undefined ? btcVolumes[currentIndex] : btcVolumes[displayIndex]);
|
|
347
|
+
}, [currentIndex, formatVolume]);
|
|
348
|
+
return /*#__PURE__*/_jsxs(HStack, {
|
|
349
|
+
gap: 2,
|
|
350
|
+
justifyContent: "space-between",
|
|
351
|
+
paddingX: 0,
|
|
352
|
+
children: [/*#__PURE__*/_jsxs(VStack, {
|
|
353
|
+
gap: 0,
|
|
354
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
355
|
+
font: "title1",
|
|
356
|
+
children: "Bitcoin"
|
|
357
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
358
|
+
font: "title2",
|
|
359
|
+
children: formatPrice(currentPrice)
|
|
360
|
+
})]
|
|
361
|
+
}), /*#__PURE__*/_jsxs(HStack, {
|
|
362
|
+
gap: 2,
|
|
363
|
+
children: [/*#__PURE__*/_jsxs(VStack, {
|
|
364
|
+
alignItems: "flex-end",
|
|
365
|
+
justifyContent: "center",
|
|
366
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
367
|
+
font: "label1",
|
|
368
|
+
children: formatDate(currentDate)
|
|
369
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
370
|
+
font: "label2",
|
|
371
|
+
children: volumeText
|
|
372
|
+
})]
|
|
373
|
+
}), /*#__PURE__*/_jsx(VStack, {
|
|
374
|
+
justifyContent: "center",
|
|
375
|
+
children: /*#__PURE__*/_jsx(Image, {
|
|
376
|
+
source: {
|
|
377
|
+
uri: assets.btc.imageUrl
|
|
378
|
+
},
|
|
379
|
+
style: {
|
|
380
|
+
width: theme.iconSize.l,
|
|
381
|
+
height: theme.iconSize.l,
|
|
382
|
+
borderRadius: 1000
|
|
383
|
+
}
|
|
384
|
+
})
|
|
385
|
+
})]
|
|
386
|
+
})]
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
const PriceWithVolume = /*#__PURE__*/memo(() => {
|
|
390
|
+
const [currentIndex, setCurrentIndex] = useState();
|
|
391
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
392
|
+
gap: 2,
|
|
393
|
+
children: [/*#__PURE__*/_jsx(PriceWithVolumeHeader, {
|
|
394
|
+
currentIndex: currentIndex
|
|
395
|
+
}), /*#__PURE__*/_jsx(PriceWithVolumeChart, {
|
|
396
|
+
onScrubberPositionChange: setCurrentIndex
|
|
397
|
+
})]
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
function TradingTrends() {
|
|
401
|
+
const theme = useTheme();
|
|
402
|
+
const profitData = [34, 24, 28, -4, 8, -16, -3, 12, 24, 18, 20, 28];
|
|
403
|
+
const gains = profitData.map(value => value > 0 ? value : 0);
|
|
404
|
+
const losses = profitData.map(value => value < 0 ? value : 0);
|
|
405
|
+
const renderProfit = useCallback(value => {
|
|
406
|
+
return "$" + value + "M";
|
|
407
|
+
}, []);
|
|
408
|
+
const ThinSolidLine = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(SolidLine, _extends({}, props, {
|
|
409
|
+
strokeWidth: 1
|
|
410
|
+
})));
|
|
411
|
+
const ThickSolidLine = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(SolidLine, _extends({}, props, {
|
|
412
|
+
strokeWidth: 2
|
|
413
|
+
})));
|
|
414
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
415
|
+
height: 250,
|
|
416
|
+
series: [{
|
|
417
|
+
id: 'gains',
|
|
418
|
+
data: gains,
|
|
419
|
+
yAxisId: 'profit',
|
|
420
|
+
color: theme.color.bgPositive,
|
|
421
|
+
stackId: 'bars'
|
|
422
|
+
}, {
|
|
423
|
+
id: 'losses',
|
|
424
|
+
data: losses,
|
|
425
|
+
yAxisId: 'profit',
|
|
426
|
+
color: theme.color.bgNegative,
|
|
427
|
+
stackId: 'bars'
|
|
428
|
+
}, {
|
|
429
|
+
id: 'revenue',
|
|
430
|
+
data: [128, 118, 122, 116, 120, 114, 118, 122, 126, 130, 134, 138],
|
|
431
|
+
yAxisId: 'revenue',
|
|
432
|
+
color: theme.color.fgMuted
|
|
433
|
+
}],
|
|
434
|
+
xAxis: {
|
|
435
|
+
scaleType: 'band',
|
|
436
|
+
data: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
|
437
|
+
},
|
|
438
|
+
yAxis: [{
|
|
439
|
+
id: 'profit',
|
|
440
|
+
range: _ref8 => {
|
|
441
|
+
let {
|
|
442
|
+
min,
|
|
443
|
+
max
|
|
444
|
+
} = _ref8;
|
|
445
|
+
return {
|
|
446
|
+
min: min,
|
|
447
|
+
max: max - 64
|
|
448
|
+
};
|
|
449
|
+
},
|
|
450
|
+
domain: {
|
|
451
|
+
min: -40,
|
|
452
|
+
max: 40
|
|
453
|
+
}
|
|
454
|
+
}, {
|
|
455
|
+
id: 'revenue',
|
|
456
|
+
range: _ref9 => {
|
|
457
|
+
let {
|
|
458
|
+
min,
|
|
459
|
+
max
|
|
460
|
+
} = _ref9;
|
|
461
|
+
return {
|
|
462
|
+
min: max - 64,
|
|
463
|
+
max
|
|
464
|
+
};
|
|
465
|
+
},
|
|
466
|
+
domain: {
|
|
467
|
+
min: 100
|
|
468
|
+
}
|
|
469
|
+
}],
|
|
470
|
+
children: [/*#__PURE__*/_jsx(YAxis, {
|
|
471
|
+
showGrid: true,
|
|
472
|
+
GridLineComponent: ThinSolidLine,
|
|
473
|
+
axisId: "profit",
|
|
474
|
+
position: "left",
|
|
475
|
+
tickLabelFormatter: renderProfit
|
|
476
|
+
}), /*#__PURE__*/_jsx(XAxis, {}), /*#__PURE__*/_jsx(ReferenceLine, {
|
|
477
|
+
LineComponent: ThickSolidLine,
|
|
478
|
+
dataY: 0,
|
|
479
|
+
yAxisId: "profit"
|
|
480
|
+
}), /*#__PURE__*/_jsx(BarPlot, {
|
|
481
|
+
seriesIds: ['gains', 'losses']
|
|
482
|
+
}), /*#__PURE__*/_jsx(Line, {
|
|
483
|
+
showArea: true,
|
|
484
|
+
seriesId: "revenue"
|
|
485
|
+
})]
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
const UVGradient = {
|
|
489
|
+
axis: 'y',
|
|
490
|
+
stops: [{
|
|
491
|
+
offset: 0,
|
|
492
|
+
color: 'green'
|
|
493
|
+
}, {
|
|
494
|
+
offset: 3,
|
|
495
|
+
color: 'yellow'
|
|
496
|
+
}, {
|
|
497
|
+
offset: 5,
|
|
498
|
+
color: 'orange'
|
|
499
|
+
}, {
|
|
500
|
+
offset: 8,
|
|
501
|
+
color: 'red'
|
|
502
|
+
}, {
|
|
503
|
+
offset: 10,
|
|
504
|
+
color: 'purple'
|
|
505
|
+
}]
|
|
506
|
+
};
|
|
507
|
+
const PreviousData = /*#__PURE__*/memo(_ref0 => {
|
|
508
|
+
let {
|
|
509
|
+
children,
|
|
510
|
+
currentHour,
|
|
511
|
+
clipOffset = 0
|
|
512
|
+
} = _ref0;
|
|
513
|
+
// we will clip the data to the current hour
|
|
514
|
+
const {
|
|
515
|
+
drawingArea,
|
|
516
|
+
getXScale
|
|
517
|
+
} = useCartesianChartContext();
|
|
518
|
+
const xScale = getXScale();
|
|
519
|
+
const currentHourX = xScale == null ? void 0 : xScale(currentHour);
|
|
520
|
+
const clipPath = useMemo(() => {
|
|
521
|
+
if (!xScale || currentHourX === undefined) return null;
|
|
522
|
+
|
|
523
|
+
// Create a rectangle from top-left of drawing area to currentHourX on the right
|
|
524
|
+
// Apply clipOffset to left, top, and bottom edges only (NOT to currentHourX)
|
|
525
|
+
const pathString = "M " + (drawingArea.x - clipOffset) + " " + (drawingArea.y - clipOffset) + " L " + currentHourX + " " + (drawingArea.y - clipOffset) + " L " + currentHourX + " " + (drawingArea.y + drawingArea.height + clipOffset) + " L " + (drawingArea.x - clipOffset) + " " + (drawingArea.y + drawingArea.height + clipOffset) + " Z";
|
|
526
|
+
return Skia.Path.MakeFromSVGString(pathString);
|
|
527
|
+
}, [xScale, currentHourX, drawingArea, clipOffset]);
|
|
528
|
+
if (!clipPath) return null;
|
|
529
|
+
return /*#__PURE__*/_jsx(Group, {
|
|
530
|
+
clip: clipPath,
|
|
531
|
+
opacity: 0.75,
|
|
532
|
+
children: children
|
|
533
|
+
});
|
|
534
|
+
});
|
|
535
|
+
const FutureData = /*#__PURE__*/memo(_ref1 => {
|
|
536
|
+
let {
|
|
537
|
+
children,
|
|
538
|
+
currentHour,
|
|
539
|
+
clipOffset = 0
|
|
540
|
+
} = _ref1;
|
|
541
|
+
// we will clip the data from the current hour to the right edge
|
|
542
|
+
const {
|
|
543
|
+
drawingArea,
|
|
544
|
+
getXScale
|
|
545
|
+
} = useCartesianChartContext();
|
|
546
|
+
const xScale = getXScale();
|
|
547
|
+
const currentHourX = xScale == null ? void 0 : xScale(currentHour);
|
|
548
|
+
const clipPath = useMemo(() => {
|
|
549
|
+
if (!xScale || currentHourX === undefined) return null;
|
|
550
|
+
|
|
551
|
+
// Create a rectangle from currentHourX to right edge of drawing area
|
|
552
|
+
// Apply clipOffset to top, bottom, and right, but NOT left (currentHourX)
|
|
553
|
+
const pathString = "M " + currentHourX + " " + (drawingArea.y - clipOffset) + " L " + (drawingArea.x + drawingArea.width + clipOffset) + " " + (drawingArea.y - clipOffset) + " L " + (drawingArea.x + drawingArea.width + clipOffset) + " " + (drawingArea.y + drawingArea.height + clipOffset) + " L " + currentHourX + " " + (drawingArea.y + drawingArea.height + clipOffset) + " Z";
|
|
554
|
+
return Skia.Path.MakeFromSVGString(pathString);
|
|
555
|
+
}, [xScale, currentHourX, drawingArea, clipOffset]);
|
|
556
|
+
if (!clipPath) return null;
|
|
557
|
+
return /*#__PURE__*/_jsx(Group, {
|
|
558
|
+
clip: clipPath,
|
|
559
|
+
children: children
|
|
560
|
+
});
|
|
561
|
+
});
|
|
562
|
+
const ScatterplotWithCustomLabels = /*#__PURE__*/memo(() => {
|
|
563
|
+
const theme = useTheme();
|
|
564
|
+
const dataPoints = useMemo(() => [{
|
|
565
|
+
x: 12,
|
|
566
|
+
y: 34,
|
|
567
|
+
label: 'A',
|
|
568
|
+
color: theme.color.accentBoldBlue
|
|
569
|
+
}, {
|
|
570
|
+
x: 28,
|
|
571
|
+
y: 67,
|
|
572
|
+
label: 'B',
|
|
573
|
+
color: theme.color.accentBoldBlue
|
|
574
|
+
}, {
|
|
575
|
+
x: 45,
|
|
576
|
+
y: 23,
|
|
577
|
+
label: 'C',
|
|
578
|
+
color: theme.color.accentBoldBlue
|
|
579
|
+
}, {
|
|
580
|
+
x: 67,
|
|
581
|
+
y: 89,
|
|
582
|
+
label: 'D',
|
|
583
|
+
color: theme.color.bgPositive
|
|
584
|
+
}, {
|
|
585
|
+
x: 82,
|
|
586
|
+
y: 76,
|
|
587
|
+
label: 'E',
|
|
588
|
+
color: theme.color.bgPositive
|
|
589
|
+
}, {
|
|
590
|
+
x: 34,
|
|
591
|
+
y: 91,
|
|
592
|
+
label: 'F',
|
|
593
|
+
color: theme.color.bgPositive
|
|
594
|
+
}, {
|
|
595
|
+
x: 56,
|
|
596
|
+
y: 45,
|
|
597
|
+
label: 'G',
|
|
598
|
+
color: theme.color.bgPositive
|
|
599
|
+
}, {
|
|
600
|
+
x: 19,
|
|
601
|
+
y: 12,
|
|
602
|
+
label: 'H',
|
|
603
|
+
color: theme.color.fgWarning
|
|
604
|
+
}, {
|
|
605
|
+
x: 73,
|
|
606
|
+
y: 28,
|
|
607
|
+
label: 'I',
|
|
608
|
+
color: theme.color.fgWarning
|
|
609
|
+
}, {
|
|
610
|
+
x: 91,
|
|
611
|
+
y: 54,
|
|
612
|
+
label: 'J',
|
|
613
|
+
color: theme.color.fgWarning
|
|
614
|
+
}, {
|
|
615
|
+
x: 15,
|
|
616
|
+
y: 58,
|
|
617
|
+
label: 'K',
|
|
618
|
+
color: theme.color.fgPrimary
|
|
619
|
+
}, {
|
|
620
|
+
x: 39,
|
|
621
|
+
y: 72,
|
|
622
|
+
label: 'L',
|
|
623
|
+
color: theme.color.fgPrimary
|
|
624
|
+
}, {
|
|
625
|
+
x: 88,
|
|
626
|
+
y: 15,
|
|
627
|
+
label: 'M',
|
|
628
|
+
color: theme.color.fgPrimary
|
|
629
|
+
}, {
|
|
630
|
+
x: 52,
|
|
631
|
+
y: 82,
|
|
632
|
+
label: 'N',
|
|
633
|
+
color: theme.color.fgPrimary
|
|
634
|
+
}], [theme]);
|
|
635
|
+
|
|
636
|
+
// Calculate domain based on data
|
|
637
|
+
const xValues = useMemo(() => dataPoints.map(p => p.x), [dataPoints]);
|
|
638
|
+
const yValues = useMemo(() => dataPoints.map(p => p.y), [dataPoints]);
|
|
639
|
+
const xMin = Math.min(...xValues);
|
|
640
|
+
const xMax = Math.max(...xValues);
|
|
641
|
+
const yMin = Math.min(...yValues);
|
|
642
|
+
const yMax = Math.max(...yValues);
|
|
643
|
+
|
|
644
|
+
// Custom label component that places labels to the top-right
|
|
645
|
+
const TopRightPointLabel = useCallback(_ref10 => {
|
|
646
|
+
let {
|
|
647
|
+
x,
|
|
648
|
+
y,
|
|
649
|
+
offset = 0,
|
|
650
|
+
children
|
|
651
|
+
} = _ref10;
|
|
652
|
+
return /*#__PURE__*/_jsx(ChartText, {
|
|
653
|
+
font: "label1",
|
|
654
|
+
fontWeight: 600,
|
|
655
|
+
horizontalAlignment: "left",
|
|
656
|
+
verticalAlignment: "bottom",
|
|
657
|
+
x: x + offset,
|
|
658
|
+
y: y - offset,
|
|
659
|
+
children: children
|
|
660
|
+
});
|
|
661
|
+
}, []);
|
|
662
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
663
|
+
height: 300,
|
|
664
|
+
xAxis: {
|
|
665
|
+
domain: {
|
|
666
|
+
min: xMin,
|
|
667
|
+
max: xMax
|
|
668
|
+
},
|
|
669
|
+
domainLimit: 'nice'
|
|
670
|
+
},
|
|
671
|
+
yAxis: {
|
|
672
|
+
domain: {
|
|
673
|
+
min: yMin,
|
|
674
|
+
max: yMax
|
|
675
|
+
},
|
|
676
|
+
domainLimit: 'nice'
|
|
677
|
+
},
|
|
678
|
+
children: [/*#__PURE__*/_jsx(XAxis, {
|
|
679
|
+
showGrid: true,
|
|
680
|
+
showLine: true,
|
|
681
|
+
showTickMarks: true
|
|
682
|
+
}), /*#__PURE__*/_jsx(YAxis, {
|
|
683
|
+
showGrid: true,
|
|
684
|
+
showLine: true,
|
|
685
|
+
showTickMarks: true,
|
|
686
|
+
position: "left"
|
|
687
|
+
}), dataPoints.map((point, index) => /*#__PURE__*/_jsx(Point, {
|
|
688
|
+
LabelComponent: TopRightPointLabel,
|
|
689
|
+
dataX: point.x,
|
|
690
|
+
dataY: point.y,
|
|
691
|
+
fill: point.color,
|
|
692
|
+
label: point.label,
|
|
693
|
+
labelOffset: 8,
|
|
694
|
+
radius: 5
|
|
695
|
+
}, index))]
|
|
696
|
+
});
|
|
697
|
+
});
|
|
698
|
+
const ChartStories = () => {
|
|
699
|
+
return /*#__PURE__*/_jsx(ScrollView, {
|
|
700
|
+
children: /*#__PURE__*/_jsxs(ExampleScreen, {
|
|
701
|
+
children: [/*#__PURE__*/_jsx(Example, {
|
|
702
|
+
title: "Line Styles",
|
|
703
|
+
children: /*#__PURE__*/_jsx(LineStyles, {})
|
|
704
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
705
|
+
title: "Multiple Types",
|
|
706
|
+
children: /*#__PURE__*/_jsx(MultipleChart, {})
|
|
707
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
708
|
+
title: "Earnings History",
|
|
709
|
+
children: /*#__PURE__*/_jsx(EarningsHistory, {})
|
|
710
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
711
|
+
title: "Price With Volume",
|
|
712
|
+
children: /*#__PURE__*/_jsx(PriceWithVolume, {})
|
|
713
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
714
|
+
title: "Trading Trends",
|
|
715
|
+
children: /*#__PURE__*/_jsx(TradingTrends, {})
|
|
716
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
717
|
+
title: "Scatterplot with Custom Labels",
|
|
718
|
+
children: /*#__PURE__*/_jsx(ScatterplotWithCustomLabels, {})
|
|
719
|
+
})]
|
|
720
|
+
})
|
|
721
|
+
});
|
|
722
|
+
};
|
|
723
|
+
export default ChartStories;
|