@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,526 +0,0 @@
|
|
|
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 React, { memo, useCallback, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import { sparklineInteractiveData, sparklineInteractiveHoverData, strokeColor } from '@coinbase/cds-common/internal/visualizations/SparklineInteractiveData';
|
|
4
|
-
import { Example, ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
|
|
5
|
-
import { Box } from '@coinbase/cds-mobile/layout';
|
|
6
|
-
import { Text } from '@coinbase/cds-mobile/typography';
|
|
7
|
-
import { SparklineInteractiveHeader } from '../../sparkline-interactive-header/SparklineInteractiveHeader';
|
|
8
|
-
import { SparklineInteractive } from '../SparklineInteractive';
|
|
9
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
-
const DEFAULT_PERIOD = 'day';
|
|
11
|
-
function numToLocaleString(num) {
|
|
12
|
-
return num.toLocaleString('en-US', {
|
|
13
|
-
maximumFractionDigits: 2
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
const getFormattingConfigForPeriod = period => {
|
|
17
|
-
switch (period) {
|
|
18
|
-
case 'hour':
|
|
19
|
-
case 'day':
|
|
20
|
-
return {
|
|
21
|
-
hour: 'numeric',
|
|
22
|
-
minute: 'numeric'
|
|
23
|
-
};
|
|
24
|
-
case 'week':
|
|
25
|
-
case 'month':
|
|
26
|
-
return {
|
|
27
|
-
month: 'numeric',
|
|
28
|
-
day: 'numeric'
|
|
29
|
-
};
|
|
30
|
-
case 'year':
|
|
31
|
-
case 'all':
|
|
32
|
-
return {
|
|
33
|
-
month: 'numeric',
|
|
34
|
-
year: 'numeric'
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const getDateHoverOptions = period => {
|
|
39
|
-
switch (period) {
|
|
40
|
-
case 'hour':
|
|
41
|
-
case 'day':
|
|
42
|
-
case 'week':
|
|
43
|
-
case 'month':
|
|
44
|
-
return {
|
|
45
|
-
weekday: 'short',
|
|
46
|
-
month: 'short',
|
|
47
|
-
day: 'numeric',
|
|
48
|
-
hour: 'numeric',
|
|
49
|
-
minute: 'numeric'
|
|
50
|
-
};
|
|
51
|
-
default:
|
|
52
|
-
return {
|
|
53
|
-
weekday: 'short',
|
|
54
|
-
year: 'numeric',
|
|
55
|
-
month: 'short',
|
|
56
|
-
day: 'numeric'
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const periods = [{
|
|
61
|
-
label: '1H',
|
|
62
|
-
value: 'hour'
|
|
63
|
-
}, {
|
|
64
|
-
label: '1D',
|
|
65
|
-
value: 'day'
|
|
66
|
-
}, {
|
|
67
|
-
label: '1W',
|
|
68
|
-
value: 'week'
|
|
69
|
-
}, {
|
|
70
|
-
label: '1M',
|
|
71
|
-
value: 'month'
|
|
72
|
-
}, {
|
|
73
|
-
label: '1Y',
|
|
74
|
-
value: 'year'
|
|
75
|
-
}, {
|
|
76
|
-
label: 'All',
|
|
77
|
-
value: 'all'
|
|
78
|
-
}];
|
|
79
|
-
const SparklineInteractiveBuild = /*#__PURE__*/memo(props => {
|
|
80
|
-
var _props$defaultPeriod;
|
|
81
|
-
const formatDateWithConfig = useCallback((value, period) => {
|
|
82
|
-
const config = getFormattingConfigForPeriod(period);
|
|
83
|
-
return value.toLocaleString('en-US', _extends({}, config));
|
|
84
|
-
}, []);
|
|
85
|
-
const formatHoverDate = useCallback((date, period) => {
|
|
86
|
-
return date.toLocaleString('en-US', _extends({}, getDateHoverOptions(period)));
|
|
87
|
-
}, []);
|
|
88
|
-
const formatMinMaxLabel = useCallback(amount => {
|
|
89
|
-
return "$" + numToLocaleString(parseInt(amount, 10));
|
|
90
|
-
}, []);
|
|
91
|
-
return /*#__PURE__*/_jsx(SparklineInteractive, _extends({
|
|
92
|
-
disableScrubbing: !__DEV__
|
|
93
|
-
}, props, {
|
|
94
|
-
defaultPeriod: (_props$defaultPeriod = props.defaultPeriod) != null ? _props$defaultPeriod : DEFAULT_PERIOD,
|
|
95
|
-
formatDate: formatDateWithConfig,
|
|
96
|
-
formatHoverDate: !props.hideHoverDate ? formatHoverDate : undefined,
|
|
97
|
-
formatMinMaxLabel: formatMinMaxLabel,
|
|
98
|
-
periods: periods
|
|
99
|
-
}));
|
|
100
|
-
});
|
|
101
|
-
const generateSubHead = (point, period, sparklineInteractiveData) => {
|
|
102
|
-
const data = sparklineInteractiveData[period];
|
|
103
|
-
const firstPoint = data[0];
|
|
104
|
-
const increase = point.value > firstPoint.value;
|
|
105
|
-
return {
|
|
106
|
-
percent: numToLocaleString(Math.abs((point.value - firstPoint.value) / firstPoint.value) * 100) + "%",
|
|
107
|
-
sign: increase ? 'upwardTrend' : 'downwardTrend',
|
|
108
|
-
variant: increase ? 'positive' : 'negative',
|
|
109
|
-
accessibilityLabel: "" + (increase ? 'up' : 'down'),
|
|
110
|
-
priceChange: "$" + numToLocaleString(Math.abs(point.value - firstPoint.value))
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
const SparklineInteractiveWithHeaderBuild = /*#__PURE__*/memo(props => {
|
|
114
|
-
var _props$defaultPeriod2;
|
|
115
|
-
const {
|
|
116
|
-
data: sparklineData,
|
|
117
|
-
trailing,
|
|
118
|
-
labelNode,
|
|
119
|
-
compact
|
|
120
|
-
} = props;
|
|
121
|
-
const sparklineInteractiveData = sparklineData;
|
|
122
|
-
const headerRef = useRef(null);
|
|
123
|
-
const [currentPeriod, setCurrentPeriod] = useState((_props$defaultPeriod2 = props.defaultPeriod) != null ? _props$defaultPeriod2 : DEFAULT_PERIOD);
|
|
124
|
-
const data = sparklineInteractiveData[currentPeriod];
|
|
125
|
-
const lastPoint = data[data.length - 1];
|
|
126
|
-
const handleScrub = useCallback(_ref => {
|
|
127
|
-
var _headerRef$current;
|
|
128
|
-
let {
|
|
129
|
-
point,
|
|
130
|
-
period
|
|
131
|
-
} = _ref;
|
|
132
|
-
(_headerRef$current = headerRef.current) == null || _headerRef$current.update({
|
|
133
|
-
title: "$" + point.value.toLocaleString('en-US'),
|
|
134
|
-
subHead: generateSubHead(point, period, sparklineInteractiveData)
|
|
135
|
-
});
|
|
136
|
-
}, [sparklineInteractiveData, headerRef]);
|
|
137
|
-
const handleScrubEnd = useCallback(() => {
|
|
138
|
-
var _headerRef$current2;
|
|
139
|
-
(_headerRef$current2 = headerRef.current) == null || _headerRef$current2.update({
|
|
140
|
-
title: "$" + numToLocaleString(lastPoint.value),
|
|
141
|
-
subHead: generateSubHead(lastPoint, currentPeriod, sparklineInteractiveData)
|
|
142
|
-
});
|
|
143
|
-
}, [currentPeriod, sparklineInteractiveData, lastPoint, headerRef]);
|
|
144
|
-
const handleOnPeriodChanged = useCallback(period => {
|
|
145
|
-
var _headerRef$current3;
|
|
146
|
-
setCurrentPeriod(period);
|
|
147
|
-
const newData = sparklineInteractiveData[period];
|
|
148
|
-
const newLastPoint = newData[newData.length - 1];
|
|
149
|
-
(_headerRef$current3 = headerRef.current) == null || _headerRef$current3.update({
|
|
150
|
-
title: "$" + numToLocaleString(newLastPoint.value),
|
|
151
|
-
subHead: generateSubHead(newLastPoint, period, sparklineInteractiveData)
|
|
152
|
-
});
|
|
153
|
-
}, [sparklineInteractiveData, headerRef]);
|
|
154
|
-
const header = useMemo(() => /*#__PURE__*/_jsx(SparklineInteractiveHeader, {
|
|
155
|
-
ref: headerRef,
|
|
156
|
-
compact: compact,
|
|
157
|
-
defaultLabel: labelNode ? 'CustomHeader' : 'Bitcoin Price',
|
|
158
|
-
defaultSubHead: generateSubHead(lastPoint, currentPeriod, sparklineInteractiveData),
|
|
159
|
-
defaultTitle: "$" + numToLocaleString(lastPoint.value),
|
|
160
|
-
labelNode: labelNode,
|
|
161
|
-
trailing: trailing
|
|
162
|
-
}), [compact, labelNode, lastPoint, currentPeriod, sparklineInteractiveData, trailing]);
|
|
163
|
-
return /*#__PURE__*/_jsx(SparklineInteractiveBuild, _extends({}, props, {
|
|
164
|
-
headerNode: header,
|
|
165
|
-
onPeriodChanged: handleOnPeriodChanged,
|
|
166
|
-
onScrub: handleScrub,
|
|
167
|
-
onScrubEnd: handleScrubEnd
|
|
168
|
-
}));
|
|
169
|
-
});
|
|
170
|
-
const rgbaStrokeColor = 'rgba(123, 1, 1, 5)';
|
|
171
|
-
const rgbStrokeColor = 'rgb(123, 1, 121)';
|
|
172
|
-
const autoStrokeColor = 'auto';
|
|
173
|
-
const SparklineInteractiveScreen = () => {
|
|
174
|
-
return /*#__PURE__*/_jsxs(ExampleScreen, {
|
|
175
|
-
children: [/*#__PURE__*/_jsx(Example, {
|
|
176
|
-
padding: 0,
|
|
177
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
178
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
179
|
-
font: "title3",
|
|
180
|
-
paddingX: 3,
|
|
181
|
-
paddingY: 3,
|
|
182
|
-
children: "Default"
|
|
183
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
184
|
-
data: sparklineInteractiveData,
|
|
185
|
-
strokeColor: strokeColor
|
|
186
|
-
})]
|
|
187
|
-
})
|
|
188
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
189
|
-
padding: 0,
|
|
190
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
191
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
192
|
-
font: "title3",
|
|
193
|
-
paddingX: 3,
|
|
194
|
-
paddingY: 3,
|
|
195
|
-
children: "Compact"
|
|
196
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
197
|
-
compact: true,
|
|
198
|
-
data: sparklineInteractiveData,
|
|
199
|
-
strokeColor: strokeColor
|
|
200
|
-
})]
|
|
201
|
-
})
|
|
202
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
203
|
-
padding: 0,
|
|
204
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
205
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
206
|
-
font: "title3",
|
|
207
|
-
paddingX: 3,
|
|
208
|
-
paddingY: 3,
|
|
209
|
-
children: "Disable Scrubbing"
|
|
210
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
211
|
-
disableScrubbing: true,
|
|
212
|
-
data: sparklineInteractiveData,
|
|
213
|
-
strokeColor: strokeColor
|
|
214
|
-
})]
|
|
215
|
-
})
|
|
216
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
217
|
-
padding: 0,
|
|
218
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
219
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
220
|
-
font: "title3",
|
|
221
|
-
paddingX: 3,
|
|
222
|
-
paddingY: 3,
|
|
223
|
-
children: "Hide period selector"
|
|
224
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
225
|
-
hidePeriodSelector: true,
|
|
226
|
-
data: sparklineInteractiveData,
|
|
227
|
-
strokeColor: strokeColor
|
|
228
|
-
})]
|
|
229
|
-
})
|
|
230
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
231
|
-
padding: 0,
|
|
232
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
233
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
234
|
-
font: "title3",
|
|
235
|
-
paddingX: 3,
|
|
236
|
-
paddingY: 3,
|
|
237
|
-
children: "Hide min/max label"
|
|
238
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
239
|
-
hideMinMaxLabel: true,
|
|
240
|
-
data: sparklineInteractiveData,
|
|
241
|
-
strokeColor: strokeColor
|
|
242
|
-
})]
|
|
243
|
-
})
|
|
244
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
245
|
-
padding: 0,
|
|
246
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
247
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
248
|
-
font: "title3",
|
|
249
|
-
paddingX: 3,
|
|
250
|
-
paddingY: 3,
|
|
251
|
-
children: "Default period All"
|
|
252
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
253
|
-
data: sparklineInteractiveData,
|
|
254
|
-
defaultPeriod: "all",
|
|
255
|
-
strokeColor: strokeColor
|
|
256
|
-
})]
|
|
257
|
-
})
|
|
258
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
259
|
-
padding: 0,
|
|
260
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
261
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
262
|
-
font: "title3",
|
|
263
|
-
paddingX: 3,
|
|
264
|
-
paddingY: 3,
|
|
265
|
-
children: "Fill Disabled"
|
|
266
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
267
|
-
data: sparklineInteractiveData,
|
|
268
|
-
fill: false,
|
|
269
|
-
strokeColor: strokeColor
|
|
270
|
-
})]
|
|
271
|
-
})
|
|
272
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
273
|
-
padding: 0,
|
|
274
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
275
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
276
|
-
font: "title3",
|
|
277
|
-
paddingX: 3,
|
|
278
|
-
paddingY: 3,
|
|
279
|
-
children: "Y axis scaling"
|
|
280
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
281
|
-
data: sparklineInteractiveData,
|
|
282
|
-
strokeColor: strokeColor,
|
|
283
|
-
yAxisScalingFactor: 0.1
|
|
284
|
-
})]
|
|
285
|
-
})
|
|
286
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
287
|
-
padding: 0,
|
|
288
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
289
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
290
|
-
font: "title3",
|
|
291
|
-
paddingX: 3,
|
|
292
|
-
paddingY: 3,
|
|
293
|
-
children: "Fallback"
|
|
294
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
295
|
-
strokeColor: strokeColor
|
|
296
|
-
})]
|
|
297
|
-
})
|
|
298
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
299
|
-
padding: 0,
|
|
300
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
301
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
302
|
-
font: "title3",
|
|
303
|
-
paddingX: 3,
|
|
304
|
-
paddingY: 3,
|
|
305
|
-
children: "Fallback Negative"
|
|
306
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
307
|
-
fallbackType: "negative",
|
|
308
|
-
strokeColor: strokeColor
|
|
309
|
-
})]
|
|
310
|
-
})
|
|
311
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
312
|
-
padding: 0,
|
|
313
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
314
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
315
|
-
font: "title3",
|
|
316
|
-
paddingX: 3,
|
|
317
|
-
paddingY: 3,
|
|
318
|
-
children: "Fallback Compact"
|
|
319
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
320
|
-
compact: true,
|
|
321
|
-
strokeColor: strokeColor
|
|
322
|
-
})]
|
|
323
|
-
})
|
|
324
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
325
|
-
padding: 0,
|
|
326
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
327
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
328
|
-
font: "title3",
|
|
329
|
-
paddingX: 3,
|
|
330
|
-
paddingY: 3,
|
|
331
|
-
children: "No Hover Date"
|
|
332
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
333
|
-
hideHoverDate: true,
|
|
334
|
-
data: sparklineInteractiveData,
|
|
335
|
-
strokeColor: strokeColor
|
|
336
|
-
})]
|
|
337
|
-
})
|
|
338
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
339
|
-
padding: 0,
|
|
340
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
341
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
342
|
-
font: "title3",
|
|
343
|
-
paddingX: 3,
|
|
344
|
-
paddingY: 3,
|
|
345
|
-
children: "With Header Node"
|
|
346
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveWithHeaderBuild, {
|
|
347
|
-
data: sparklineInteractiveData,
|
|
348
|
-
strokeColor: "#F7931A"
|
|
349
|
-
})]
|
|
350
|
-
})
|
|
351
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
352
|
-
padding: 0,
|
|
353
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
354
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
355
|
-
font: "title3",
|
|
356
|
-
paddingX: 3,
|
|
357
|
-
paddingY: 3,
|
|
358
|
-
children: "No padding"
|
|
359
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
360
|
-
data: sparklineInteractiveData,
|
|
361
|
-
gutter: 0,
|
|
362
|
-
strokeColor: "#F7931A",
|
|
363
|
-
timePeriodGutter: 3
|
|
364
|
-
})]
|
|
365
|
-
})
|
|
366
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
367
|
-
padding: 4,
|
|
368
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
369
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
370
|
-
font: "title3",
|
|
371
|
-
paddingY: 3,
|
|
372
|
-
children: "In Container With 4 padding"
|
|
373
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveWithHeaderBuild, {
|
|
374
|
-
disableHorizontalPadding: true,
|
|
375
|
-
data: sparklineInteractiveData,
|
|
376
|
-
gutter: 4,
|
|
377
|
-
strokeColor: "#F7931A"
|
|
378
|
-
})]
|
|
379
|
-
})
|
|
380
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
381
|
-
padding: 0,
|
|
382
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
383
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
384
|
-
font: "title3",
|
|
385
|
-
paddingX: 3,
|
|
386
|
-
paddingY: 3,
|
|
387
|
-
children: "Custom screen padding 6"
|
|
388
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
389
|
-
data: sparklineInteractiveData,
|
|
390
|
-
gutter: 6,
|
|
391
|
-
strokeColor: "#F7931A"
|
|
392
|
-
})]
|
|
393
|
-
})
|
|
394
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
395
|
-
padding: 0,
|
|
396
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
397
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
398
|
-
font: "title3",
|
|
399
|
-
paddingX: 3,
|
|
400
|
-
paddingY: 3,
|
|
401
|
-
children: "Hover data"
|
|
402
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
403
|
-
data: sparklineInteractiveData,
|
|
404
|
-
hoverData: sparklineInteractiveHoverData,
|
|
405
|
-
strokeColor: strokeColor
|
|
406
|
-
})]
|
|
407
|
-
})
|
|
408
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
409
|
-
padding: 0,
|
|
410
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
411
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
412
|
-
font: "title3",
|
|
413
|
-
paddingX: 3,
|
|
414
|
-
paddingY: 3,
|
|
415
|
-
children: "Auto Stoke Color"
|
|
416
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
417
|
-
data: sparklineInteractiveData,
|
|
418
|
-
strokeColor: autoStrokeColor
|
|
419
|
-
})]
|
|
420
|
-
})
|
|
421
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
422
|
-
padding: 0,
|
|
423
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
424
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
425
|
-
font: "title3",
|
|
426
|
-
paddingX: 3,
|
|
427
|
-
paddingY: 3,
|
|
428
|
-
children: "Custom RGB Stoke Color"
|
|
429
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
430
|
-
data: sparklineInteractiveData,
|
|
431
|
-
strokeColor: rgbStrokeColor
|
|
432
|
-
})]
|
|
433
|
-
})
|
|
434
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
435
|
-
padding: 0,
|
|
436
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
437
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
438
|
-
font: "title3",
|
|
439
|
-
paddingX: 3,
|
|
440
|
-
paddingY: 3,
|
|
441
|
-
children: "Custom RGBA Stoke Color"
|
|
442
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
443
|
-
data: sparklineInteractiveData,
|
|
444
|
-
strokeColor: rgbaStrokeColor
|
|
445
|
-
})]
|
|
446
|
-
})
|
|
447
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
448
|
-
padding: 0,
|
|
449
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
450
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
451
|
-
font: "title3",
|
|
452
|
-
paddingX: 3,
|
|
453
|
-
paddingY: 3,
|
|
454
|
-
children: "No Data In SelectedPeriod"
|
|
455
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
456
|
-
data: _extends({}, sparklineInteractiveData, {
|
|
457
|
-
hour: []
|
|
458
|
-
}),
|
|
459
|
-
strokeColor: rgbaStrokeColor
|
|
460
|
-
})]
|
|
461
|
-
})
|
|
462
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
463
|
-
padding: 0,
|
|
464
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
465
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
466
|
-
font: "title3",
|
|
467
|
-
paddingX: 3,
|
|
468
|
-
paddingY: 3,
|
|
469
|
-
children: "Enable Interaction When Outside"
|
|
470
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
471
|
-
allowOverflowGestures: true,
|
|
472
|
-
data: sparklineInteractiveData,
|
|
473
|
-
strokeColor: strokeColor
|
|
474
|
-
})]
|
|
475
|
-
})
|
|
476
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
477
|
-
padding: 0,
|
|
478
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
479
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
480
|
-
font: "title3",
|
|
481
|
-
paddingX: 3,
|
|
482
|
-
paddingY: 3,
|
|
483
|
-
children: "Custom Node Header Styles"
|
|
484
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveWithHeaderBuild, {
|
|
485
|
-
data: sparklineInteractiveData,
|
|
486
|
-
strokeColor: "#F7931A",
|
|
487
|
-
styles: {
|
|
488
|
-
header: {
|
|
489
|
-
paddingBottom: 0
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
})]
|
|
493
|
-
})
|
|
494
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
495
|
-
padding: 0,
|
|
496
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
497
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
498
|
-
font: "title3",
|
|
499
|
-
paddingX: 3,
|
|
500
|
-
paddingY: 3,
|
|
501
|
-
children: "Dotted Fill Type"
|
|
502
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
503
|
-
data: sparklineInteractiveData,
|
|
504
|
-
fillType: "dotted",
|
|
505
|
-
strokeColor: strokeColor
|
|
506
|
-
})]
|
|
507
|
-
})
|
|
508
|
-
}), /*#__PURE__*/_jsx(Example, {
|
|
509
|
-
padding: 0,
|
|
510
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
511
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
512
|
-
font: "title3",
|
|
513
|
-
paddingX: 3,
|
|
514
|
-
paddingY: 3,
|
|
515
|
-
children: "Y Scale Custom"
|
|
516
|
-
}), /*#__PURE__*/_jsx(SparklineInteractiveBuild, {
|
|
517
|
-
data: sparklineInteractiveData,
|
|
518
|
-
fillType: "dotted",
|
|
519
|
-
strokeColor: strokeColor,
|
|
520
|
-
yAxisScalingFactor: 0.1
|
|
521
|
-
})]
|
|
522
|
-
})
|
|
523
|
-
})]
|
|
524
|
-
});
|
|
525
|
-
};
|
|
526
|
-
export default SparklineInteractiveScreen;
|
|
@@ -1,58 +0,0 @@
|
|
|
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 { useCallback, useEffect, useRef } from 'react';
|
|
3
|
-
import { Animated } from 'react-native';
|
|
4
|
-
import { animatedPathConfig } from '@coinbase/cds-common/animation/sparkline';
|
|
5
|
-
import { useSparklineInteractiveContext } from './SparklineInteractiveProvider';
|
|
6
|
-
const animationConfig = _extends({}, animatedPathConfig, {
|
|
7
|
-
toValue: 1,
|
|
8
|
-
useNativeDriver: true
|
|
9
|
-
});
|
|
10
|
-
export const useInterruptiblePathAnimation = _ref => {
|
|
11
|
-
let {
|
|
12
|
-
animationListener,
|
|
13
|
-
onInterrupt,
|
|
14
|
-
ignoreMinMax
|
|
15
|
-
} = _ref;
|
|
16
|
-
const {
|
|
17
|
-
animateMinMaxIn
|
|
18
|
-
} = useSparklineInteractiveContext();
|
|
19
|
-
const isRunning = useRef(false);
|
|
20
|
-
const animationProgress = useRef(new Animated.Value(0)).current;
|
|
21
|
-
const animations = [Animated.timing(animationProgress, animationConfig)];
|
|
22
|
-
if (!ignoreMinMax) {
|
|
23
|
-
animations.push(animateMinMaxIn);
|
|
24
|
-
}
|
|
25
|
-
const animation = Animated.sequence(animations);
|
|
26
|
-
const onFinishAnimation = useCallback(_ref2 => {
|
|
27
|
-
let {
|
|
28
|
-
finished
|
|
29
|
-
} = _ref2;
|
|
30
|
-
if (finished) {
|
|
31
|
-
animationProgress.removeAllListeners();
|
|
32
|
-
animationProgress.setValue(0);
|
|
33
|
-
isRunning.current = false;
|
|
34
|
-
}
|
|
35
|
-
}, [animationProgress]);
|
|
36
|
-
|
|
37
|
-
// Clean up listeners
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
return () => {
|
|
40
|
-
animationProgress.removeAllListeners();
|
|
41
|
-
};
|
|
42
|
-
}, [animationProgress]);
|
|
43
|
-
return useCallback(() => {
|
|
44
|
-
// If try to re-run animation while currently running
|
|
45
|
-
// we should interrupt it and start new one
|
|
46
|
-
if (isRunning.current) {
|
|
47
|
-
animation.stop();
|
|
48
|
-
onFinishAnimation({
|
|
49
|
-
finished: true
|
|
50
|
-
});
|
|
51
|
-
onInterrupt();
|
|
52
|
-
} else {
|
|
53
|
-
isRunning.current = true;
|
|
54
|
-
animationProgress.addListener(animationListener);
|
|
55
|
-
animation.start(onFinishAnimation);
|
|
56
|
-
}
|
|
57
|
-
}, [animation, animationListener, animationProgress, onFinishAnimation, onInterrupt]);
|
|
58
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Animated } from 'react-native';
|
|
2
|
-
import { renderHook } from '@testing-library/react-hooks';
|
|
3
|
-
import { useInterruptiblePathAnimation } from './useInterruptiblePathAnimation';
|
|
4
|
-
jest.useFakeTimers({
|
|
5
|
-
legacyFakeTimers: true
|
|
6
|
-
});
|
|
7
|
-
describe('useInterruptiblePathAnimation', () => {
|
|
8
|
-
const animationListenerSpy = jest.fn();
|
|
9
|
-
const onInterruptSpy = jest.fn();
|
|
10
|
-
it('plays correctly', () => {
|
|
11
|
-
const {
|
|
12
|
-
result
|
|
13
|
-
} = renderHook(() => {
|
|
14
|
-
return useInterruptiblePathAnimation({
|
|
15
|
-
animationListener: animationListenerSpy,
|
|
16
|
-
onInterrupt: onInterruptSpy
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
result.current();
|
|
20
|
-
expect(Animated.timing).toHaveBeenCalled();
|
|
21
|
-
});
|
|
22
|
-
it('interrupts correctly if triggering play while already playing', () => {
|
|
23
|
-
const {
|
|
24
|
-
result
|
|
25
|
-
} = renderHook(() => {
|
|
26
|
-
return useInterruptiblePathAnimation({
|
|
27
|
-
animationListener: animationListenerSpy,
|
|
28
|
-
onInterrupt: onInterruptSpy
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
result.current();
|
|
32
|
-
expect(Animated.timing).toHaveBeenCalled();
|
|
33
|
-
result.current();
|
|
34
|
-
expect(onInterruptSpy).toHaveBeenCalled();
|
|
35
|
-
jest.runAllTimers();
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import { Animated } from 'react-native';
|
|
3
|
-
import { durations } from '@coinbase/cds-common/motion/tokens';
|
|
4
|
-
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
5
|
-
import { useSparklineInteractiveContext } from './SparklineInteractiveProvider';
|
|
6
|
-
import { useSparklineInteractiveConstants } from './useSparklineInteractiveConstants';
|
|
7
|
-
export function useMinMaxTransform(_ref) {
|
|
8
|
-
let {
|
|
9
|
-
minMaxLayout,
|
|
10
|
-
x,
|
|
11
|
-
transform,
|
|
12
|
-
opacity
|
|
13
|
-
} = _ref;
|
|
14
|
-
const theme = useTheme();
|
|
15
|
-
const {
|
|
16
|
-
height,
|
|
17
|
-
width
|
|
18
|
-
} = minMaxLayout;
|
|
19
|
-
const {
|
|
20
|
-
SparklineInteractiveMinMaxLabelHeight,
|
|
21
|
-
chartWidth
|
|
22
|
-
} = useSparklineInteractiveConstants({});
|
|
23
|
-
const {
|
|
24
|
-
gutter
|
|
25
|
-
} = useSparklineInteractiveContext();
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
// If onLayout has not finished we don't want to show min/max
|
|
28
|
-
// or else it will abruptly change positions
|
|
29
|
-
if (height === 0 && width === 0) {
|
|
30
|
-
opacity.setValue(0);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// if we have no gutter the min/max label needs some space so it's not right up against the edge of the screen
|
|
35
|
-
const minGutter = gutter === 0 ? theme.space['1'] : 0;
|
|
36
|
-
|
|
37
|
-
// Position min or max at center of the desired x coordinate when possible.
|
|
38
|
-
// If this is not possible, ensure that it's never positioned outside of chart container.
|
|
39
|
-
// This means the x transform should never be less than 0 or greater than chartWidth - labelWidth
|
|
40
|
-
const idealX = x - width / 2;
|
|
41
|
-
const translateX = Math.round(Math.max(minGutter, Math.min(idealX, chartWidth - width - minGutter)));
|
|
42
|
-
// Vertically center the min/max label within SparklineInteractiveMinMaxLabelHeight.
|
|
43
|
-
// This is the area between the vertical dotted line and the top or bottom
|
|
44
|
-
// of sparkline where min/max is displayed
|
|
45
|
-
const translateY = SparklineInteractiveMinMaxLabelHeight / 2 - height / 2;
|
|
46
|
-
transform.setValue({
|
|
47
|
-
x: translateX,
|
|
48
|
-
y: translateY
|
|
49
|
-
});
|
|
50
|
-
Animated.timing(opacity, {
|
|
51
|
-
toValue: 1,
|
|
52
|
-
duration: durations.moderate1,
|
|
53
|
-
useNativeDriver: true
|
|
54
|
-
}).start();
|
|
55
|
-
}, [SparklineInteractiveMinMaxLabelHeight, chartWidth, gutter, height, opacity, theme.space, transform, width, x]);
|
|
56
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { useMemo, useRef } from 'react';
|
|
2
|
-
import { Animated } from 'react-native';
|
|
3
|
-
import { fadeDuration } from '@coinbase/cds-common/tokens/sparkline';
|
|
4
|
-
export function useOpacityAnimation(initialValue, duration) {
|
|
5
|
-
if (initialValue === void 0) {
|
|
6
|
-
initialValue = 0;
|
|
7
|
-
}
|
|
8
|
-
if (duration === void 0) {
|
|
9
|
-
duration = fadeDuration;
|
|
10
|
-
}
|
|
11
|
-
const animation = useRef(new Animated.Value(initialValue)).current;
|
|
12
|
-
const animateIn = useMemo(() => Animated.timing(animation, {
|
|
13
|
-
toValue: 1,
|
|
14
|
-
duration,
|
|
15
|
-
useNativeDriver: true
|
|
16
|
-
}), [animation, duration]);
|
|
17
|
-
const animateOut = useMemo(() => Animated.timing(animation, {
|
|
18
|
-
toValue: 0,
|
|
19
|
-
duration,
|
|
20
|
-
useNativeDriver: true
|
|
21
|
-
}), [animation, duration]);
|
|
22
|
-
return [animation, animateIn, animateOut];
|
|
23
|
-
}
|