@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
package/esm/chart/line/Line.js
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
const _excluded = ["seriesId", "curve", "type", "areaType", "stroke", "strokeOpacity", "showArea", "LineComponent", "AreaComponent", "opacity", "points", "connectNulls", "transitions", "transition", "gradient"];
|
|
2
|
-
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); }
|
|
3
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
-
import React, { memo, useMemo } from 'react';
|
|
5
|
-
import { useTheme } from '@coinbase/cds-mobile';
|
|
6
|
-
import { Group } from '@shopify/react-native-skia';
|
|
7
|
-
import { Area } from '../area/Area';
|
|
8
|
-
import { useCartesianChartContext } from '../ChartProvider';
|
|
9
|
-
import { Point } from '../point';
|
|
10
|
-
import { getLineData, getLinePath } from '../utils';
|
|
11
|
-
import { evaluateGradientAtValue, getGradientStops } from '../utils/gradient';
|
|
12
|
-
import { convertToSerializableScale } from '../utils/scale';
|
|
13
|
-
import { DottedLine } from './DottedLine';
|
|
14
|
-
import { SolidLine } from './SolidLine';
|
|
15
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
export const Line = /*#__PURE__*/memo(_ref => {
|
|
17
|
-
var _ref2;
|
|
18
|
-
let {
|
|
19
|
-
seriesId,
|
|
20
|
-
curve = 'bump',
|
|
21
|
-
type = 'solid',
|
|
22
|
-
areaType = 'gradient',
|
|
23
|
-
stroke: strokeProp,
|
|
24
|
-
strokeOpacity,
|
|
25
|
-
showArea,
|
|
26
|
-
LineComponent: SelectedLineComponent,
|
|
27
|
-
AreaComponent,
|
|
28
|
-
opacity = 1,
|
|
29
|
-
points,
|
|
30
|
-
connectNulls,
|
|
31
|
-
transitions,
|
|
32
|
-
transition,
|
|
33
|
-
gradient: gradientProp
|
|
34
|
-
} = _ref,
|
|
35
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
36
|
-
const theme = useTheme();
|
|
37
|
-
const {
|
|
38
|
-
layout,
|
|
39
|
-
animate,
|
|
40
|
-
getSeries,
|
|
41
|
-
getSeriesData,
|
|
42
|
-
getXScale,
|
|
43
|
-
getYScale,
|
|
44
|
-
getXAxis,
|
|
45
|
-
getYAxis
|
|
46
|
-
} = useCartesianChartContext();
|
|
47
|
-
const matchedSeries = useMemo(() => getSeries(seriesId), [getSeries, seriesId]);
|
|
48
|
-
const gradient = useMemo(() => gradientProp != null ? gradientProp : matchedSeries == null ? void 0 : matchedSeries.gradient, [gradientProp, matchedSeries == null ? void 0 : matchedSeries.gradient]);
|
|
49
|
-
const sourceData = useMemo(() => getSeriesData(seriesId), [getSeriesData, seriesId]);
|
|
50
|
-
const xAxis = useMemo(() => getXAxis(matchedSeries == null ? void 0 : matchedSeries.xAxisId), [getXAxis, matchedSeries == null ? void 0 : matchedSeries.xAxisId]);
|
|
51
|
-
const xScale = useMemo(() => getXScale(matchedSeries == null ? void 0 : matchedSeries.xAxisId), [getXScale, matchedSeries == null ? void 0 : matchedSeries.xAxisId]);
|
|
52
|
-
const yScale = useMemo(() => getYScale(matchedSeries == null ? void 0 : matchedSeries.yAxisId), [getYScale, matchedSeries == null ? void 0 : matchedSeries.yAxisId]);
|
|
53
|
-
const yAxis = useMemo(() => getYAxis(matchedSeries == null ? void 0 : matchedSeries.yAxisId), [getYAxis, matchedSeries == null ? void 0 : matchedSeries.yAxisId]);
|
|
54
|
-
|
|
55
|
-
// Convert sourceData to number array (line only supports numbers, not tuples)
|
|
56
|
-
const chartData = useMemo(() => getLineData(sourceData), [sourceData]);
|
|
57
|
-
const categoryAxisIsX = useMemo(() => {
|
|
58
|
-
return layout !== 'horizontal';
|
|
59
|
-
}, [layout]);
|
|
60
|
-
const categoryAxis = useMemo(() => {
|
|
61
|
-
return categoryAxisIsX ? xAxis : yAxis;
|
|
62
|
-
}, [categoryAxisIsX, xAxis, yAxis]);
|
|
63
|
-
const path = useMemo(() => {
|
|
64
|
-
if (!xScale || !yScale || chartData.length === 0) return '';
|
|
65
|
-
|
|
66
|
-
// Get numeric category-axis data if available.
|
|
67
|
-
const indexData = categoryAxis != null && categoryAxis.data && Array.isArray(categoryAxis.data) && typeof categoryAxis.data[0] === 'number' ? categoryAxis.data : undefined;
|
|
68
|
-
return getLinePath({
|
|
69
|
-
data: chartData,
|
|
70
|
-
xScale,
|
|
71
|
-
yScale,
|
|
72
|
-
curve,
|
|
73
|
-
xData: categoryAxisIsX ? indexData : undefined,
|
|
74
|
-
yData: !categoryAxisIsX ? indexData : undefined,
|
|
75
|
-
connectNulls,
|
|
76
|
-
layout
|
|
77
|
-
});
|
|
78
|
-
}, [xScale, yScale, chartData, categoryAxis, curve, categoryAxisIsX, connectNulls, layout]);
|
|
79
|
-
const LineComponent = useMemo(() => {
|
|
80
|
-
if (SelectedLineComponent) {
|
|
81
|
-
return SelectedLineComponent;
|
|
82
|
-
}
|
|
83
|
-
switch (type) {
|
|
84
|
-
case 'dotted':
|
|
85
|
-
return DottedLine;
|
|
86
|
-
default:
|
|
87
|
-
return SolidLine;
|
|
88
|
-
}
|
|
89
|
-
}, [SelectedLineComponent, type]);
|
|
90
|
-
|
|
91
|
-
// Get series color for stroke
|
|
92
|
-
const stroke = (_ref2 = strokeProp != null ? strokeProp : matchedSeries == null ? void 0 : matchedSeries.color) != null ? _ref2 : theme.color.fgPrimary;
|
|
93
|
-
const categoryData = useMemo(() => {
|
|
94
|
-
const data = categoryAxis == null ? void 0 : categoryAxis.data;
|
|
95
|
-
return data && Array.isArray(data) && data.length > 0 && typeof data[0] === 'number' ? data : null;
|
|
96
|
-
}, [categoryAxis]);
|
|
97
|
-
const gradientConfig = useMemo(() => {
|
|
98
|
-
if (!gradient || !xScale || !yScale) return;
|
|
99
|
-
const gradientScale = gradient.axis === 'x' ? xScale : yScale;
|
|
100
|
-
const serializableScale = convertToSerializableScale(gradientScale);
|
|
101
|
-
if (!serializableScale) return;
|
|
102
|
-
const domain = {
|
|
103
|
-
min: serializableScale.domain[0],
|
|
104
|
-
max: serializableScale.domain[1]
|
|
105
|
-
};
|
|
106
|
-
const stops = getGradientStops(gradient.stops, domain);
|
|
107
|
-
return {
|
|
108
|
-
scale: serializableScale,
|
|
109
|
-
stops
|
|
110
|
-
};
|
|
111
|
-
}, [gradient, xScale, yScale]);
|
|
112
|
-
if (!xScale || !yScale || !path) return;
|
|
113
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
114
|
-
children: [showArea && /*#__PURE__*/_jsx(Area, {
|
|
115
|
-
AreaComponent: AreaComponent,
|
|
116
|
-
connectNulls: connectNulls,
|
|
117
|
-
curve: curve,
|
|
118
|
-
fill: stroke,
|
|
119
|
-
fillOpacity: opacity,
|
|
120
|
-
gradient: gradient,
|
|
121
|
-
seriesId: seriesId,
|
|
122
|
-
transition: transition,
|
|
123
|
-
transitions: transitions,
|
|
124
|
-
type: areaType
|
|
125
|
-
}), /*#__PURE__*/_jsx(LineComponent, _extends({
|
|
126
|
-
d: path,
|
|
127
|
-
gradient: gradient,
|
|
128
|
-
stroke: stroke,
|
|
129
|
-
strokeOpacity: strokeOpacity != null ? strokeOpacity : opacity,
|
|
130
|
-
transition: transition,
|
|
131
|
-
transitions: transitions,
|
|
132
|
-
xAxisId: matchedSeries == null ? void 0 : matchedSeries.xAxisId,
|
|
133
|
-
yAxisId: matchedSeries == null ? void 0 : matchedSeries.yAxisId
|
|
134
|
-
}, props)), points && /*#__PURE__*/_jsx(Group, {
|
|
135
|
-
children: chartData.map((value, index) => {
|
|
136
|
-
if (value === null) return;
|
|
137
|
-
const indexValue = categoryData && categoryData[index] !== undefined ? categoryData[index] : index;
|
|
138
|
-
let pointFill = stroke;
|
|
139
|
-
if (gradientConfig && gradient) {
|
|
140
|
-
var _gradient$axis;
|
|
141
|
-
// Match gradient sampling to the chart axis roles for each layout.
|
|
142
|
-
const gradientAxis = (_gradient$axis = gradient.axis) != null ? _gradient$axis : 'y';
|
|
143
|
-
const dataValue = gradientAxis === 'x' ? categoryAxisIsX ? indexValue : value : categoryAxisIsX ? value : indexValue;
|
|
144
|
-
const evaluatedColor = evaluateGradientAtValue(gradientConfig.stops, dataValue, gradientConfig.scale);
|
|
145
|
-
if (evaluatedColor) {
|
|
146
|
-
// Apply gradient color to fill if not explicitly set
|
|
147
|
-
pointFill = evaluatedColor;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Build defaults that would be passed to Point
|
|
152
|
-
const defaults = {
|
|
153
|
-
dataX: categoryAxisIsX ? indexValue : value,
|
|
154
|
-
dataY: categoryAxisIsX ? value : indexValue,
|
|
155
|
-
fill: pointFill,
|
|
156
|
-
xAxisId: matchedSeries == null ? void 0 : matchedSeries.xAxisId,
|
|
157
|
-
yAxisId: matchedSeries == null ? void 0 : matchedSeries.yAxisId,
|
|
158
|
-
opacity
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
// If points is true, render with defaults
|
|
162
|
-
if (points === true) {
|
|
163
|
-
return /*#__PURE__*/_jsx(Point, _extends({
|
|
164
|
-
transition: transition,
|
|
165
|
-
transitions: transitions
|
|
166
|
-
}, defaults), seriesId + "-" + index);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Call the function with defaults
|
|
170
|
-
const result = points(defaults);
|
|
171
|
-
if (!result) return;
|
|
172
|
-
const pointConfig = result === true ? {} : result;
|
|
173
|
-
return /*#__PURE__*/_jsx(Point, _extends({
|
|
174
|
-
transition: transition,
|
|
175
|
-
transitions: transitions
|
|
176
|
-
}, defaults, pointConfig), seriesId + "-" + index);
|
|
177
|
-
})
|
|
178
|
-
})]
|
|
179
|
-
});
|
|
180
|
-
});
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
const _excluded = ["series", "showArea", "areaType", "type", "LineComponent", "AreaComponent", "curve", "points", "strokeWidth", "strokeOpacity", "connectNulls", "transition", "transitions", "opacity", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "scrubberAccessibilityLabelStep", "layout", "children"],
|
|
2
|
-
_excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "baseline", "id"],
|
|
3
|
-
_excluded3 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "baseline", "id"],
|
|
4
|
-
_excluded4 = ["id", "data", "label", "color", "xAxisId", "yAxisId"];
|
|
5
|
-
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); }
|
|
6
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
7
|
-
import { forwardRef, memo, useMemo } from 'react';
|
|
8
|
-
import { XAxis } from '../axis/XAxis';
|
|
9
|
-
import { YAxis } from '../axis/YAxis';
|
|
10
|
-
import { CartesianChart } from '../CartesianChart';
|
|
11
|
-
import { Line } from './Line';
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
const getDefaultScrubberAccessibilityStep = function (dataLength, sampleCount) {
|
|
14
|
-
if (sampleCount === void 0) {
|
|
15
|
-
sampleCount = 10;
|
|
16
|
-
}
|
|
17
|
-
if (dataLength <= 0) return 1;
|
|
18
|
-
return Math.max(1, Math.ceil(dataLength / sampleCount));
|
|
19
|
-
};
|
|
20
|
-
export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
21
|
-
let {
|
|
22
|
-
series,
|
|
23
|
-
showArea,
|
|
24
|
-
areaType,
|
|
25
|
-
type,
|
|
26
|
-
LineComponent,
|
|
27
|
-
AreaComponent,
|
|
28
|
-
curve,
|
|
29
|
-
points,
|
|
30
|
-
strokeWidth,
|
|
31
|
-
strokeOpacity,
|
|
32
|
-
connectNulls,
|
|
33
|
-
transition,
|
|
34
|
-
transitions,
|
|
35
|
-
opacity,
|
|
36
|
-
showXAxis,
|
|
37
|
-
showYAxis,
|
|
38
|
-
xAxis,
|
|
39
|
-
yAxis,
|
|
40
|
-
inset,
|
|
41
|
-
scrubberAccessibilityLabelStep,
|
|
42
|
-
layout = 'vertical',
|
|
43
|
-
children
|
|
44
|
-
} = _ref,
|
|
45
|
-
chartProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
46
|
-
// Convert LineSeries to Series for Chart context
|
|
47
|
-
const chartSeries = useMemo(() => {
|
|
48
|
-
return series == null ? void 0 : series.map(s => ({
|
|
49
|
-
id: s.id,
|
|
50
|
-
data: s.data,
|
|
51
|
-
label: s.label,
|
|
52
|
-
color: s.color,
|
|
53
|
-
xAxisId: s.xAxisId,
|
|
54
|
-
yAxisId: s.yAxisId,
|
|
55
|
-
stackId: s.stackId,
|
|
56
|
-
gradient: s.gradient,
|
|
57
|
-
legendShape: s.legendShape
|
|
58
|
-
}));
|
|
59
|
-
}, [series]);
|
|
60
|
-
|
|
61
|
-
// Split axis props into config props for Chart and visual props for axis components
|
|
62
|
-
const _ref2 = xAxis || {},
|
|
63
|
-
{
|
|
64
|
-
scaleType: xScaleType,
|
|
65
|
-
data: xData,
|
|
66
|
-
categoryPadding: xCategoryPadding,
|
|
67
|
-
domain: xDomain,
|
|
68
|
-
domainLimit: xDomainLimit,
|
|
69
|
-
range: xRange,
|
|
70
|
-
baseline: xBaseline,
|
|
71
|
-
id: xAxisId
|
|
72
|
-
} = _ref2,
|
|
73
|
-
xAxisVisualProps = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
74
|
-
const _ref3 = yAxis || {},
|
|
75
|
-
{
|
|
76
|
-
scaleType: yScaleType,
|
|
77
|
-
data: yData,
|
|
78
|
-
categoryPadding: yCategoryPadding,
|
|
79
|
-
domain: yDomain,
|
|
80
|
-
domainLimit: yDomainLimit,
|
|
81
|
-
range: yRange,
|
|
82
|
-
baseline: yBaseline,
|
|
83
|
-
id: yAxisId
|
|
84
|
-
} = _ref3,
|
|
85
|
-
yAxisVisualProps = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
86
|
-
const xAxisConfig = {
|
|
87
|
-
scaleType: xScaleType,
|
|
88
|
-
data: xData,
|
|
89
|
-
categoryPadding: xCategoryPadding,
|
|
90
|
-
domain: xDomain,
|
|
91
|
-
domainLimit: xDomainLimit,
|
|
92
|
-
range: xRange,
|
|
93
|
-
baseline: xBaseline
|
|
94
|
-
};
|
|
95
|
-
const yAxisConfig = {
|
|
96
|
-
scaleType: yScaleType,
|
|
97
|
-
data: yData,
|
|
98
|
-
categoryPadding: yCategoryPadding,
|
|
99
|
-
domain: yDomain,
|
|
100
|
-
domainLimit: yDomainLimit,
|
|
101
|
-
range: yRange,
|
|
102
|
-
baseline: yBaseline
|
|
103
|
-
};
|
|
104
|
-
const categoryAxisData = layout === 'horizontal' ? yData : xData;
|
|
105
|
-
const lineChartDataLength = useMemo(() => {
|
|
106
|
-
if (categoryAxisData && categoryAxisData.length > 0) return categoryAxisData.length;
|
|
107
|
-
if (!series || series.length === 0) return 0;
|
|
108
|
-
return series.reduce((max, s) => {
|
|
109
|
-
var _s$data$length, _s$data;
|
|
110
|
-
return Math.max(max, (_s$data$length = (_s$data = s.data) == null ? void 0 : _s$data.length) != null ? _s$data$length : 0);
|
|
111
|
-
}, 0);
|
|
112
|
-
}, [categoryAxisData, series]);
|
|
113
|
-
const resolvedScrubberAccessibilityLabelStep = useMemo(() => scrubberAccessibilityLabelStep != null ? scrubberAccessibilityLabelStep : getDefaultScrubberAccessibilityStep(lineChartDataLength), [scrubberAccessibilityLabelStep, lineChartDataLength]);
|
|
114
|
-
return /*#__PURE__*/_jsxs(CartesianChart, _extends({}, chartProps, {
|
|
115
|
-
ref: ref,
|
|
116
|
-
inset: inset,
|
|
117
|
-
layout: layout,
|
|
118
|
-
scrubberAccessibilityLabelStep: resolvedScrubberAccessibilityLabelStep,
|
|
119
|
-
series: chartSeries,
|
|
120
|
-
xAxis: xAxisConfig,
|
|
121
|
-
yAxis: yAxisConfig,
|
|
122
|
-
children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _extends({
|
|
123
|
-
axisId: xAxisId
|
|
124
|
-
}, xAxisVisualProps)), showYAxis && /*#__PURE__*/_jsx(YAxis, _extends({
|
|
125
|
-
axisId: yAxisId
|
|
126
|
-
}, yAxisVisualProps)), series == null ? void 0 : series.map(_ref4 => {
|
|
127
|
-
let {
|
|
128
|
-
id
|
|
129
|
-
} = _ref4,
|
|
130
|
-
linePropsFromSeries = _objectWithoutPropertiesLoose(_ref4, _excluded4);
|
|
131
|
-
return /*#__PURE__*/_jsx(Line, _extends({
|
|
132
|
-
AreaComponent: AreaComponent,
|
|
133
|
-
LineComponent: LineComponent,
|
|
134
|
-
areaType: areaType,
|
|
135
|
-
connectNulls: connectNulls,
|
|
136
|
-
curve: curve,
|
|
137
|
-
opacity: opacity,
|
|
138
|
-
points: points,
|
|
139
|
-
seriesId: id,
|
|
140
|
-
showArea: showArea,
|
|
141
|
-
strokeOpacity: strokeOpacity,
|
|
142
|
-
strokeWidth: strokeWidth,
|
|
143
|
-
transition: transition,
|
|
144
|
-
transitions: transitions,
|
|
145
|
-
type: type
|
|
146
|
-
}, linePropsFromSeries), id);
|
|
147
|
-
}), children]
|
|
148
|
-
}));
|
|
149
|
-
}));
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { memo } from 'react';
|
|
2
|
-
import { useDerivedValue } from 'react-native-reanimated';
|
|
3
|
-
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
4
|
-
import { useCartesianChartContext } from '../ChartProvider';
|
|
5
|
-
import { unwrapAnimatedValue } from '../utils';
|
|
6
|
-
import { getPointOnSerializableScale } from '../utils/point';
|
|
7
|
-
import { DefaultReferenceLineLabel } from './DefaultReferenceLineLabel';
|
|
8
|
-
import { DottedLine } from './DottedLine';
|
|
9
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
-
export const ReferenceLine = /*#__PURE__*/memo(_ref => {
|
|
11
|
-
let {
|
|
12
|
-
dataX,
|
|
13
|
-
dataY,
|
|
14
|
-
yAxisId,
|
|
15
|
-
label,
|
|
16
|
-
labelPosition = dataY !== undefined ? 'right' : 'top',
|
|
17
|
-
LineComponent = DottedLine,
|
|
18
|
-
LabelComponent = DefaultReferenceLineLabel,
|
|
19
|
-
labelElevated,
|
|
20
|
-
labelFont,
|
|
21
|
-
labelDx,
|
|
22
|
-
labelDy,
|
|
23
|
-
labelHorizontalAlignment,
|
|
24
|
-
labelVerticalAlignment,
|
|
25
|
-
labelBoundsInset,
|
|
26
|
-
stroke,
|
|
27
|
-
opacity = 1
|
|
28
|
-
} = _ref;
|
|
29
|
-
const theme = useTheme();
|
|
30
|
-
const {
|
|
31
|
-
getXSerializableScale,
|
|
32
|
-
getYSerializableScale,
|
|
33
|
-
drawingArea
|
|
34
|
-
} = useCartesianChartContext();
|
|
35
|
-
const xScale = getXSerializableScale();
|
|
36
|
-
const yScale = getYSerializableScale(yAxisId);
|
|
37
|
-
const effectiveLineStroke = stroke != null ? stroke : theme.color.bgLine;
|
|
38
|
-
|
|
39
|
-
// For horizontal lines (dataY defined): default to verticalAlignment: 'middle'
|
|
40
|
-
// For vertical lines (dataX defined): default to horizontalAlignment: 'center'
|
|
41
|
-
const isHorizontal = dataY !== undefined;
|
|
42
|
-
const xPixel = useDerivedValue(() => {
|
|
43
|
-
const dataXValue = unwrapAnimatedValue(dataX);
|
|
44
|
-
return dataXValue !== undefined && xScale ? getPointOnSerializableScale(dataXValue, xScale) : undefined;
|
|
45
|
-
}, [dataX, xScale]);
|
|
46
|
-
const yPixel = useDerivedValue(() => {
|
|
47
|
-
const dataYValue = unwrapAnimatedValue(dataY);
|
|
48
|
-
return dataYValue !== undefined && yScale ? getPointOnSerializableScale(dataYValue, yScale) : undefined;
|
|
49
|
-
}, [dataY, yScale]);
|
|
50
|
-
const horizontalLine = useDerivedValue(() => {
|
|
51
|
-
if (yPixel.value === undefined) return;
|
|
52
|
-
return "M" + drawingArea.x + "," + yPixel.value + " L" + (drawingArea.x + drawingArea.width) + "," + yPixel.value;
|
|
53
|
-
}, [drawingArea, yPixel]);
|
|
54
|
-
const verticalLine = useDerivedValue(() => {
|
|
55
|
-
if (xPixel.value === undefined) return;
|
|
56
|
-
return "M" + xPixel.value + "," + drawingArea.y + " L" + xPixel.value + "," + (drawingArea.y + drawingArea.height);
|
|
57
|
-
}, [drawingArea, xPixel]);
|
|
58
|
-
const labelXPixel = useDerivedValue(() => {
|
|
59
|
-
var _xPixel$value;
|
|
60
|
-
return (_xPixel$value = xPixel.value) != null ? _xPixel$value : 0;
|
|
61
|
-
}, [xPixel]);
|
|
62
|
-
const labelYPixel = useDerivedValue(() => {
|
|
63
|
-
var _yPixel$value;
|
|
64
|
-
return (_yPixel$value = yPixel.value) != null ? _yPixel$value : 0;
|
|
65
|
-
}, [yPixel]);
|
|
66
|
-
const labelOpacity = useDerivedValue(() => {
|
|
67
|
-
const isVisible = dataY !== undefined && yPixel.value !== undefined || dataX !== undefined && xPixel.value !== undefined;
|
|
68
|
-
return isVisible ? unwrapAnimatedValue(opacity) : 0;
|
|
69
|
-
}, [yPixel, xPixel, opacity]);
|
|
70
|
-
if (dataY !== undefined) {
|
|
71
|
-
let labelX;
|
|
72
|
-
if (labelPosition === 'left') {
|
|
73
|
-
labelX = drawingArea.x;
|
|
74
|
-
} else if (labelPosition === 'center') {
|
|
75
|
-
labelX = drawingArea.x + drawingArea.width / 2;
|
|
76
|
-
} else {
|
|
77
|
-
labelX = drawingArea.x + drawingArea.width;
|
|
78
|
-
}
|
|
79
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
80
|
-
children: [/*#__PURE__*/_jsx(LineComponent, {
|
|
81
|
-
animate: false,
|
|
82
|
-
d: horizontalLine,
|
|
83
|
-
stroke: effectiveLineStroke,
|
|
84
|
-
strokeOpacity: opacity
|
|
85
|
-
}), label && /*#__PURE__*/_jsx(LabelComponent, {
|
|
86
|
-
boundsInset: labelBoundsInset,
|
|
87
|
-
dx: labelDx,
|
|
88
|
-
dy: labelDy,
|
|
89
|
-
elevated: labelElevated,
|
|
90
|
-
font: labelFont,
|
|
91
|
-
horizontalAlignment: labelHorizontalAlignment,
|
|
92
|
-
opacity: labelOpacity,
|
|
93
|
-
verticalAlignment: labelVerticalAlignment != null ? labelVerticalAlignment : isHorizontal ? 'middle' : undefined,
|
|
94
|
-
x: labelX,
|
|
95
|
-
y: labelYPixel,
|
|
96
|
-
children: label
|
|
97
|
-
})]
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Vertical reference line logic
|
|
102
|
-
if (dataX !== undefined) {
|
|
103
|
-
let labelY;
|
|
104
|
-
if (labelPosition === 'top') {
|
|
105
|
-
labelY = drawingArea.y;
|
|
106
|
-
} else if (labelPosition === 'middle') {
|
|
107
|
-
labelY = drawingArea.y + drawingArea.height / 2;
|
|
108
|
-
} else {
|
|
109
|
-
labelY = drawingArea.y + drawingArea.height;
|
|
110
|
-
}
|
|
111
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
112
|
-
children: [/*#__PURE__*/_jsx(LineComponent, {
|
|
113
|
-
animate: false,
|
|
114
|
-
d: verticalLine,
|
|
115
|
-
stroke: effectiveLineStroke,
|
|
116
|
-
strokeOpacity: opacity
|
|
117
|
-
}), label && /*#__PURE__*/_jsx(LabelComponent, {
|
|
118
|
-
boundsInset: labelBoundsInset,
|
|
119
|
-
dx: labelDx,
|
|
120
|
-
dy: labelDy,
|
|
121
|
-
elevated: labelElevated,
|
|
122
|
-
font: labelFont,
|
|
123
|
-
horizontalAlignment: labelHorizontalAlignment != null ? labelHorizontalAlignment : !isHorizontal ? 'center' : undefined,
|
|
124
|
-
opacity: labelOpacity,
|
|
125
|
-
verticalAlignment: labelVerticalAlignment,
|
|
126
|
-
x: labelXPixel,
|
|
127
|
-
y: labelY,
|
|
128
|
-
children: label
|
|
129
|
-
})]
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
const _excluded = ["fill", "stroke", "strokeCap", "strokeJoin", "strokeOpacity", "strokeWidth", "gradient", "xAxisId", "yAxisId", "d", "animate", "transitions", "transition"];
|
|
2
|
-
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); }
|
|
3
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
-
import { memo } from 'react';
|
|
5
|
-
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
6
|
-
import { Gradient } from '../gradient';
|
|
7
|
-
import { Path } from '../Path';
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
/**
|
|
10
|
-
* A customizable solid line component.
|
|
11
|
-
* Supports gradient for gradient effects and smooth data transitions via AnimatedPath.
|
|
12
|
-
*/
|
|
13
|
-
export const SolidLine = /*#__PURE__*/memo(_ref => {
|
|
14
|
-
var _transitions$update;
|
|
15
|
-
let {
|
|
16
|
-
fill = 'none',
|
|
17
|
-
stroke,
|
|
18
|
-
strokeCap = 'round',
|
|
19
|
-
strokeJoin = 'round',
|
|
20
|
-
strokeOpacity = 1,
|
|
21
|
-
strokeWidth = 2,
|
|
22
|
-
gradient,
|
|
23
|
-
xAxisId,
|
|
24
|
-
yAxisId,
|
|
25
|
-
d,
|
|
26
|
-
animate,
|
|
27
|
-
transitions,
|
|
28
|
-
transition
|
|
29
|
-
} = _ref,
|
|
30
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
31
|
-
const theme = useTheme();
|
|
32
|
-
return /*#__PURE__*/_jsx(Path, _extends({
|
|
33
|
-
animate: animate,
|
|
34
|
-
clipOffset: strokeWidth,
|
|
35
|
-
d: d,
|
|
36
|
-
fill: fill,
|
|
37
|
-
stroke: stroke != null ? stroke : theme.color.fgPrimary,
|
|
38
|
-
strokeCap: strokeCap,
|
|
39
|
-
strokeJoin: strokeJoin,
|
|
40
|
-
strokeOpacity: strokeOpacity,
|
|
41
|
-
strokeWidth: strokeWidth,
|
|
42
|
-
transition: transition,
|
|
43
|
-
transitions: transitions
|
|
44
|
-
}, props, {
|
|
45
|
-
children: gradient && /*#__PURE__*/_jsx(Gradient, {
|
|
46
|
-
animate: animate,
|
|
47
|
-
gradient: gradient,
|
|
48
|
-
transition: (_transitions$update = transitions == null ? void 0 : transitions.update) != null ? _transitions$update : transition,
|
|
49
|
-
xAxisId: xAxisId,
|
|
50
|
-
yAxisId: yAxisId
|
|
51
|
-
})
|
|
52
|
-
}));
|
|
53
|
-
});
|