@coinbase/cds-mobile-visualization 3.4.0-beta.2 → 3.4.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +122 -0
- package/dts/chart/CartesianChart.d.ts +92 -34
- package/dts/chart/CartesianChart.d.ts.map +1 -1
- package/dts/chart/ChartContextBridge.d.ts +28 -0
- package/dts/chart/ChartContextBridge.d.ts.map +1 -0
- package/dts/chart/ChartProvider.d.ts +3 -0
- package/dts/chart/ChartProvider.d.ts.map +1 -1
- package/dts/chart/Path.d.ts +97 -32
- package/dts/chart/Path.d.ts.map +1 -1
- package/dts/chart/PeriodSelector.d.ts +6 -13
- package/dts/chart/PeriodSelector.d.ts.map +1 -1
- package/dts/chart/area/Area.d.ts +39 -28
- package/dts/chart/area/Area.d.ts.map +1 -1
- package/dts/chart/area/AreaChart.d.ts +51 -10
- package/dts/chart/area/AreaChart.d.ts.map +1 -1
- package/dts/chart/area/DottedArea.d.ts +21 -2
- package/dts/chart/area/DottedArea.d.ts.map +1 -1
- package/dts/chart/area/GradientArea.d.ts +19 -13
- package/dts/chart/area/GradientArea.d.ts.map +1 -1
- package/dts/chart/area/SolidArea.d.ts +17 -2
- package/dts/chart/area/SolidArea.d.ts.map +1 -1
- package/dts/chart/axis/Axis.d.ts +86 -118
- package/dts/chart/axis/Axis.d.ts.map +1 -1
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
- package/dts/chart/axis/XAxis.d.ts +1 -1
- package/dts/chart/axis/XAxis.d.ts.map +1 -1
- package/dts/chart/axis/YAxis.d.ts +2 -2
- package/dts/chart/axis/YAxis.d.ts.map +1 -1
- package/dts/chart/axis/index.d.ts +1 -0
- package/dts/chart/axis/index.d.ts.map +1 -1
- package/dts/chart/bar/Bar.d.ts +49 -12
- package/dts/chart/bar/Bar.d.ts.map +1 -1
- package/dts/chart/bar/BarChart.d.ts +40 -19
- package/dts/chart/bar/BarChart.d.ts.map +1 -1
- package/dts/chart/bar/BarPlot.d.ts +3 -1
- package/dts/chart/bar/BarPlot.d.ts.map +1 -1
- package/dts/chart/bar/BarStack.d.ts +41 -46
- package/dts/chart/bar/BarStack.d.ts.map +1 -1
- package/dts/chart/bar/BarStackGroup.d.ts +2 -0
- package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
- package/dts/chart/bar/DefaultBar.d.ts +1 -1
- package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
- package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
- package/dts/chart/gradient/Gradient.d.ts +25 -0
- package/dts/chart/gradient/Gradient.d.ts.map +1 -0
- package/dts/chart/gradient/index.d.ts +2 -0
- package/dts/chart/gradient/index.d.ts.map +1 -0
- package/dts/chart/index.d.ts +4 -1
- package/dts/chart/index.d.ts.map +1 -1
- package/dts/chart/legend/DefaultLegendEntry.d.ts +5 -0
- package/dts/chart/legend/DefaultLegendEntry.d.ts.map +1 -0
- package/dts/chart/legend/DefaultLegendShape.d.ts +5 -0
- package/dts/chart/legend/DefaultLegendShape.d.ts.map +1 -0
- package/dts/chart/legend/Legend.d.ts +168 -0
- package/dts/chart/legend/Legend.d.ts.map +1 -0
- package/dts/chart/legend/index.d.ts +4 -0
- package/dts/chart/legend/index.d.ts.map +1 -0
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
- package/dts/chart/line/DottedLine.d.ts +13 -5
- package/dts/chart/line/DottedLine.d.ts.map +1 -1
- package/dts/chart/line/Line.d.ts +61 -27
- package/dts/chart/line/Line.d.ts.map +1 -1
- package/dts/chart/line/LineChart.d.ts +43 -9
- package/dts/chart/line/LineChart.d.ts.map +1 -1
- package/dts/chart/line/ReferenceLine.d.ts +68 -20
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
- package/dts/chart/line/SolidLine.d.ts +8 -5
- package/dts/chart/line/SolidLine.d.ts.map +1 -1
- package/dts/chart/line/index.d.ts +1 -1
- package/dts/chart/line/index.d.ts.map +1 -1
- package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
- package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
- package/dts/chart/point/Point.d.ts +136 -0
- package/dts/chart/point/Point.d.ts.map +1 -0
- package/dts/chart/point/index.d.ts +3 -0
- package/dts/chart/point/index.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +38 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +11 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/Scrubber.d.ts +230 -42
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +54 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +46 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberProvider.d.ts +6 -3
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -1
- package/dts/chart/scrubber/index.d.ts +3 -0
- package/dts/chart/scrubber/index.d.ts.map +1 -1
- package/dts/chart/text/ChartText.d.ts +151 -77
- package/dts/chart/text/ChartText.d.ts.map +1 -1
- package/dts/chart/text/{SmartChartTextGroup.d.ts → ChartTextGroup.d.ts} +9 -3
- package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
- package/dts/chart/text/index.d.ts +1 -1
- package/dts/chart/text/index.d.ts.map +1 -1
- package/dts/chart/utils/axis.d.ts +25 -1
- package/dts/chart/utils/axis.d.ts.map +1 -1
- package/dts/chart/utils/bar.d.ts +34 -0
- package/dts/chart/utils/bar.d.ts.map +1 -1
- package/dts/chart/utils/chart.d.ts +52 -7
- package/dts/chart/utils/chart.d.ts.map +1 -1
- package/dts/chart/utils/context.d.ts +28 -7
- package/dts/chart/utils/context.d.ts.map +1 -1
- package/dts/chart/utils/gradient.d.ts +117 -0
- package/dts/chart/utils/gradient.d.ts.map +1 -0
- package/dts/chart/utils/index.d.ts +3 -0
- package/dts/chart/utils/index.d.ts.map +1 -1
- package/dts/chart/utils/path.d.ts +59 -0
- package/dts/chart/utils/path.d.ts.map +1 -1
- package/dts/chart/utils/point.d.ts +71 -7
- package/dts/chart/utils/point.d.ts.map +1 -1
- package/dts/chart/utils/scale.d.ts +102 -0
- package/dts/chart/utils/scale.d.ts.map +1 -1
- package/dts/chart/utils/scrubber.d.ts +40 -0
- package/dts/chart/utils/scrubber.d.ts.map +1 -0
- package/dts/chart/utils/transition.d.ts +178 -0
- package/dts/chart/utils/transition.d.ts.map +1 -0
- package/esm/chart/CartesianChart.js +199 -75
- package/esm/chart/ChartContextBridge.js +159 -0
- package/esm/chart/ChartProvider.js +2 -2
- package/esm/chart/Path.js +200 -114
- package/esm/chart/PeriodSelector.js +7 -3
- package/esm/chart/__stories__/CartesianChart.stories.js +307 -134
- package/esm/chart/__stories__/ChartTransitions.stories.js +629 -0
- package/esm/chart/__stories__/PeriodSelector.stories.js +201 -75
- package/esm/chart/area/Area.js +27 -35
- package/esm/chart/area/AreaChart.js +17 -12
- package/esm/chart/area/DottedArea.js +64 -108
- package/esm/chart/area/GradientArea.js +37 -91
- package/esm/chart/area/SolidArea.js +24 -8
- package/esm/chart/area/__stories__/AreaChart.stories.js +1 -1
- package/esm/chart/axis/Axis.js +5 -39
- package/esm/chart/axis/DefaultAxisTickLabel.js +11 -0
- package/esm/chart/axis/XAxis.js +148 -66
- package/esm/chart/axis/YAxis.js +149 -65
- package/esm/chart/axis/__stories__/Axis.stories.js +259 -1
- package/esm/chart/axis/index.js +1 -0
- package/esm/chart/bar/Bar.js +7 -1
- package/esm/chart/bar/BarChart.js +17 -37
- package/esm/chart/bar/BarPlot.js +43 -35
- package/esm/chart/bar/BarStack.js +84 -37
- package/esm/chart/bar/BarStackGroup.js +7 -17
- package/esm/chart/bar/DefaultBar.js +29 -51
- package/esm/chart/bar/DefaultBarStack.js +34 -58
- package/esm/chart/bar/__stories__/BarChart.stories.js +948 -88
- package/esm/chart/gradient/Gradient.js +53 -0
- package/esm/chart/gradient/index.js +1 -0
- package/esm/chart/index.js +4 -1
- package/esm/chart/legend/DefaultLegendEntry.js +42 -0
- package/esm/chart/legend/DefaultLegendShape.js +64 -0
- package/esm/chart/legend/Legend.js +59 -0
- package/esm/chart/legend/__stories__/Legend.stories.js +574 -0
- package/esm/chart/legend/index.js +3 -0
- package/esm/chart/line/DefaultReferenceLineLabel.js +66 -0
- package/esm/chart/line/DottedLine.js +31 -14
- package/esm/chart/line/Line.js +96 -68
- package/esm/chart/line/LineChart.js +21 -14
- package/esm/chart/line/ReferenceLine.js +80 -63
- package/esm/chart/line/SolidLine.js +27 -10
- package/esm/chart/line/__stories__/LineChart.stories.js +1748 -2048
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +177 -28
- package/esm/chart/line/index.js +1 -1
- package/esm/chart/point/DefaultPointLabel.js +39 -0
- package/esm/chart/point/Point.js +186 -0
- package/esm/chart/point/index.js +2 -0
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +180 -0
- package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +43 -0
- package/esm/chart/scrubber/DefaultScrubberLabel.js +28 -0
- package/esm/chart/scrubber/Scrubber.js +130 -144
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +165 -0
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +208 -0
- package/esm/chart/scrubber/ScrubberProvider.js +46 -54
- package/esm/chart/scrubber/__stories__/Scrubber.stories.js +760 -0
- package/esm/chart/scrubber/index.js +3 -1
- package/esm/chart/text/ChartText.js +242 -174
- package/esm/chart/text/{SmartChartTextGroup.js → ChartTextGroup.js} +6 -5
- package/esm/chart/text/index.js +1 -1
- package/esm/chart/utils/axis.js +47 -31
- package/esm/chart/utils/bar.js +43 -0
- package/esm/chart/utils/chart.js +57 -3
- package/esm/chart/utils/gradient.js +305 -0
- package/esm/chart/utils/index.js +3 -0
- package/esm/chart/utils/path.js +84 -8
- package/esm/chart/utils/point.js +171 -17
- package/esm/chart/utils/scale.js +242 -2
- package/esm/chart/utils/scrubber.js +146 -0
- package/esm/chart/utils/transition.js +220 -0
- package/esm/sparkline/__figma__/Sparkline.figma.js +1 -1
- package/esm/sparkline/__stories__/Sparkline.stories.js +11 -7
- package/esm/sparkline/__stories__/SparklineGradient.stories.js +7 -4
- package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +1 -1
- package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +51 -26
- package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +1 -1
- package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +17 -9
- package/package.json +15 -10
- package/dts/chart/Point.d.ts +0 -103
- package/dts/chart/Point.d.ts.map +0 -1
- package/dts/chart/line/GradientLine.d.ts +0 -45
- package/dts/chart/line/GradientLine.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberBeacon.d.ts +0 -75
- package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +0 -1
- package/dts/chart/text/SmartChartTextGroup.d.ts.map +0 -1
- package/esm/chart/Point.js +0 -111
- package/esm/chart/__stories__/Chart.stories.js +0 -79
- package/esm/chart/line/GradientLine.js +0 -62
- package/esm/chart/scrubber/ScrubberBeacon.js +0 -199
|
@@ -1,128 +1,84 @@
|
|
|
1
|
-
const _excluded = ["d", "fill", "
|
|
1
|
+
const _excluded = ["d", "fill", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "animate", "transitions", "transition"];
|
|
2
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
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,
|
|
5
|
-
import { Circle, Defs, G, LinearGradient, Mask, Pattern, Stop } from 'react-native-svg';
|
|
4
|
+
import { memo, useMemo } from 'react';
|
|
6
5
|
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
6
|
+
import { Group, Skia } from '@shopify/react-native-skia';
|
|
7
7
|
import { useCartesianChartContext } from '../ChartProvider';
|
|
8
|
+
import { Gradient } from '../gradient';
|
|
8
9
|
import { Path } from '../Path';
|
|
9
|
-
import {
|
|
10
|
+
import { createGradient, getBaseline } from '../utils';
|
|
11
|
+
import { getDottedAreaPath } from '../utils/path';
|
|
12
|
+
import { usePathTransition } from '../utils/transition';
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
/**
|
|
15
|
+
* A customizable dotted area gradient component.
|
|
16
|
+
* When no gradient is provided, renders a default gradient based
|
|
17
|
+
* on the fill color and peak/baseline opacities.
|
|
18
|
+
*/
|
|
10
19
|
export const DottedArea = /*#__PURE__*/memo(_ref => {
|
|
11
20
|
let {
|
|
12
21
|
d,
|
|
13
|
-
fill,
|
|
14
|
-
fillOpacity = 1,
|
|
22
|
+
fill: fillProp,
|
|
15
23
|
patternSize = 4,
|
|
16
24
|
dotSize = 1,
|
|
17
25
|
peakOpacity = 1,
|
|
18
26
|
baselineOpacity = 0,
|
|
19
27
|
baseline,
|
|
20
28
|
yAxisId,
|
|
21
|
-
|
|
29
|
+
gradient: gradientProp,
|
|
30
|
+
animate: animateProp,
|
|
31
|
+
transitions,
|
|
32
|
+
transition
|
|
22
33
|
} = _ref,
|
|
23
34
|
pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
24
35
|
const theme = useTheme();
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (minValue >= 0) {
|
|
46
|
-
// All positive: baseline at min
|
|
47
|
-
dataBaseline = minValue;
|
|
48
|
-
} else if (maxValue <= 0) {
|
|
49
|
-
// All negative: baseline at max
|
|
50
|
-
dataBaseline = maxValue;
|
|
51
|
-
} else {
|
|
52
|
-
// Crosses zero: baseline at 0
|
|
53
|
-
dataBaseline = 0;
|
|
36
|
+
const {
|
|
37
|
+
drawingArea,
|
|
38
|
+
animate,
|
|
39
|
+
getYAxis
|
|
40
|
+
} = useCartesianChartContext();
|
|
41
|
+
const yAxisConfig = getYAxis(yAxisId);
|
|
42
|
+
const fill = useMemo(() => fillProp != null ? fillProp : theme.color.fgPrimary, [fillProp, theme.color.fgPrimary]);
|
|
43
|
+
const dottedPath = useMemo(() => {
|
|
44
|
+
if (!drawingArea) return '';
|
|
45
|
+
return getDottedAreaPath({
|
|
46
|
+
x: drawingArea.x,
|
|
47
|
+
y: drawingArea.y,
|
|
48
|
+
width: drawingArea.width,
|
|
49
|
+
height: drawingArea.height
|
|
50
|
+
}, patternSize, dotSize);
|
|
51
|
+
}, [drawingArea, patternSize, dotSize]);
|
|
52
|
+
const animatedClipPath = usePathTransition({
|
|
53
|
+
currentPath: d,
|
|
54
|
+
transitions: {
|
|
55
|
+
update: transition
|
|
54
56
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
fill: effectiveFill,
|
|
82
|
-
r: dotSize
|
|
83
|
-
})
|
|
84
|
-
}), /*#__PURE__*/_jsx(LinearGradient, {
|
|
85
|
-
gradientUnits: useUserSpaceUnits ? 'userSpaceOnUse' : 'objectBoundingBox',
|
|
86
|
-
id: gradientId,
|
|
87
|
-
x1: useUserSpaceUnits ? '0' : '0%',
|
|
88
|
-
x2: useUserSpaceUnits ? '0' : '0%',
|
|
89
|
-
y1: gradientY1,
|
|
90
|
-
y2: gradientY2,
|
|
91
|
-
children: baselinePosition !== undefined || baselinePercentage !== undefined ? /* Diverging gradient: high opacity at extremes, low at baseline */
|
|
92
|
-
[/*#__PURE__*/_jsx(Stop, {
|
|
93
|
-
offset: "0%",
|
|
94
|
-
stopColor: "white",
|
|
95
|
-
stopOpacity: peakOpacity
|
|
96
|
-
}, "0"), /*#__PURE__*/_jsx(Stop, {
|
|
97
|
-
offset: baselinePercentage != null ? baselinePercentage : (baselinePosition - yRange[1]) / (yRange[0] - yRange[1]) * 100 + "%",
|
|
98
|
-
stopColor: "white",
|
|
99
|
-
stopOpacity: baselineOpacity
|
|
100
|
-
}, "1"), /*#__PURE__*/_jsx(Stop, {
|
|
101
|
-
offset: "100%",
|
|
102
|
-
stopColor: "white",
|
|
103
|
-
stopOpacity: peakOpacity
|
|
104
|
-
}, "2")] : /* Simple gradient from top to bottom */
|
|
105
|
-
[/*#__PURE__*/_jsx(Stop, {
|
|
106
|
-
offset: "0%",
|
|
107
|
-
stopColor: "white",
|
|
108
|
-
stopOpacity: peakOpacity
|
|
109
|
-
}, "0"), /*#__PURE__*/_jsx(Stop, {
|
|
110
|
-
offset: "100%",
|
|
111
|
-
stopColor: "white",
|
|
112
|
-
stopOpacity: baselineOpacity
|
|
113
|
-
}, "1")]
|
|
114
|
-
}), /*#__PURE__*/_jsx(Mask, {
|
|
115
|
-
id: maskId,
|
|
116
|
-
children: /*#__PURE__*/_jsx(Path, {
|
|
117
|
-
d: d,
|
|
118
|
-
fill: "url(#" + gradientId + ")"
|
|
119
|
-
})
|
|
120
|
-
})]
|
|
121
|
-
}), /*#__PURE__*/_jsx(Path, _extends({
|
|
122
|
-
clipRect: clipRect,
|
|
123
|
-
d: d,
|
|
124
|
-
fill: "url(#" + patternId + ")",
|
|
125
|
-
mask: "url(#" + maskId + ")"
|
|
126
|
-
}, pathProps))]
|
|
57
|
+
});
|
|
58
|
+
const staticClipPath = useMemo(() => {
|
|
59
|
+
var _Skia$Path$MakeFromSV;
|
|
60
|
+
if (!d) return;
|
|
61
|
+
return (_Skia$Path$MakeFromSV = Skia.Path.MakeFromSVGString(d)) != null ? _Skia$Path$MakeFromSV : undefined;
|
|
62
|
+
}, [d]);
|
|
63
|
+
const gradient = useMemo(() => {
|
|
64
|
+
if (gradientProp) return gradientProp;
|
|
65
|
+
if (!yAxisConfig) return;
|
|
66
|
+
const baselineValue = getBaseline(yAxisConfig.domain, baseline);
|
|
67
|
+
return createGradient(yAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity);
|
|
68
|
+
}, [gradientProp, yAxisConfig, fill, baseline, peakOpacity, baselineOpacity]);
|
|
69
|
+
return /*#__PURE__*/_jsx(Group, {
|
|
70
|
+
clip: animate ? animatedClipPath : staticClipPath,
|
|
71
|
+
children: /*#__PURE__*/_jsx(Path, _extends({
|
|
72
|
+
animate: animateProp != null ? animateProp : animate,
|
|
73
|
+
d: dottedPath,
|
|
74
|
+
fill: fill,
|
|
75
|
+
transition: transition,
|
|
76
|
+
transitions: transitions
|
|
77
|
+
}, pathProps, {
|
|
78
|
+
children: gradient && /*#__PURE__*/_jsx(Gradient, {
|
|
79
|
+
gradient: gradient,
|
|
80
|
+
yAxisId: yAxisId
|
|
81
|
+
})
|
|
82
|
+
}))
|
|
127
83
|
});
|
|
128
84
|
});
|
|
@@ -1,110 +1,56 @@
|
|
|
1
|
-
const _excluded = ["d", "fill", "fillOpacity", "
|
|
1
|
+
const _excluded = ["d", "fill", "fillOpacity", "gradient", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "animate", "transitions", "transition"];
|
|
2
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
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,
|
|
5
|
-
import { Defs, LinearGradient, Stop } from 'react-native-svg';
|
|
4
|
+
import { memo, useMemo } from 'react';
|
|
6
5
|
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
7
6
|
import { useCartesianChartContext } from '../ChartProvider';
|
|
7
|
+
import { Gradient } from '../gradient';
|
|
8
8
|
import { Path } from '../Path';
|
|
9
|
-
import {
|
|
9
|
+
import { createGradient, getBaseline } from '../utils';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
11
|
/**
|
|
11
|
-
* A customizable gradient area component
|
|
12
|
+
* A customizable gradient area component.
|
|
13
|
+
* When no gradient is provided, renders a default gradient based
|
|
14
|
+
* on the fill color and peak/baseline opacities.
|
|
12
15
|
*/
|
|
13
16
|
export const GradientArea = /*#__PURE__*/memo(_ref => {
|
|
14
17
|
let {
|
|
15
18
|
d,
|
|
16
|
-
fill,
|
|
19
|
+
fill: fillProp,
|
|
17
20
|
fillOpacity = 1,
|
|
18
|
-
|
|
19
|
-
baselineColor,
|
|
21
|
+
gradient: gradientProp,
|
|
20
22
|
peakOpacity = 0.3,
|
|
21
23
|
baselineOpacity = 0,
|
|
22
24
|
baseline,
|
|
23
25
|
yAxisId,
|
|
24
|
-
|
|
26
|
+
animate,
|
|
27
|
+
transitions,
|
|
28
|
+
transition
|
|
25
29
|
} = _ref,
|
|
26
30
|
pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
27
|
-
const
|
|
31
|
+
const {
|
|
32
|
+
getYAxis
|
|
33
|
+
} = useCartesianChartContext();
|
|
28
34
|
const theme = useTheme();
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
} else if (maxValue <= 0) {
|
|
51
|
-
// All negative: baseline at max
|
|
52
|
-
dataBaseline = maxValue;
|
|
53
|
-
} else {
|
|
54
|
-
// Crosses zero: baseline at 0
|
|
55
|
-
dataBaseline = 0;
|
|
56
|
-
}
|
|
57
|
-
if (useUserSpaceUnits && yRange) {
|
|
58
|
-
// Get the actual y coordinate for the baseline
|
|
59
|
-
const scaledValue = yScale(baseline != null ? baseline : dataBaseline);
|
|
60
|
-
if (typeof scaledValue === 'number') {
|
|
61
|
-
baselinePosition = scaledValue;
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
// Calculate percentage position
|
|
65
|
-
baselinePercentage = (maxValue - (baseline != null ? baseline : dataBaseline)) / (maxValue - minValue) * 100 + "%";
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
const effectiveFill = fill != null ? fill : theme.color.fgPrimary;
|
|
69
|
-
const effectivePeakColor = peakColor != null ? peakColor : effectiveFill;
|
|
70
|
-
const effectiveBaselineColor = baselineColor != null ? baselineColor : effectiveFill;
|
|
71
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
72
|
-
children: [/*#__PURE__*/_jsx(Defs, {
|
|
73
|
-
children: /*#__PURE__*/_jsx(LinearGradient, {
|
|
74
|
-
gradientUnits: useUserSpaceUnits ? 'userSpaceOnUse' : 'objectBoundingBox',
|
|
75
|
-
id: patternId,
|
|
76
|
-
x1: useUserSpaceUnits ? '0' : '0%',
|
|
77
|
-
x2: useUserSpaceUnits ? '0' : '0%',
|
|
78
|
-
y1: gradientY1,
|
|
79
|
-
y2: gradientY2,
|
|
80
|
-
children: baselinePosition !== undefined || baselinePercentage !== undefined ? /* Diverging gradient: peak opacity at extremes, baseline opacity at baseline */
|
|
81
|
-
[/*#__PURE__*/_jsx(Stop, {
|
|
82
|
-
offset: "0%",
|
|
83
|
-
stopColor: effectivePeakColor,
|
|
84
|
-
stopOpacity: peakOpacity
|
|
85
|
-
}, "0"), /*#__PURE__*/_jsx(Stop, {
|
|
86
|
-
offset: baselinePercentage != null ? baselinePercentage : (baselinePosition - yRange[1]) / (yRange[0] - yRange[1]) * 100 + "%",
|
|
87
|
-
stopColor: effectiveBaselineColor,
|
|
88
|
-
stopOpacity: baselineOpacity
|
|
89
|
-
}, "1"), /*#__PURE__*/_jsx(Stop, {
|
|
90
|
-
offset: "100%",
|
|
91
|
-
stopColor: effectivePeakColor,
|
|
92
|
-
stopOpacity: peakOpacity
|
|
93
|
-
}, "2")] : /* Simple gradient from peak to baseline */
|
|
94
|
-
[/*#__PURE__*/_jsx(Stop, {
|
|
95
|
-
offset: "0%",
|
|
96
|
-
stopColor: effectivePeakColor,
|
|
97
|
-
stopOpacity: peakOpacity
|
|
98
|
-
}, "0"), /*#__PURE__*/_jsx(Stop, {
|
|
99
|
-
offset: "100%",
|
|
100
|
-
stopColor: effectiveBaselineColor,
|
|
101
|
-
stopOpacity: baselineOpacity
|
|
102
|
-
}, "1")]
|
|
103
|
-
})
|
|
104
|
-
}), /*#__PURE__*/_jsx(Path, _extends({
|
|
105
|
-
clipRect: clipRect,
|
|
106
|
-
d: d,
|
|
107
|
-
fill: "url(#" + patternId + ")"
|
|
108
|
-
}, pathProps))]
|
|
109
|
-
});
|
|
35
|
+
const yAxisConfig = getYAxis(yAxisId);
|
|
36
|
+
const fill = useMemo(() => fillProp != null ? fillProp : theme.color.fgPrimary, [fillProp, theme.color.fgPrimary]);
|
|
37
|
+
const gradient = useMemo(() => {
|
|
38
|
+
if (gradientProp) return gradientProp;
|
|
39
|
+
if (!yAxisConfig) return;
|
|
40
|
+
const baselineValue = getBaseline(yAxisConfig.domain, baseline);
|
|
41
|
+
return createGradient(yAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity);
|
|
42
|
+
}, [gradientProp, yAxisConfig, fill, baseline, peakOpacity, baselineOpacity]);
|
|
43
|
+
return /*#__PURE__*/_jsx(Path, _extends({
|
|
44
|
+
animate: animate,
|
|
45
|
+
d: d,
|
|
46
|
+
fill: fill,
|
|
47
|
+
fillOpacity: fillOpacity,
|
|
48
|
+
transition: transition,
|
|
49
|
+
transitions: transitions
|
|
50
|
+
}, pathProps, {
|
|
51
|
+
children: gradient && /*#__PURE__*/_jsx(Gradient, {
|
|
52
|
+
gradient: gradient,
|
|
53
|
+
yAxisId: yAxisId
|
|
54
|
+
})
|
|
55
|
+
}));
|
|
110
56
|
});
|
|
@@ -1,24 +1,40 @@
|
|
|
1
|
-
const _excluded = ["d", "fill", "fillOpacity", "
|
|
1
|
+
const _excluded = ["d", "fill", "fillOpacity", "yAxisId", "animate", "transitions", "transition", "gradient"];
|
|
2
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
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
4
|
import { memo } from 'react';
|
|
5
|
+
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
6
|
+
import { Gradient } from '../gradient';
|
|
5
7
|
import { Path } from '../Path';
|
|
6
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
9
|
/**
|
|
8
|
-
* A customizable solid area component
|
|
10
|
+
* A customizable solid area component.
|
|
11
|
+
* When a gradient is provided, renders with gradient fill.
|
|
12
|
+
* Otherwise, renders with solid fill.
|
|
9
13
|
*/
|
|
10
14
|
export const SolidArea = /*#__PURE__*/memo(_ref => {
|
|
11
15
|
let {
|
|
12
16
|
d,
|
|
13
17
|
fill,
|
|
14
18
|
fillOpacity = 1,
|
|
15
|
-
|
|
19
|
+
yAxisId,
|
|
20
|
+
animate,
|
|
21
|
+
transitions,
|
|
22
|
+
transition,
|
|
23
|
+
gradient
|
|
16
24
|
} = _ref,
|
|
17
|
-
|
|
25
|
+
pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
26
|
+
const theme = useTheme();
|
|
18
27
|
return /*#__PURE__*/_jsx(Path, _extends({
|
|
19
|
-
|
|
28
|
+
animate: animate,
|
|
20
29
|
d: d,
|
|
21
|
-
fill: fill,
|
|
22
|
-
fillOpacity: fillOpacity
|
|
23
|
-
|
|
30
|
+
fill: fill != null ? fill : theme.color.fgPrimary,
|
|
31
|
+
fillOpacity: fillOpacity,
|
|
32
|
+
transition: transition,
|
|
33
|
+
transitions: transitions
|
|
34
|
+
}, pathProps, {
|
|
35
|
+
children: gradient && /*#__PURE__*/_jsx(Gradient, {
|
|
36
|
+
gradient: gradient,
|
|
37
|
+
yAxisId: yAxisId
|
|
38
|
+
})
|
|
39
|
+
}));
|
|
24
40
|
});
|
package/esm/chart/axis/Axis.js
CHANGED
|
@@ -1,43 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
* Animation variants for grouped axis tick labels - initial mount
|
|
3
|
-
*/
|
|
4
|
-
export const axisTickLabelsInitialAnimationVariants = {
|
|
5
|
-
initial: {
|
|
6
|
-
opacity: 0
|
|
7
|
-
},
|
|
8
|
-
animate: {
|
|
9
|
-
opacity: 1,
|
|
10
|
-
transition: {
|
|
11
|
-
duration: 0,
|
|
12
|
-
delay: 0
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
exit: {
|
|
16
|
-
opacity: 0,
|
|
17
|
-
transition: {
|
|
18
|
-
duration: 0.15
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
};
|
|
1
|
+
import { accessoryFadeTransitionDuration } from '../utils';
|
|
22
2
|
|
|
23
3
|
/**
|
|
24
|
-
* Animation
|
|
4
|
+
* Animation transition for axis elements (grid lines, tick marks, tick labels).
|
|
5
|
+
* Matches web's axisUpdateAnimationTransition timing.
|
|
25
6
|
*/
|
|
26
|
-
export const
|
|
27
|
-
|
|
28
|
-
opacity: 0
|
|
29
|
-
},
|
|
30
|
-
animate: {
|
|
31
|
-
opacity: 1,
|
|
32
|
-
transition: {
|
|
33
|
-
duration: 0.15,
|
|
34
|
-
delay: 0.15 // For updates: fade out 150ms, then fade in 150ms
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
exit: {
|
|
38
|
-
opacity: 0,
|
|
39
|
-
transition: {
|
|
40
|
-
duration: 0.15
|
|
41
|
-
}
|
|
42
|
-
}
|
|
7
|
+
export const axisUpdateAnimationTransition = {
|
|
8
|
+
duration: accessoryFadeTransitionDuration
|
|
43
9
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
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 } from 'react';
|
|
3
|
+
import { ChartText } from '../text';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
/**
|
|
6
|
+
* DefaultAxisTickLabel is the default label component for axis tick labels.
|
|
7
|
+
* Provides standard styling for both X and Y axis tick labels.
|
|
8
|
+
*/
|
|
9
|
+
export const DefaultAxisTickLabel = /*#__PURE__*/memo(props => {
|
|
10
|
+
return /*#__PURE__*/_jsx(ChartText, _extends({}, props));
|
|
11
|
+
});
|