@coinbase/cds-mobile-visualization 3.3.0 → 3.4.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -0
- package/dts/chart/CartesianChart.d.ts +125 -0
- package/dts/chart/CartesianChart.d.ts.map +1 -0
- package/dts/chart/ChartContextBridge.d.ts +28 -0
- package/dts/chart/ChartContextBridge.d.ts.map +1 -0
- package/dts/chart/ChartProvider.d.ts +6 -0
- package/dts/chart/ChartProvider.d.ts.map +1 -0
- package/dts/chart/Path.d.ts +91 -0
- package/dts/chart/Path.d.ts.map +1 -0
- package/dts/chart/PeriodSelector.d.ts +85 -0
- package/dts/chart/PeriodSelector.d.ts.map +1 -0
- package/dts/chart/area/Area.d.ts +77 -0
- package/dts/chart/area/Area.d.ts.map +1 -0
- package/dts/chart/area/AreaChart.d.ts +131 -0
- package/dts/chart/area/AreaChart.d.ts.map +1 -0
- package/dts/chart/area/DottedArea.d.ts +46 -0
- package/dts/chart/area/DottedArea.d.ts.map +1 -0
- package/dts/chart/area/GradientArea.d.ts +36 -0
- package/dts/chart/area/GradientArea.d.ts.map +1 -0
- package/dts/chart/area/SolidArea.d.ts +23 -0
- package/dts/chart/area/SolidArea.d.ts.map +1 -0
- package/dts/chart/area/index.d.ts +6 -0
- package/dts/chart/area/index.d.ts.map +1 -0
- package/dts/chart/axis/Axis.d.ts +194 -0
- package/dts/chart/axis/Axis.d.ts.map +1 -0
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
- package/dts/chart/axis/XAxis.d.ts +16 -0
- package/dts/chart/axis/XAxis.d.ts.map +1 -0
- package/dts/chart/axis/YAxis.d.ts +21 -0
- package/dts/chart/axis/YAxis.d.ts.map +1 -0
- package/dts/chart/axis/index.d.ts +5 -0
- package/dts/chart/axis/index.d.ts.map +1 -0
- package/dts/chart/bar/Bar.d.ts +92 -0
- package/dts/chart/bar/Bar.d.ts.map +1 -0
- package/dts/chart/bar/BarChart.d.ts +113 -0
- package/dts/chart/bar/BarChart.d.ts.map +1 -0
- package/dts/chart/bar/BarPlot.d.ts +30 -0
- package/dts/chart/bar/BarPlot.d.ts.map +1 -0
- package/dts/chart/bar/BarStack.d.ts +102 -0
- package/dts/chart/bar/BarStack.d.ts.map +1 -0
- package/dts/chart/bar/BarStackGroup.d.ts +36 -0
- package/dts/chart/bar/BarStackGroup.d.ts.map +1 -0
- package/dts/chart/bar/DefaultBar.d.ts +7 -0
- package/dts/chart/bar/DefaultBar.d.ts.map +1 -0
- package/dts/chart/bar/DefaultBarStack.d.ts +7 -0
- package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -0
- package/dts/chart/bar/index.d.ts +8 -0
- package/dts/chart/bar/index.d.ts.map +1 -0
- package/dts/chart/gradient/Gradient.d.ts +25 -0
- package/dts/chart/gradient/Gradient.d.ts.map +1 -0
- package/dts/chart/gradient/index.d.ts +2 -0
- package/dts/chart/gradient/index.d.ts.map +1 -0
- package/dts/chart/index.d.ts +15 -0
- package/dts/chart/index.d.ts.map +1 -0
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
- package/dts/chart/line/DottedLine.d.ts +20 -0
- package/dts/chart/line/DottedLine.d.ts.map +1 -0
- package/dts/chart/line/Line.d.ts +115 -0
- package/dts/chart/line/Line.d.ts.map +1 -0
- package/dts/chart/line/LineChart.d.ts +118 -0
- package/dts/chart/line/LineChart.d.ts.map +1 -0
- package/dts/chart/line/ReferenceLine.d.ts +139 -0
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -0
- package/dts/chart/line/SolidLine.d.ts +15 -0
- package/dts/chart/line/SolidLine.d.ts.map +1 -0
- package/dts/chart/line/index.d.ts +7 -0
- package/dts/chart/line/index.d.ts.map +1 -0
- package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
- package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
- package/dts/chart/point/Point.d.ts +120 -0
- package/dts/chart/point/Point.d.ts.map +1 -0
- package/dts/chart/point/index.d.ts +3 -0
- package/dts/chart/point/index.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +8 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +11 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/Scrubber.d.ts +233 -0
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +44 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +31 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberProvider.d.ts +20 -0
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -0
- package/dts/chart/scrubber/index.d.ts +5 -0
- package/dts/chart/scrubber/index.d.ts.map +1 -0
- package/dts/chart/text/ChartText.d.ts +164 -0
- package/dts/chart/text/ChartText.d.ts.map +1 -0
- package/dts/chart/text/ChartTextGroup.d.ts +61 -0
- package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
- package/dts/chart/text/index.d.ts +3 -0
- package/dts/chart/text/index.d.ts.map +1 -0
- package/dts/chart/utils/axis.d.ts +342 -0
- package/dts/chart/utils/axis.d.ts.map +1 -0
- package/dts/chart/utils/bar.d.ts +20 -0
- package/dts/chart/utils/bar.d.ts.map +1 -0
- package/dts/chart/utils/chart.d.ts +124 -0
- package/dts/chart/utils/chart.d.ts.map +1 -0
- package/dts/chart/utils/context.d.ts +116 -0
- package/dts/chart/utils/context.d.ts.map +1 -0
- package/dts/chart/utils/gradient.d.ts +117 -0
- package/dts/chart/utils/gradient.d.ts.map +1 -0
- package/dts/chart/utils/index.d.ts +11 -0
- package/dts/chart/utils/index.d.ts.map +1 -0
- package/dts/chart/utils/path.d.ts +160 -0
- package/dts/chart/utils/path.d.ts.map +1 -0
- package/dts/chart/utils/point.d.ts +134 -0
- package/dts/chart/utils/point.d.ts.map +1 -0
- package/dts/chart/utils/scale.d.ts +134 -0
- package/dts/chart/utils/scale.d.ts.map +1 -0
- package/dts/chart/utils/scrubber.d.ts +39 -0
- package/dts/chart/utils/scrubber.d.ts.map +1 -0
- package/dts/chart/utils/transition.d.ts +140 -0
- package/dts/chart/utils/transition.d.ts.map +1 -0
- package/dts/index.d.ts +2 -1
- package/dts/index.d.ts.map +1 -1
- package/dts/sparkline/Counter.d.ts +7 -2
- package/dts/sparkline/Sparkline.d.ts +67 -16
- package/dts/sparkline/Sparkline.d.ts.map +1 -1
- package/dts/sparkline/SparklineArea.d.ts +10 -4
- package/dts/sparkline/SparklineArea.d.ts.map +1 -1
- package/dts/sparkline/SparklineAreaPattern.d.ts +12 -4
- package/dts/sparkline/SparklineAreaPattern.d.ts.map +1 -1
- package/dts/sparkline/SparklineGradient.d.ts +21 -10
- package/dts/sparkline/SparklineGradient.d.ts.map +1 -1
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts +1 -1
- package/dts/sparkline/generateSparklineWithId.d.ts +8 -2
- package/dts/sparkline/generateSparklineWithId.d.ts.map +1 -1
- package/dts/sparkline/index.d.ts +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts +8 -3
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +132 -110
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +22 -9
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +18 -7
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +9 -4
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +11 -6
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts +7 -5
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts +22 -10
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +21 -7
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +21 -16
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +29 -23
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +22 -14
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +1 -1
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts +9 -5
- package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts +11 -6
- package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts +5 -2
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +17 -17
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts +16 -13
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +106 -98
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +1 -1
- package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts +22 -19
- package/esm/chart/CartesianChart.js +335 -0
- package/esm/chart/ChartContextBridge.js +148 -0
- package/esm/chart/ChartProvider.js +10 -0
- package/esm/chart/Path.js +218 -0
- package/esm/chart/PeriodSelector.js +136 -0
- package/esm/chart/__stories__/CartesianChart.stories.js +723 -0
- package/esm/chart/__stories__/Chart.stories.js +77 -0
- package/esm/chart/__stories__/PeriodSelector.stories.js +322 -0
- package/esm/chart/area/Area.js +75 -0
- package/esm/chart/area/AreaChart.js +151 -0
- package/esm/chart/area/DottedArea.js +80 -0
- package/esm/chart/area/GradientArea.js +54 -0
- package/esm/chart/area/SolidArea.js +38 -0
- package/esm/chart/area/__stories__/AreaChart.stories.js +100 -0
- package/esm/chart/area/index.js +7 -0
- package/esm/chart/axis/Axis.js +45 -0
- package/esm/chart/axis/DefaultAxisTickLabel.js +11 -0
- package/esm/chart/axis/XAxis.js +188 -0
- package/esm/chart/axis/YAxis.js +177 -0
- package/esm/chart/axis/__stories__/Axis.stories.js +276 -0
- package/esm/chart/axis/index.js +6 -0
- package/esm/chart/bar/Bar.js +69 -0
- package/esm/chart/bar/BarChart.js +125 -0
- package/esm/chart/bar/BarPlot.js +102 -0
- package/esm/chart/bar/BarStack.js +551 -0
- package/esm/chart/bar/BarStackGroup.js +79 -0
- package/esm/chart/bar/DefaultBar.js +56 -0
- package/esm/chart/bar/DefaultBarStack.js +47 -0
- package/esm/chart/bar/__stories__/BarChart.stories.js +668 -0
- package/esm/chart/bar/index.js +9 -0
- package/esm/chart/gradient/Gradient.js +53 -0
- package/esm/chart/gradient/index.js +1 -0
- package/esm/chart/index.js +16 -0
- package/esm/chart/line/DefaultReferenceLineLabel.js +66 -0
- package/esm/chart/line/DottedLine.js +50 -0
- package/esm/chart/line/Line.js +178 -0
- package/esm/chart/line/LineChart.js +121 -0
- package/esm/chart/line/ReferenceLine.js +132 -0
- package/esm/chart/line/SolidLine.js +46 -0
- package/esm/chart/line/__stories__/LineChart.stories.js +2372 -0
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +132 -0
- package/esm/chart/line/index.js +8 -0
- package/esm/chart/point/DefaultPointLabel.js +39 -0
- package/esm/chart/point/Point.js +188 -0
- package/esm/chart/point/index.js +2 -0
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +179 -0
- package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +43 -0
- package/esm/chart/scrubber/DefaultScrubberLabel.js +28 -0
- package/esm/chart/scrubber/Scrubber.js +166 -0
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +161 -0
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +185 -0
- package/esm/chart/scrubber/ScrubberProvider.js +135 -0
- package/esm/chart/scrubber/index.js +4 -0
- package/esm/chart/text/ChartText.js +305 -0
- package/esm/chart/text/ChartTextGroup.js +211 -0
- package/esm/chart/text/index.js +4 -0
- package/esm/chart/utils/axis.js +592 -0
- package/esm/chart/utils/bar.js +24 -0
- package/esm/chart/utils/chart.js +270 -0
- package/esm/chart/utils/context.js +15 -0
- package/esm/chart/utils/gradient.js +305 -0
- package/esm/chart/utils/index.js +12 -0
- package/esm/chart/utils/path.js +274 -0
- package/esm/chart/utils/point.js +229 -0
- package/esm/chart/utils/scale.js +277 -0
- package/esm/chart/utils/scrubber.js +139 -0
- package/esm/chart/utils/transition.js +185 -0
- package/esm/index.js +4 -1
- package/esm/sparkline/Sparkline.js +129 -16
- package/esm/sparkline/SparklineArea.js +7 -2
- package/esm/sparkline/SparklineAreaPattern.js +4 -2
- package/esm/sparkline/SparklineGradient.js +4 -0
- package/esm/sparkline/__stories__/Sparkline.stories.js +11 -7
- package/esm/sparkline/__stories__/SparklineGradient.stories.js +7 -4
- package/esm/sparkline/generateSparklineWithId.js +3 -2
- package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +5 -1
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +5 -2
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +4 -0
- package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +76 -24
- package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +17 -9
- package/package.json +17 -11
- package/dts/sparkline/__stories__/Sparkline.stories.d.ts +0 -3
- package/dts/sparkline/__stories__/Sparkline.stories.d.ts.map +0 -1
- package/dts/sparkline/__stories__/SparklineGradient.stories.d.ts +0 -3
- package/dts/sparkline/__stories__/SparklineGradient.stories.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts +0 -3
- package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveHoverDate.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveHoverDate.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePanGestureHandler.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePanGestureHandler.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveTimeseriesPaths.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveTimeseriesPaths.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/useMinMaxTransform.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/useMinMaxTransform.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts +0 -4
- package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/__tests__/useSparklineInteractiveHeaderStyles.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive-header/__tests__/useSparklineInteractiveHeaderStyles.test.d.ts.map +0 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const _excluded = ["d", "fill", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "animate", "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, useMemo } from 'react';
|
|
5
|
+
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
6
|
+
import { Group, Skia } from '@shopify/react-native-skia';
|
|
7
|
+
import { useCartesianChartContext } from '../ChartProvider';
|
|
8
|
+
import { Gradient } from '../gradient';
|
|
9
|
+
import { Path } from '../Path';
|
|
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
|
+
*/
|
|
19
|
+
export const DottedArea = /*#__PURE__*/memo(_ref => {
|
|
20
|
+
let {
|
|
21
|
+
d,
|
|
22
|
+
fill: fillProp,
|
|
23
|
+
patternSize = 4,
|
|
24
|
+
dotSize = 1,
|
|
25
|
+
peakOpacity = 1,
|
|
26
|
+
baselineOpacity = 0,
|
|
27
|
+
baseline,
|
|
28
|
+
yAxisId,
|
|
29
|
+
gradient: gradientProp,
|
|
30
|
+
animate: animateProp,
|
|
31
|
+
transition
|
|
32
|
+
} = _ref,
|
|
33
|
+
pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
34
|
+
const theme = useTheme();
|
|
35
|
+
const {
|
|
36
|
+
drawingArea,
|
|
37
|
+
animate,
|
|
38
|
+
getYAxis
|
|
39
|
+
} = useCartesianChartContext();
|
|
40
|
+
const yAxisConfig = getYAxis(yAxisId);
|
|
41
|
+
const fill = useMemo(() => fillProp != null ? fillProp : theme.color.fgPrimary, [fillProp, theme.color.fgPrimary]);
|
|
42
|
+
const dottedPath = useMemo(() => {
|
|
43
|
+
if (!drawingArea) return '';
|
|
44
|
+
return getDottedAreaPath({
|
|
45
|
+
x: drawingArea.x,
|
|
46
|
+
y: drawingArea.y,
|
|
47
|
+
width: drawingArea.width,
|
|
48
|
+
height: drawingArea.height
|
|
49
|
+
}, patternSize, dotSize);
|
|
50
|
+
}, [drawingArea, patternSize, dotSize]);
|
|
51
|
+
const animatedClipPath = usePathTransition({
|
|
52
|
+
currentPath: d,
|
|
53
|
+
transition
|
|
54
|
+
});
|
|
55
|
+
const staticClipPath = useMemo(() => {
|
|
56
|
+
var _Skia$Path$MakeFromSV;
|
|
57
|
+
if (!d) return;
|
|
58
|
+
return (_Skia$Path$MakeFromSV = Skia.Path.MakeFromSVGString(d)) != null ? _Skia$Path$MakeFromSV : undefined;
|
|
59
|
+
}, [d]);
|
|
60
|
+
const gradient = useMemo(() => {
|
|
61
|
+
if (gradientProp) return gradientProp;
|
|
62
|
+
if (!yAxisConfig) return;
|
|
63
|
+
const baselineValue = getBaseline(yAxisConfig.domain, baseline);
|
|
64
|
+
return createGradient(yAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity);
|
|
65
|
+
}, [gradientProp, yAxisConfig, fill, baseline, peakOpacity, baselineOpacity]);
|
|
66
|
+
return /*#__PURE__*/_jsx(Group, {
|
|
67
|
+
clip: animate ? animatedClipPath : staticClipPath,
|
|
68
|
+
children: /*#__PURE__*/_jsx(Path, _extends({
|
|
69
|
+
animate: animateProp != null ? animateProp : animate,
|
|
70
|
+
d: dottedPath,
|
|
71
|
+
fill: fill,
|
|
72
|
+
transition: transition
|
|
73
|
+
}, pathProps, {
|
|
74
|
+
children: gradient && /*#__PURE__*/_jsx(Gradient, {
|
|
75
|
+
gradient: gradient,
|
|
76
|
+
yAxisId: yAxisId
|
|
77
|
+
})
|
|
78
|
+
}))
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const _excluded = ["d", "fill", "fillOpacity", "gradient", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "animate", "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, useMemo } from 'react';
|
|
5
|
+
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
6
|
+
import { useCartesianChartContext } from '../ChartProvider';
|
|
7
|
+
import { Gradient } from '../gradient';
|
|
8
|
+
import { Path } from '../Path';
|
|
9
|
+
import { createGradient, getBaseline } from '../utils';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
/**
|
|
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.
|
|
15
|
+
*/
|
|
16
|
+
export const GradientArea = /*#__PURE__*/memo(_ref => {
|
|
17
|
+
let {
|
|
18
|
+
d,
|
|
19
|
+
fill: fillProp,
|
|
20
|
+
fillOpacity = 1,
|
|
21
|
+
gradient: gradientProp,
|
|
22
|
+
peakOpacity = 0.3,
|
|
23
|
+
baselineOpacity = 0,
|
|
24
|
+
baseline,
|
|
25
|
+
yAxisId,
|
|
26
|
+
animate,
|
|
27
|
+
transition
|
|
28
|
+
} = _ref,
|
|
29
|
+
pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
30
|
+
const {
|
|
31
|
+
getYAxis
|
|
32
|
+
} = useCartesianChartContext();
|
|
33
|
+
const theme = useTheme();
|
|
34
|
+
const yAxisConfig = getYAxis(yAxisId);
|
|
35
|
+
const fill = useMemo(() => fillProp != null ? fillProp : theme.color.fgPrimary, [fillProp, theme.color.fgPrimary]);
|
|
36
|
+
const gradient = useMemo(() => {
|
|
37
|
+
if (gradientProp) return gradientProp;
|
|
38
|
+
if (!yAxisConfig) return;
|
|
39
|
+
const baselineValue = getBaseline(yAxisConfig.domain, baseline);
|
|
40
|
+
return createGradient(yAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity);
|
|
41
|
+
}, [gradientProp, yAxisConfig, fill, baseline, peakOpacity, baselineOpacity]);
|
|
42
|
+
return /*#__PURE__*/_jsx(Path, _extends({
|
|
43
|
+
animate: animate,
|
|
44
|
+
d: d,
|
|
45
|
+
fill: fill,
|
|
46
|
+
fillOpacity: fillOpacity,
|
|
47
|
+
transition: transition
|
|
48
|
+
}, pathProps, {
|
|
49
|
+
children: gradient && /*#__PURE__*/_jsx(Gradient, {
|
|
50
|
+
gradient: gradient,
|
|
51
|
+
yAxisId: yAxisId
|
|
52
|
+
})
|
|
53
|
+
}));
|
|
54
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const _excluded = ["d", "fill", "fillOpacity", "yAxisId", "animate", "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 { 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 area component.
|
|
11
|
+
* When a gradient is provided, renders with gradient fill.
|
|
12
|
+
* Otherwise, renders with solid fill.
|
|
13
|
+
*/
|
|
14
|
+
export const SolidArea = /*#__PURE__*/memo(_ref => {
|
|
15
|
+
let {
|
|
16
|
+
d,
|
|
17
|
+
fill,
|
|
18
|
+
fillOpacity = 1,
|
|
19
|
+
yAxisId,
|
|
20
|
+
animate,
|
|
21
|
+
transition,
|
|
22
|
+
gradient
|
|
23
|
+
} = _ref,
|
|
24
|
+
pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
25
|
+
const theme = useTheme();
|
|
26
|
+
return /*#__PURE__*/_jsx(Path, _extends({
|
|
27
|
+
animate: animate,
|
|
28
|
+
d: d,
|
|
29
|
+
fill: fill != null ? fill : theme.color.fgPrimary,
|
|
30
|
+
fillOpacity: fillOpacity,
|
|
31
|
+
transition: transition
|
|
32
|
+
}, pathProps, {
|
|
33
|
+
children: gradient && /*#__PURE__*/_jsx(Gradient, {
|
|
34
|
+
gradient: gradient,
|
|
35
|
+
yAxisId: yAxisId
|
|
36
|
+
})
|
|
37
|
+
}));
|
|
38
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Example, ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
|
|
2
|
+
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
3
|
+
import { DottedLine } from '../../line';
|
|
4
|
+
import { Scrubber } from '../../scrubber/Scrubber';
|
|
5
|
+
import { AreaChart } from '..';
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
const BasicExample = () => {
|
|
8
|
+
return /*#__PURE__*/_jsx(AreaChart, {
|
|
9
|
+
enableScrubbing: true,
|
|
10
|
+
showYAxis: true,
|
|
11
|
+
height: 400,
|
|
12
|
+
series: [{
|
|
13
|
+
id: 'pageViews',
|
|
14
|
+
data: [24, 13, 98, 39, 48, 38, 43]
|
|
15
|
+
}],
|
|
16
|
+
yAxis: {
|
|
17
|
+
showGrid: true,
|
|
18
|
+
domain: {
|
|
19
|
+
min: 0
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
children: /*#__PURE__*/_jsx(Scrubber, {})
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const StackedExample = () => {
|
|
26
|
+
const theme = useTheme();
|
|
27
|
+
return /*#__PURE__*/_jsx(AreaChart, {
|
|
28
|
+
enableScrubbing: true,
|
|
29
|
+
showLines: true,
|
|
30
|
+
stacked: true,
|
|
31
|
+
curve: "natural",
|
|
32
|
+
height: 256,
|
|
33
|
+
series: [{
|
|
34
|
+
id: 'currentRewards',
|
|
35
|
+
data: [100, 150, 200, 280, 380, 500, 650, 820, 1020, 1250, 1510, 1800, 2120, 2470, 2850, 3260, 3700, 4170],
|
|
36
|
+
color: theme.color.fg
|
|
37
|
+
}, {
|
|
38
|
+
id: 'potentialRewards',
|
|
39
|
+
data: [150, 220, 300, 400, 520, 660, 820, 1000, 1200, 1420, 1660, 1920, 2200, 2500, 2820, 3160, 3520, 3900],
|
|
40
|
+
color: theme.color.fgPositive,
|
|
41
|
+
type: 'dotted',
|
|
42
|
+
LineComponent: DottedLine
|
|
43
|
+
}],
|
|
44
|
+
type: "dotted",
|
|
45
|
+
children: /*#__PURE__*/_jsx(Scrubber, {})
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
const AreaChartStories = () => {
|
|
49
|
+
return /*#__PURE__*/_jsxs(ExampleScreen, {
|
|
50
|
+
children: [/*#__PURE__*/_jsx(Example, {
|
|
51
|
+
title: "Basic",
|
|
52
|
+
children: /*#__PURE__*/_jsx(BasicExample, {})
|
|
53
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
54
|
+
title: "Stacked",
|
|
55
|
+
children: /*#__PURE__*/_jsx(StackedExample, {})
|
|
56
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
57
|
+
title: "Negative Values",
|
|
58
|
+
children: /*#__PURE__*/_jsx(AreaChart, {
|
|
59
|
+
enableScrubbing: true,
|
|
60
|
+
showLines: true,
|
|
61
|
+
showYAxis: true,
|
|
62
|
+
height: 400,
|
|
63
|
+
series: [{
|
|
64
|
+
id: 'pageViews',
|
|
65
|
+
data: [24, 13, -98, 39, 48, 38, 43]
|
|
66
|
+
}],
|
|
67
|
+
type: "solid",
|
|
68
|
+
yAxis: {
|
|
69
|
+
showGrid: true
|
|
70
|
+
},
|
|
71
|
+
children: /*#__PURE__*/_jsx(Scrubber, {})
|
|
72
|
+
})
|
|
73
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
74
|
+
title: "Styles",
|
|
75
|
+
children: /*#__PURE__*/_jsx(AreaChart, {
|
|
76
|
+
enableScrubbing: false,
|
|
77
|
+
height: 350,
|
|
78
|
+
series: [{
|
|
79
|
+
id: 'visitors',
|
|
80
|
+
data: [450, 520, 480, 600, 750, 680, 590],
|
|
81
|
+
label: 'Weekly Visitors',
|
|
82
|
+
color: '#fb4d3d',
|
|
83
|
+
type: 'dotted'
|
|
84
|
+
}, {
|
|
85
|
+
id: 'repeatVisitors',
|
|
86
|
+
data: [250, 200, 150, 140, 100, 80, 50],
|
|
87
|
+
label: 'Weekly Repeat Visitors',
|
|
88
|
+
color: '#16a34a'
|
|
89
|
+
}, {
|
|
90
|
+
id: 'signups',
|
|
91
|
+
data: [45, 62, 55, 250, 380, 400, 450],
|
|
92
|
+
label: 'Weekly Signups',
|
|
93
|
+
color: '#2563eb',
|
|
94
|
+
type: 'gradient'
|
|
95
|
+
}]
|
|
96
|
+
})
|
|
97
|
+
})]
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
export default AreaChartStories;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Animation variants for grouped axis tick labels - initial mount
|
|
3
|
+
* Note: Mobile currently doesn't use these variants. Axes render immediately without animation.
|
|
4
|
+
* Web uses similar variants with delay to match path enter animation timing.
|
|
5
|
+
*/
|
|
6
|
+
export const axisTickLabelsInitialAnimationVariants = {
|
|
7
|
+
initial: {
|
|
8
|
+
opacity: 0
|
|
9
|
+
},
|
|
10
|
+
animate: {
|
|
11
|
+
opacity: 1,
|
|
12
|
+
transition: {
|
|
13
|
+
duration: 0,
|
|
14
|
+
delay: 0
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
exit: {
|
|
18
|
+
opacity: 0,
|
|
19
|
+
transition: {
|
|
20
|
+
duration: 0.15
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Animation variants for axis elements - updates (used for both grid lines and tick labels)
|
|
27
|
+
*/
|
|
28
|
+
export const axisUpdateAnimationVariants = {
|
|
29
|
+
initial: {
|
|
30
|
+
opacity: 0
|
|
31
|
+
},
|
|
32
|
+
animate: {
|
|
33
|
+
opacity: 1,
|
|
34
|
+
transition: {
|
|
35
|
+
duration: 0.15,
|
|
36
|
+
delay: 0.15 // For updates: fade out 150ms, then fade in 150ms
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
exit: {
|
|
40
|
+
opacity: 0,
|
|
41
|
+
transition: {
|
|
42
|
+
duration: 0.15
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
const _excluded = ["position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "tickMinStep", "tickMaxStep", "label", "labelGap", "height"];
|
|
2
|
+
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; }
|
|
3
|
+
import { memo, useCallback, useEffect, useId, useMemo } from 'react';
|
|
4
|
+
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
5
|
+
import { Group } from '@shopify/react-native-skia';
|
|
6
|
+
import { useCartesianChartContext } from '../ChartProvider';
|
|
7
|
+
import { DottedLine } from '../line/DottedLine';
|
|
8
|
+
import { ReferenceLine } from '../line/ReferenceLine';
|
|
9
|
+
import { SolidLine } from '../line/SolidLine';
|
|
10
|
+
import { ChartText } from '../text/ChartText';
|
|
11
|
+
import { ChartTextGroup } from '../text/ChartTextGroup';
|
|
12
|
+
import { getAxisTicksData, isCategoricalScale, lineToPath } from '../utils';
|
|
13
|
+
import { DefaultAxisTickLabel } from './DefaultAxisTickLabel';
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
const AXIS_HEIGHT = 32;
|
|
16
|
+
const LABEL_SIZE = 20;
|
|
17
|
+
export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
18
|
+
let {
|
|
19
|
+
position = 'bottom',
|
|
20
|
+
showGrid,
|
|
21
|
+
requestedTickCount,
|
|
22
|
+
ticks,
|
|
23
|
+
tickLabelFormatter,
|
|
24
|
+
TickLabelComponent = DefaultAxisTickLabel,
|
|
25
|
+
GridLineComponent = DottedLine,
|
|
26
|
+
LineComponent = SolidLine,
|
|
27
|
+
TickMarkLineComponent = SolidLine,
|
|
28
|
+
tickMarkLabelGap = 2,
|
|
29
|
+
minTickLabelGap = 4,
|
|
30
|
+
showTickMarks,
|
|
31
|
+
showLine,
|
|
32
|
+
tickMarkSize = 4,
|
|
33
|
+
tickInterval = 32,
|
|
34
|
+
tickMinStep = 1,
|
|
35
|
+
tickMaxStep,
|
|
36
|
+
label,
|
|
37
|
+
labelGap = 4,
|
|
38
|
+
height = label ? AXIS_HEIGHT + LABEL_SIZE : AXIS_HEIGHT
|
|
39
|
+
} = _ref,
|
|
40
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
41
|
+
const theme = useTheme();
|
|
42
|
+
const registrationId = useId();
|
|
43
|
+
const {
|
|
44
|
+
animate,
|
|
45
|
+
getXScale,
|
|
46
|
+
getXAxis,
|
|
47
|
+
registerAxis,
|
|
48
|
+
unregisterAxis,
|
|
49
|
+
getAxisBounds
|
|
50
|
+
} = useCartesianChartContext();
|
|
51
|
+
const xScale = getXScale();
|
|
52
|
+
const xAxis = getXAxis();
|
|
53
|
+
const axisBounds = getAxisBounds(registrationId);
|
|
54
|
+
|
|
55
|
+
// Note: gridOpacity not currently used in Skia version
|
|
56
|
+
// const gridOpacity = useSharedValue(1);
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
registerAxis(registrationId, position, height);
|
|
60
|
+
return () => unregisterAxis(registrationId);
|
|
61
|
+
}, [registrationId, registerAxis, unregisterAxis, position, height]);
|
|
62
|
+
const formatTick = useCallback(value => {
|
|
63
|
+
var _tickLabelFormatter;
|
|
64
|
+
// If we have string labels and no custom formatter, use the labels
|
|
65
|
+
const axisData = xAxis == null ? void 0 : xAxis.data;
|
|
66
|
+
const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
|
|
67
|
+
let finalValue = value;
|
|
68
|
+
|
|
69
|
+
// For band scales with string data, value is an index
|
|
70
|
+
if (hasStringLabels && typeof value === 'number' && axisData[value] !== undefined) {
|
|
71
|
+
finalValue = axisData[value];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Use the formatter (if provided) or the value itself
|
|
75
|
+
return (_tickLabelFormatter = tickLabelFormatter == null ? void 0 : tickLabelFormatter(finalValue)) != null ? _tickLabelFormatter : finalValue;
|
|
76
|
+
}, [xAxis == null ? void 0 : xAxis.data, tickLabelFormatter]);
|
|
77
|
+
const ticksData = useMemo(() => {
|
|
78
|
+
if (!xScale) return [];
|
|
79
|
+
|
|
80
|
+
// Check if we have string labels
|
|
81
|
+
const axisData = xAxis == null ? void 0 : xAxis.data;
|
|
82
|
+
const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
|
|
83
|
+
|
|
84
|
+
// For band scales, we need categories
|
|
85
|
+
let categories;
|
|
86
|
+
if (hasStringLabels) {
|
|
87
|
+
categories = axisData;
|
|
88
|
+
} else if (isCategoricalScale(xScale)) {
|
|
89
|
+
// For band scales without explicit string data, generate numeric categories
|
|
90
|
+
// based on the domain of the scale
|
|
91
|
+
const domain = xScale.domain();
|
|
92
|
+
categories = domain.map(String);
|
|
93
|
+
}
|
|
94
|
+
let possibleTickValues;
|
|
95
|
+
|
|
96
|
+
// If we have discrete data, we can use the indices as possible tick values
|
|
97
|
+
if (axisData && Array.isArray(axisData) && (typeof axisData[0] === 'string' || typeof axisData[0] === 'number' && isCategoricalScale(xScale))) {
|
|
98
|
+
possibleTickValues = Array.from({
|
|
99
|
+
length: axisData.length
|
|
100
|
+
}, (_, i) => i);
|
|
101
|
+
}
|
|
102
|
+
return getAxisTicksData({
|
|
103
|
+
scaleFunction: xScale,
|
|
104
|
+
ticks,
|
|
105
|
+
requestedTickCount,
|
|
106
|
+
categories,
|
|
107
|
+
possibleTickValues,
|
|
108
|
+
tickInterval: tickInterval,
|
|
109
|
+
options: {
|
|
110
|
+
minStep: tickMinStep,
|
|
111
|
+
maxStep: tickMaxStep
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}, [ticks, xScale, requestedTickCount, tickInterval, tickMinStep, tickMaxStep, xAxis == null ? void 0 : xAxis.data]);
|
|
115
|
+
const chartTextData = useMemo(() => {
|
|
116
|
+
if (!axisBounds) return null;
|
|
117
|
+
return ticksData.map(tick => {
|
|
118
|
+
const tickOffset = tickMarkLabelGap + (showTickMarks ? tickMarkSize : 0);
|
|
119
|
+
|
|
120
|
+
// Use AXIS_HEIGHT for centering, not full axisBounds.height
|
|
121
|
+
// This ensures tick labels are centered in the axis area, not including label space
|
|
122
|
+
const availableSpace = AXIS_HEIGHT - tickOffset;
|
|
123
|
+
const labelOffset = availableSpace / 2;
|
|
124
|
+
|
|
125
|
+
// For bottom position: start at axisBounds.y
|
|
126
|
+
// For top position with label: start at axisBounds.y + LABEL_SIZE
|
|
127
|
+
const baseY = position === 'top' && label ? axisBounds.y + LABEL_SIZE : axisBounds.y;
|
|
128
|
+
const labelY = position === 'top' ? baseY + labelOffset - tickOffset : baseY + labelOffset + tickOffset;
|
|
129
|
+
return {
|
|
130
|
+
x: tick.position,
|
|
131
|
+
y: labelY,
|
|
132
|
+
label: String(formatTick(tick.tick)),
|
|
133
|
+
chartTextProps: {
|
|
134
|
+
color: theme.color.fgMuted,
|
|
135
|
+
verticalAlignment: 'middle',
|
|
136
|
+
horizontalAlignment: 'center'
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
}, [axisBounds, ticksData, theme.color.fgMuted, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick, label]);
|
|
141
|
+
if (!xScale || !axisBounds) return;
|
|
142
|
+
const labelX = axisBounds.x + axisBounds.width / 2;
|
|
143
|
+
const labelY = position === 'bottom' ? axisBounds.y + axisBounds.height - LABEL_SIZE / 2 : axisBounds.y + LABEL_SIZE / 2;
|
|
144
|
+
return /*#__PURE__*/_jsxs(Group, {
|
|
145
|
+
children: [showGrid && /*#__PURE__*/_jsx(Group, {
|
|
146
|
+
children: ticksData.map((tick, index) => {
|
|
147
|
+
const verticalLine = /*#__PURE__*/_jsx(ReferenceLine, {
|
|
148
|
+
LineComponent: GridLineComponent,
|
|
149
|
+
dataX: tick.tick
|
|
150
|
+
});
|
|
151
|
+
return /*#__PURE__*/_jsx(Group, {
|
|
152
|
+
children: verticalLine
|
|
153
|
+
}, "grid-" + tick.tick + "-" + index);
|
|
154
|
+
})
|
|
155
|
+
}), chartTextData && /*#__PURE__*/_jsx(ChartTextGroup, {
|
|
156
|
+
prioritizeEndLabels: true,
|
|
157
|
+
LabelComponent: TickLabelComponent,
|
|
158
|
+
labels: chartTextData,
|
|
159
|
+
minGap: minTickLabelGap
|
|
160
|
+
}), axisBounds && showTickMarks && /*#__PURE__*/_jsx(Group, {
|
|
161
|
+
children: ticksData.map((tick, index) => {
|
|
162
|
+
const tickY = position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height;
|
|
163
|
+
const tickY2 = position === 'bottom' ? axisBounds.y + tickMarkSize : axisBounds.y + axisBounds.height - tickMarkSize;
|
|
164
|
+
return /*#__PURE__*/_jsx(TickMarkLineComponent, {
|
|
165
|
+
animate: false,
|
|
166
|
+
clipPath: null,
|
|
167
|
+
d: lineToPath(tick.position, tickY, tick.position, tickY2),
|
|
168
|
+
stroke: theme.color.fg,
|
|
169
|
+
strokeCap: "square",
|
|
170
|
+
strokeWidth: 1
|
|
171
|
+
}, "tick-mark-" + tick.tick + "-" + index);
|
|
172
|
+
})
|
|
173
|
+
}), showLine && /*#__PURE__*/_jsx(LineComponent, {
|
|
174
|
+
animate: false,
|
|
175
|
+
clipPath: null,
|
|
176
|
+
d: lineToPath(axisBounds.x, position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height, axisBounds.x + axisBounds.width, position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height),
|
|
177
|
+
stroke: theme.color.fg,
|
|
178
|
+
strokeCap: "square",
|
|
179
|
+
strokeWidth: 1
|
|
180
|
+
}), label && /*#__PURE__*/_jsx(ChartText, {
|
|
181
|
+
horizontalAlignment: "center",
|
|
182
|
+
verticalAlignment: "middle",
|
|
183
|
+
x: labelX,
|
|
184
|
+
y: labelY,
|
|
185
|
+
children: label
|
|
186
|
+
})]
|
|
187
|
+
});
|
|
188
|
+
});
|