@coinbase/cds-mobile-visualization 0.0.0 → 3.4.0-beta.1
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 +26 -0
- package/README.md +3 -0
- package/dts/chart/CartesianChart.d.ts +101 -0
- package/dts/chart/CartesianChart.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 +48 -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/Point.d.ts +103 -0
- package/dts/chart/Point.d.ts.map +1 -0
- package/dts/chart/area/Area.d.ts +62 -0
- package/dts/chart/area/Area.d.ts.map +1 -0
- package/dts/chart/area/AreaChart.d.ts +90 -0
- package/dts/chart/area/AreaChart.d.ts.map +1 -0
- package/dts/chart/area/DottedArea.d.ts +27 -0
- package/dts/chart/area/DottedArea.d.ts.map +1 -0
- package/dts/chart/area/GradientArea.d.ts +30 -0
- package/dts/chart/area/GradientArea.d.ts.map +1 -0
- package/dts/chart/area/SolidArea.d.ts +8 -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 +204 -0
- package/dts/chart/axis/Axis.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 +4 -0
- package/dts/chart/axis/index.d.ts.map +1 -0
- package/dts/chart/bar/Bar.d.ts +89 -0
- package/dts/chart/bar/Bar.d.ts.map +1 -0
- package/dts/chart/bar/BarChart.d.ts +97 -0
- package/dts/chart/bar/BarChart.d.ts.map +1 -0
- package/dts/chart/bar/BarPlot.d.ts +29 -0
- package/dts/chart/bar/BarPlot.d.ts.map +1 -0
- package/dts/chart/bar/BarStack.d.ts +111 -0
- package/dts/chart/bar/BarStack.d.ts.map +1 -0
- package/dts/chart/bar/BarStackGroup.d.ts +35 -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/index.d.ts +13 -0
- package/dts/chart/index.d.ts.map +1 -0
- package/dts/chart/line/DottedLine.d.ts +12 -0
- package/dts/chart/line/DottedLine.d.ts.map +1 -0
- package/dts/chart/line/GradientLine.d.ts +45 -0
- package/dts/chart/line/GradientLine.d.ts.map +1 -0
- package/dts/chart/line/Line.d.ts +78 -0
- package/dts/chart/line/Line.d.ts.map +1 -0
- package/dts/chart/line/LineChart.d.ts +84 -0
- package/dts/chart/line/LineChart.d.ts.map +1 -0
- package/dts/chart/line/ReferenceLine.d.ts +91 -0
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -0
- package/dts/chart/line/SolidLine.d.ts +12 -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/scrubber/Scrubber.d.ts +104 -0
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeacon.d.ts +75 -0
- package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberProvider.d.ts +17 -0
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -0
- package/dts/chart/scrubber/index.d.ts +2 -0
- package/dts/chart/scrubber/index.d.ts.map +1 -0
- package/dts/chart/text/ChartText.d.ts +90 -0
- package/dts/chart/text/ChartText.d.ts.map +1 -0
- package/dts/chart/text/SmartChartTextGroup.d.ts +55 -0
- package/dts/chart/text/SmartChartTextGroup.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 +97 -0
- package/dts/chart/utils/chart.d.ts.map +1 -0
- package/dts/chart/utils/context.d.ts +95 -0
- package/dts/chart/utils/context.d.ts.map +1 -0
- package/dts/chart/utils/index.d.ts +8 -0
- package/dts/chart/utils/index.d.ts.map +1 -0
- package/dts/chart/utils/path.d.ts +107 -0
- package/dts/chart/utils/path.d.ts.map +1 -0
- package/dts/chart/utils/point.d.ts +75 -0
- package/dts/chart/utils/point.d.ts.map +1 -0
- package/dts/chart/utils/scale.d.ts +43 -0
- package/dts/chart/utils/scale.d.ts.map +1 -0
- package/dts/index.d.ts +3 -0
- package/dts/index.d.ts.map +1 -0
- package/dts/sparkline/Counter.d.ts +8 -0
- package/dts/sparkline/Counter.d.ts.map +1 -0
- package/dts/sparkline/Sparkline.d.ts +73 -0
- package/dts/sparkline/Sparkline.d.ts.map +1 -0
- package/dts/sparkline/SparklineArea.d.ts +14 -0
- package/dts/sparkline/SparklineArea.d.ts.map +1 -0
- package/dts/sparkline/SparklineAreaPattern.d.ts +14 -0
- package/dts/sparkline/SparklineAreaPattern.d.ts.map +1 -0
- package/dts/sparkline/SparklineGradient.d.ts +23 -0
- package/dts/sparkline/SparklineGradient.d.ts.map +1 -0
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts +2 -0
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts.map +1 -0
- package/dts/sparkline/generateSparklineWithId.d.ts +11 -0
- package/dts/sparkline/generateSparklineWithId.d.ts.map +1 -0
- package/dts/sparkline/index.d.ts +6 -0
- package/dts/sparkline/index.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts +23 -0
- package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +184 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +25 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +28 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +13 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +17 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts +11 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts +26 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +25 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +25 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +39 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +31 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +2 -0
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts +13 -0
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts +16 -0
- package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts +6 -0
- package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +22 -0
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts +34 -0
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +118 -0
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +2 -0
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts +29 -0
- package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts.map +1 -0
- package/esm/chart/CartesianChart.js +241 -0
- package/esm/chart/ChartProvider.js +10 -0
- package/esm/chart/Path.js +133 -0
- package/esm/chart/PeriodSelector.js +136 -0
- package/esm/chart/Point.js +111 -0
- package/esm/chart/__stories__/CartesianChart.stories.js +476 -0
- package/esm/chart/__stories__/Chart.stories.js +79 -0
- package/esm/chart/__stories__/PeriodSelector.stories.js +294 -0
- package/esm/chart/area/Area.js +85 -0
- package/esm/chart/area/AreaChart.js +146 -0
- package/esm/chart/area/DottedArea.js +128 -0
- package/esm/chart/area/GradientArea.js +110 -0
- package/esm/chart/area/SolidArea.js +24 -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 +43 -0
- package/esm/chart/axis/XAxis.js +181 -0
- package/esm/chart/axis/YAxis.js +170 -0
- package/esm/chart/axis/__stories__/Axis.stories.js +277 -0
- package/esm/chart/axis/index.js +5 -0
- package/esm/chart/bar/Bar.js +67 -0
- package/esm/chart/bar/BarChart.js +147 -0
- package/esm/chart/bar/BarPlot.js +96 -0
- package/esm/chart/bar/BarStack.js +514 -0
- package/esm/chart/bar/BarStackGroup.js +89 -0
- package/esm/chart/bar/DefaultBar.js +78 -0
- package/esm/chart/bar/DefaultBarStack.js +82 -0
- package/esm/chart/bar/__stories__/BarChart.stories.js +282 -0
- package/esm/chart/bar/index.js +9 -0
- package/esm/chart/index.js +14 -0
- package/esm/chart/line/DottedLine.js +35 -0
- package/esm/chart/line/GradientLine.js +62 -0
- package/esm/chart/line/Line.js +139 -0
- package/esm/chart/line/LineChart.js +115 -0
- package/esm/chart/line/ReferenceLine.js +115 -0
- package/esm/chart/line/SolidLine.js +31 -0
- package/esm/chart/line/__stories__/LineChart.stories.js +2248 -0
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +77 -0
- package/esm/chart/line/index.js +8 -0
- package/esm/chart/scrubber/Scrubber.js +186 -0
- package/esm/chart/scrubber/ScrubberBeacon.js +199 -0
- package/esm/chart/scrubber/ScrubberProvider.js +143 -0
- package/esm/chart/scrubber/index.js +2 -0
- package/esm/chart/text/ChartText.js +237 -0
- package/esm/chart/text/SmartChartTextGroup.js +210 -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 +229 -0
- package/esm/chart/utils/context.js +15 -0
- package/esm/chart/utils/index.js +9 -0
- package/esm/chart/utils/path.js +206 -0
- package/esm/chart/utils/point.js +118 -0
- package/esm/chart/utils/scale.js +48 -0
- package/esm/index.js +4 -0
- package/esm/sparkline/Counter.js +45 -0
- package/esm/sparkline/Sparkline.js +164 -0
- package/esm/sparkline/SparklineArea.js +19 -0
- package/esm/sparkline/SparklineAreaPattern.js +38 -0
- package/esm/sparkline/SparklineGradient.js +76 -0
- package/esm/sparkline/__figma__/Sparkline.figma.js +22 -0
- package/esm/sparkline/__stories__/Sparkline.stories.js +120 -0
- package/esm/sparkline/__stories__/SparklineGradient.stories.js +123 -0
- package/esm/sparkline/generateSparklineWithId.js +7 -0
- package/esm/sparkline/index.js +5 -0
- package/esm/sparkline/sparkline-interactive/SparklineAccessibleView.js +75 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +307 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +116 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.js +131 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.js +99 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +82 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMinMax.js +103 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.js +104 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +57 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.js +124 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveProvider.js +80 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.js +109 -0
- package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +85 -0
- package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +501 -0
- package/esm/sparkline/sparkline-interactive/useInterruptiblePathAnimation.js +58 -0
- package/esm/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.js +37 -0
- package/esm/sparkline/sparkline-interactive/useMinMaxTransform.js +56 -0
- package/esm/sparkline/sparkline-interactive/useOpacityAnimation.js +23 -0
- package/esm/sparkline/sparkline-interactive/useSparklineInteractiveConstants.js +47 -0
- package/esm/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.js +34 -0
- package/esm/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.js +233 -0
- package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +104 -0
- package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +555 -0
- package/esm/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.js +117 -0
- package/package.json +65 -6
- package/index.js +0 -1
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import { memo, useCallback, useMemo } from 'react';
|
|
3
|
+
import { Example, ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
|
|
4
|
+
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
5
|
+
import { CartesianChart } from '../../CartesianChart';
|
|
6
|
+
import { LineChart, SolidLine } from '../../line';
|
|
7
|
+
import { Line } from '../../line/Line';
|
|
8
|
+
import { Scrubber } from '../../scrubber/Scrubber';
|
|
9
|
+
import { XAxis, YAxis } from '..';
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
const defaultChartHeight = 250;
|
|
12
|
+
const ThinSolidLine = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(SolidLine, _extends({}, props, {
|
|
13
|
+
strokeWidth: 1
|
|
14
|
+
})));
|
|
15
|
+
const Simple = () => {
|
|
16
|
+
const data = [{
|
|
17
|
+
name: 'Page A',
|
|
18
|
+
uv: 4000,
|
|
19
|
+
pv: 2400,
|
|
20
|
+
amt: 2400
|
|
21
|
+
}, {
|
|
22
|
+
name: 'Page B',
|
|
23
|
+
uv: 3000,
|
|
24
|
+
pv: 1398,
|
|
25
|
+
amt: 2210
|
|
26
|
+
}, {
|
|
27
|
+
name: 'Page C',
|
|
28
|
+
uv: 2000,
|
|
29
|
+
pv: 9800,
|
|
30
|
+
amt: 2290
|
|
31
|
+
}, {
|
|
32
|
+
name: 'Page D',
|
|
33
|
+
uv: 2780,
|
|
34
|
+
pv: 3908,
|
|
35
|
+
amt: 2000
|
|
36
|
+
}, {
|
|
37
|
+
name: 'Page E',
|
|
38
|
+
uv: 1890,
|
|
39
|
+
pv: 4800,
|
|
40
|
+
amt: 2181
|
|
41
|
+
}, {
|
|
42
|
+
name: 'Page F',
|
|
43
|
+
uv: 2390,
|
|
44
|
+
pv: 3800,
|
|
45
|
+
amt: 2500
|
|
46
|
+
}, {
|
|
47
|
+
name: 'Page G',
|
|
48
|
+
uv: 3490,
|
|
49
|
+
pv: 4300,
|
|
50
|
+
amt: 2100
|
|
51
|
+
}];
|
|
52
|
+
const pageViews = data.map(d => d.pv);
|
|
53
|
+
const pageNames = data.map(d => d.name);
|
|
54
|
+
const pageUniqueVisitors = data.map(d => d.uv);
|
|
55
|
+
return /*#__PURE__*/_jsx(LineChart, {
|
|
56
|
+
enableScrubbing: true,
|
|
57
|
+
showXAxis: true,
|
|
58
|
+
showYAxis: true,
|
|
59
|
+
height: defaultChartHeight,
|
|
60
|
+
inset: 32,
|
|
61
|
+
series: [{
|
|
62
|
+
id: 'pageViews',
|
|
63
|
+
data: pageViews,
|
|
64
|
+
label: 'Page Views',
|
|
65
|
+
color: '#8884d8',
|
|
66
|
+
curve: 'monotone'
|
|
67
|
+
}, {
|
|
68
|
+
id: 'uniqueVisitors',
|
|
69
|
+
data: pageUniqueVisitors,
|
|
70
|
+
label: 'Unique Visitors',
|
|
71
|
+
color: '#82ca9d',
|
|
72
|
+
curve: 'monotone'
|
|
73
|
+
}],
|
|
74
|
+
xAxis: {
|
|
75
|
+
data: pageNames,
|
|
76
|
+
showLine: true,
|
|
77
|
+
showGrid: true,
|
|
78
|
+
showTickMarks: true,
|
|
79
|
+
GridLineComponent: ThinSolidLine,
|
|
80
|
+
position: 'bottom',
|
|
81
|
+
requestedTickCount: 5
|
|
82
|
+
},
|
|
83
|
+
yAxis: {
|
|
84
|
+
domain: {
|
|
85
|
+
min: 0
|
|
86
|
+
},
|
|
87
|
+
showGrid: true,
|
|
88
|
+
showLine: true,
|
|
89
|
+
showTickMarks: true,
|
|
90
|
+
GridLineComponent: ThinSolidLine,
|
|
91
|
+
position: 'left',
|
|
92
|
+
requestedTickCount: 5
|
|
93
|
+
},
|
|
94
|
+
children: /*#__PURE__*/_jsx(Scrubber, {})
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const TimeOfDayAxesExample = () => {
|
|
98
|
+
const theme = useTheme();
|
|
99
|
+
const lineA = [5, 5, 10, 90, 85, 70, 30, 25, 25];
|
|
100
|
+
const lineB = [90, 85, 70, 25, 23, 40, 45, 40, 50];
|
|
101
|
+
const timeData = useMemo(() => [new Date(2023, 7, 31), new Date(2023, 7, 31, 12), new Date(2023, 8, 1), new Date(2023, 8, 1, 12), new Date(2023, 8, 2), new Date(2023, 8, 2, 12), new Date(2023, 8, 3), new Date(2023, 8, 3, 12), new Date(2023, 8, 4)].map(d => d.getTime()), []);
|
|
102
|
+
const dateFormatter = useCallback(index => {
|
|
103
|
+
return new Date(timeData[index]).toLocaleDateString('en-US', {
|
|
104
|
+
month: '2-digit',
|
|
105
|
+
day: '2-digit'
|
|
106
|
+
});
|
|
107
|
+
}, [timeData]);
|
|
108
|
+
const timeOfDayFormatter = useCallback(index => {
|
|
109
|
+
return new Date(timeData[index]).toLocaleTimeString('en-US', {
|
|
110
|
+
hour: '2-digit'
|
|
111
|
+
});
|
|
112
|
+
}, [timeData]);
|
|
113
|
+
const timeOfDayTicks = useMemo(() => {
|
|
114
|
+
return timeData.map((d, index) => index);
|
|
115
|
+
}, [timeData]);
|
|
116
|
+
const dateTicks = useMemo(() => {
|
|
117
|
+
return timeData.map((d, index) => index).filter(d => d % 2 === 0);
|
|
118
|
+
}, [timeData]);
|
|
119
|
+
return /*#__PURE__*/_jsxs(LineChart, {
|
|
120
|
+
enableScrubbing: true,
|
|
121
|
+
curve: "monotone",
|
|
122
|
+
height: defaultChartHeight,
|
|
123
|
+
series: [{
|
|
124
|
+
id: 'lineA',
|
|
125
|
+
data: lineA,
|
|
126
|
+
color: theme.color.accentBoldBlue
|
|
127
|
+
}, {
|
|
128
|
+
id: 'lineB',
|
|
129
|
+
data: lineB,
|
|
130
|
+
color: theme.color.accentBoldGreen
|
|
131
|
+
}],
|
|
132
|
+
yAxis: {
|
|
133
|
+
domain: {
|
|
134
|
+
min: 0,
|
|
135
|
+
max: 100
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
children: [/*#__PURE__*/_jsx(XAxis, {
|
|
139
|
+
showLine: true,
|
|
140
|
+
showTickMarks: true,
|
|
141
|
+
position: "top",
|
|
142
|
+
tickLabelFormatter: dateFormatter,
|
|
143
|
+
ticks: dateTicks
|
|
144
|
+
}), /*#__PURE__*/_jsx(XAxis, {
|
|
145
|
+
showGrid: true,
|
|
146
|
+
showLine: true,
|
|
147
|
+
showTickMarks: true,
|
|
148
|
+
tickLabelFormatter: timeOfDayFormatter,
|
|
149
|
+
ticks: timeOfDayTicks
|
|
150
|
+
}), /*#__PURE__*/_jsx(Scrubber, {})]
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
const MultipleYAxesExample = () => /*#__PURE__*/_jsxs(CartesianChart, {
|
|
154
|
+
enableScrubbing: true,
|
|
155
|
+
height: defaultChartHeight,
|
|
156
|
+
series: [{
|
|
157
|
+
id: 'linear',
|
|
158
|
+
yAxisId: 'linearAxis',
|
|
159
|
+
data: [1, 10, 30, 50, 70, 90, 100],
|
|
160
|
+
label: 'linear'
|
|
161
|
+
}, {
|
|
162
|
+
id: 'log',
|
|
163
|
+
yAxisId: 'logAxis',
|
|
164
|
+
data: [1, 10, 30, 50, 70, 90, 100],
|
|
165
|
+
label: 'log'
|
|
166
|
+
}],
|
|
167
|
+
xAxis: {
|
|
168
|
+
data: [1, 10, 30, 50, 70, 90, 100]
|
|
169
|
+
},
|
|
170
|
+
yAxis: [{
|
|
171
|
+
id: 'linearAxis',
|
|
172
|
+
scaleType: 'linear'
|
|
173
|
+
}, {
|
|
174
|
+
id: 'logAxis',
|
|
175
|
+
scaleType: 'log'
|
|
176
|
+
}],
|
|
177
|
+
children: [/*#__PURE__*/_jsx(XAxis, {
|
|
178
|
+
showLine: true,
|
|
179
|
+
showTickMarks: true
|
|
180
|
+
}), /*#__PURE__*/_jsx(YAxis, {
|
|
181
|
+
showLine: true,
|
|
182
|
+
showTickMarks: true,
|
|
183
|
+
axisId: "logAxis",
|
|
184
|
+
position: "left"
|
|
185
|
+
}), /*#__PURE__*/_jsx(YAxis, {
|
|
186
|
+
showLine: true,
|
|
187
|
+
showTickMarks: true,
|
|
188
|
+
axisId: "linearAxis",
|
|
189
|
+
position: "left"
|
|
190
|
+
}), /*#__PURE__*/_jsx(Line, {
|
|
191
|
+
curve: "natural",
|
|
192
|
+
seriesId: "linear"
|
|
193
|
+
}), /*#__PURE__*/_jsx(Line, {
|
|
194
|
+
curve: "natural",
|
|
195
|
+
seriesId: "log"
|
|
196
|
+
}), /*#__PURE__*/_jsx(Scrubber, {})]
|
|
197
|
+
});
|
|
198
|
+
const DomainLimitType = _ref => {
|
|
199
|
+
let {
|
|
200
|
+
limit
|
|
201
|
+
} = _ref;
|
|
202
|
+
const exponentialData = [1, 2, 4, 8, 15, 30, 65, 140, 280, 580, 1200, 2400, 4800, 9500, 19000, 38000, 75000, 150000];
|
|
203
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
204
|
+
enableScrubbing: true,
|
|
205
|
+
height: defaultChartHeight,
|
|
206
|
+
series: [{
|
|
207
|
+
id: 'growthLinear',
|
|
208
|
+
data: exponentialData,
|
|
209
|
+
color: '#10b981',
|
|
210
|
+
yAxisId: 'linear'
|
|
211
|
+
}, {
|
|
212
|
+
id: 'growthExponential',
|
|
213
|
+
data: exponentialData,
|
|
214
|
+
color: '#10b981',
|
|
215
|
+
yAxisId: 'exponential'
|
|
216
|
+
}],
|
|
217
|
+
yAxis: [{
|
|
218
|
+
id: 'linear',
|
|
219
|
+
scaleType: 'linear',
|
|
220
|
+
domainLimit: limit
|
|
221
|
+
}, {
|
|
222
|
+
id: 'exponential',
|
|
223
|
+
scaleType: 'log',
|
|
224
|
+
domainLimit: limit
|
|
225
|
+
}],
|
|
226
|
+
children: [/*#__PURE__*/_jsx(Line, {
|
|
227
|
+
showArea: true,
|
|
228
|
+
curve: "natural",
|
|
229
|
+
seriesId: "growthLinear"
|
|
230
|
+
}), /*#__PURE__*/_jsx(Line, {
|
|
231
|
+
showArea: true,
|
|
232
|
+
curve: "natural",
|
|
233
|
+
seriesId: "growthExponential"
|
|
234
|
+
}), /*#__PURE__*/_jsx(XAxis, {
|
|
235
|
+
showLine: true
|
|
236
|
+
}), /*#__PURE__*/_jsx(YAxis, {
|
|
237
|
+
showLine: true,
|
|
238
|
+
showTickMarks: true,
|
|
239
|
+
axisId: "exponential",
|
|
240
|
+
position: "left",
|
|
241
|
+
requestedTickCount: 6,
|
|
242
|
+
tickLabelFormatter: value => value.toLocaleString(),
|
|
243
|
+
width: 70
|
|
244
|
+
}), /*#__PURE__*/_jsx(YAxis, {
|
|
245
|
+
showLine: true,
|
|
246
|
+
showTickMarks: true,
|
|
247
|
+
axisId: "linear",
|
|
248
|
+
tickLabelFormatter: value => value.toLocaleString(),
|
|
249
|
+
width: 70
|
|
250
|
+
}), /*#__PURE__*/_jsx(Scrubber, {})]
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
const AxisStories = () => {
|
|
254
|
+
return /*#__PURE__*/_jsxs(ExampleScreen, {
|
|
255
|
+
children: [/*#__PURE__*/_jsx(Example, {
|
|
256
|
+
title: "Basic",
|
|
257
|
+
children: /*#__PURE__*/_jsx(Simple, {})
|
|
258
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
259
|
+
title: "Time of Day",
|
|
260
|
+
children: /*#__PURE__*/_jsx(TimeOfDayAxesExample, {})
|
|
261
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
262
|
+
title: "Multiple Axes on Same Side",
|
|
263
|
+
children: /*#__PURE__*/_jsx(MultipleYAxesExample, {})
|
|
264
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
265
|
+
title: "Strict Domain Limit",
|
|
266
|
+
children: /*#__PURE__*/_jsx(DomainLimitType, {
|
|
267
|
+
limit: "strict"
|
|
268
|
+
})
|
|
269
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
270
|
+
title: "Nice Domain Limit",
|
|
271
|
+
children: /*#__PURE__*/_jsx(DomainLimitType, {
|
|
272
|
+
limit: "nice"
|
|
273
|
+
})
|
|
274
|
+
})]
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
export default AxisStories;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
|
+
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
3
|
+
import { getBarPath } from '../utils';
|
|
4
|
+
import { DefaultBar } from './DefaultBar';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
/**
|
|
7
|
+
* Simple bar component that renders a single bar at the specified position.
|
|
8
|
+
*
|
|
9
|
+
* This component is intentionally kept simple - it just renders a static bar at the given
|
|
10
|
+
* x, y, width, height coordinates. Complex positioning logic (like handling stacks,
|
|
11
|
+
* groups, gaps, etc.) should be handled by parent components like BarChart or BarStack.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <Bar x={10} y={20} width={50} height={100} fill="blue" />
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export const Bar = /*#__PURE__*/memo(_ref => {
|
|
19
|
+
let {
|
|
20
|
+
x,
|
|
21
|
+
y,
|
|
22
|
+
width,
|
|
23
|
+
height,
|
|
24
|
+
originY,
|
|
25
|
+
dataX,
|
|
26
|
+
dataY,
|
|
27
|
+
BarComponent = DefaultBar,
|
|
28
|
+
fill,
|
|
29
|
+
fillOpacity = 1,
|
|
30
|
+
stroke,
|
|
31
|
+
strokeWidth,
|
|
32
|
+
borderRadius = 4,
|
|
33
|
+
roundTop = true,
|
|
34
|
+
roundBottom = true
|
|
35
|
+
} = _ref;
|
|
36
|
+
const theme = useTheme();
|
|
37
|
+
|
|
38
|
+
// Use theme color as default if no fill is provided
|
|
39
|
+
const effectiveFill = fill != null ? fill : theme.color.fgPrimary;
|
|
40
|
+
const borderRadiusPixels = useMemo(() => borderRadius != null ? borderRadius : 0, [borderRadius]);
|
|
41
|
+
const barPath = useMemo(() => {
|
|
42
|
+
return getBarPath(x, y, width, height, borderRadiusPixels, roundTop, roundBottom);
|
|
43
|
+
}, [x, y, width, height, borderRadiusPixels, roundTop, roundBottom]);
|
|
44
|
+
const effectiveOriginY = originY != null ? originY : y + height;
|
|
45
|
+
if (!barPath) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Always use the BarComponent for rendering
|
|
50
|
+
return /*#__PURE__*/_jsx(BarComponent, {
|
|
51
|
+
borderRadius: borderRadius,
|
|
52
|
+
d: barPath,
|
|
53
|
+
dataX: dataX,
|
|
54
|
+
dataY: dataY,
|
|
55
|
+
fill: effectiveFill,
|
|
56
|
+
fillOpacity: fillOpacity,
|
|
57
|
+
height: height,
|
|
58
|
+
originY: effectiveOriginY,
|
|
59
|
+
roundBottom: roundBottom,
|
|
60
|
+
roundTop: roundTop,
|
|
61
|
+
stroke: stroke,
|
|
62
|
+
strokeWidth: strokeWidth,
|
|
63
|
+
width: width,
|
|
64
|
+
x: x,
|
|
65
|
+
y: y
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
const _excluded = ["series", "stacked", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children", "barPadding", "BarComponent", "fillOpacity", "stroke", "strokeWidth", "borderRadius", "roundBaseline", "BarStackComponent", "stackGap", "barMinSize", "stackMinSize"],
|
|
2
|
+
_excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range"],
|
|
3
|
+
_excluded3 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"];
|
|
4
|
+
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); }
|
|
5
|
+
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; }
|
|
6
|
+
import { forwardRef, memo, useMemo } from 'react';
|
|
7
|
+
import { XAxis, YAxis } from '../axis';
|
|
8
|
+
import { CartesianChart } from '../CartesianChart';
|
|
9
|
+
import { defaultChartInset, defaultStackId, getChartInset } from '../utils';
|
|
10
|
+
import { BarPlot } from './BarPlot';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Series type specifically for bar charts - supports both single numbers and tuples,
|
|
14
|
+
* and allows individual customization of Bar props per series.
|
|
15
|
+
*/
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
18
|
+
let {
|
|
19
|
+
series,
|
|
20
|
+
stacked,
|
|
21
|
+
showXAxis,
|
|
22
|
+
showYAxis,
|
|
23
|
+
xAxis,
|
|
24
|
+
yAxis,
|
|
25
|
+
inset: userInset,
|
|
26
|
+
children,
|
|
27
|
+
barPadding,
|
|
28
|
+
BarComponent,
|
|
29
|
+
fillOpacity,
|
|
30
|
+
stroke,
|
|
31
|
+
strokeWidth,
|
|
32
|
+
borderRadius,
|
|
33
|
+
roundBaseline,
|
|
34
|
+
BarStackComponent,
|
|
35
|
+
stackGap,
|
|
36
|
+
barMinSize,
|
|
37
|
+
stackMinSize
|
|
38
|
+
} = _ref,
|
|
39
|
+
chartProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
40
|
+
const calculatedInset = useMemo(() => getChartInset(userInset, defaultChartInset), [userInset]);
|
|
41
|
+
|
|
42
|
+
// Convert BarSeries to Series for Chart context
|
|
43
|
+
const chartSeries = useMemo(() => {
|
|
44
|
+
return series == null ? void 0 : series.map(s => ({
|
|
45
|
+
id: s.id,
|
|
46
|
+
data: s.data,
|
|
47
|
+
label: s.label,
|
|
48
|
+
color: s.color,
|
|
49
|
+
yAxisId: s.yAxisId,
|
|
50
|
+
stackId: s.stackId
|
|
51
|
+
}));
|
|
52
|
+
}, [series]);
|
|
53
|
+
const transformedSeries = useMemo(() => {
|
|
54
|
+
if (!stacked || !chartSeries) return chartSeries;
|
|
55
|
+
return chartSeries.map(s => {
|
|
56
|
+
var _s$stackId;
|
|
57
|
+
return _extends({}, s, {
|
|
58
|
+
stackId: (_s$stackId = s.stackId) != null ? _s$stackId : defaultStackId
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}, [chartSeries, stacked]);
|
|
62
|
+
const seriesToRender = transformedSeries != null ? transformedSeries : chartSeries;
|
|
63
|
+
|
|
64
|
+
// Keep the original series with bar-specific props for BarPlot
|
|
65
|
+
const barSeriesToRender = useMemo(() => {
|
|
66
|
+
if (!stacked || !series) return series;
|
|
67
|
+
return series.map(s => {
|
|
68
|
+
var _s$stackId2;
|
|
69
|
+
return _extends({}, s, {
|
|
70
|
+
stackId: (_s$stackId2 = s.stackId) != null ? _s$stackId2 : defaultStackId
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}, [series, stacked]);
|
|
74
|
+
|
|
75
|
+
// Split axis props into config props for Chart and visual props for axis components
|
|
76
|
+
const _ref2 = xAxis || {},
|
|
77
|
+
{
|
|
78
|
+
scaleType: xScaleType,
|
|
79
|
+
data: xData,
|
|
80
|
+
categoryPadding: xCategoryPadding,
|
|
81
|
+
domain: xDomain,
|
|
82
|
+
domainLimit: xDomainLimit,
|
|
83
|
+
range: xRange
|
|
84
|
+
} = _ref2,
|
|
85
|
+
xAxisVisualProps = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
86
|
+
const _ref3 = yAxis || {},
|
|
87
|
+
{
|
|
88
|
+
scaleType: yScaleType,
|
|
89
|
+
data: yData,
|
|
90
|
+
categoryPadding: yCategoryPadding,
|
|
91
|
+
domain: yDomain,
|
|
92
|
+
domainLimit: yDomainLimit,
|
|
93
|
+
range: yRange,
|
|
94
|
+
id: yAxisId
|
|
95
|
+
} = _ref3,
|
|
96
|
+
yAxisVisualProps = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
97
|
+
const xAxisConfig = {
|
|
98
|
+
scaleType: xScaleType != null ? xScaleType : 'band',
|
|
99
|
+
data: xData,
|
|
100
|
+
categoryPadding: xCategoryPadding,
|
|
101
|
+
domain: xDomain,
|
|
102
|
+
domainLimit: xDomainLimit,
|
|
103
|
+
range: xRange
|
|
104
|
+
};
|
|
105
|
+
const hasNegativeValues = useMemo(() => {
|
|
106
|
+
if (!series) return false;
|
|
107
|
+
return series.some(s => {
|
|
108
|
+
var _s$data;
|
|
109
|
+
return (_s$data = s.data) == null ? void 0 : _s$data.some(value => typeof value === 'number' && value < 0 || Array.isArray(value) && value.some(v => typeof v === 'number' && v < 0));
|
|
110
|
+
});
|
|
111
|
+
}, [series]);
|
|
112
|
+
|
|
113
|
+
// Set default min domain to 0 for area chart, but only if there are no negative values
|
|
114
|
+
const yAxisConfig = {
|
|
115
|
+
scaleType: yScaleType,
|
|
116
|
+
data: yData,
|
|
117
|
+
categoryPadding: yCategoryPadding,
|
|
118
|
+
domain: hasNegativeValues ? yDomain : _extends({
|
|
119
|
+
min: 0
|
|
120
|
+
}, yDomain),
|
|
121
|
+
domainLimit: yDomainLimit,
|
|
122
|
+
range: yRange
|
|
123
|
+
};
|
|
124
|
+
return /*#__PURE__*/_jsxs(CartesianChart, _extends({}, chartProps, {
|
|
125
|
+
ref: ref,
|
|
126
|
+
inset: calculatedInset,
|
|
127
|
+
series: seriesToRender,
|
|
128
|
+
xAxis: xAxisConfig,
|
|
129
|
+
yAxis: yAxisConfig,
|
|
130
|
+
children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _extends({}, xAxisVisualProps)), showYAxis && /*#__PURE__*/_jsx(YAxis, _extends({
|
|
131
|
+
axisId: yAxisId
|
|
132
|
+
}, yAxisVisualProps)), /*#__PURE__*/_jsx(BarPlot, {
|
|
133
|
+
BarComponent: BarComponent,
|
|
134
|
+
BarStackComponent: BarStackComponent,
|
|
135
|
+
barMinSize: barMinSize,
|
|
136
|
+
barPadding: barPadding,
|
|
137
|
+
borderRadius: borderRadius,
|
|
138
|
+
fillOpacity: fillOpacity,
|
|
139
|
+
roundBaseline: roundBaseline,
|
|
140
|
+
seriesIds: barSeriesToRender == null ? void 0 : barSeriesToRender.map(s => s.id),
|
|
141
|
+
stackGap: stackGap,
|
|
142
|
+
stackMinSize: stackMinSize,
|
|
143
|
+
stroke: stroke,
|
|
144
|
+
strokeWidth: strokeWidth
|
|
145
|
+
}), children]
|
|
146
|
+
}));
|
|
147
|
+
}));
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { memo, useId, useMemo } from 'react';
|
|
2
|
+
import { ClipPath, Defs, G, Rect } from 'react-native-svg';
|
|
3
|
+
import { useCartesianChartContext } from '../ChartProvider';
|
|
4
|
+
import { defaultAxisId } from '../utils';
|
|
5
|
+
import { BarStackGroup } from './BarStackGroup';
|
|
6
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
/**
|
|
8
|
+
* BarPlot component that handles multiple series with proper stacking coordination.
|
|
9
|
+
* Groups series by stack ID + y-axis ID combination and renders BarStackGroup for each group.
|
|
10
|
+
* This allows series with different y-axes to be rendered side by side while preventing
|
|
11
|
+
* cross-axis stacking (e.g., comparing $1M vs $1B companies on different scales).
|
|
12
|
+
*/
|
|
13
|
+
export const BarPlot = /*#__PURE__*/memo(_ref => {
|
|
14
|
+
let {
|
|
15
|
+
seriesIds,
|
|
16
|
+
barPadding = 0.1,
|
|
17
|
+
BarComponent: defaultBarComponent,
|
|
18
|
+
fillOpacity: defaultFillOpacity,
|
|
19
|
+
stroke: defaultStroke,
|
|
20
|
+
strokeWidth: defaultStrokeWidth,
|
|
21
|
+
borderRadius: defaultBorderRadius,
|
|
22
|
+
roundBaseline,
|
|
23
|
+
BarStackComponent,
|
|
24
|
+
stackGap,
|
|
25
|
+
barMinSize,
|
|
26
|
+
stackMinSize
|
|
27
|
+
} = _ref;
|
|
28
|
+
const {
|
|
29
|
+
series: allSeries,
|
|
30
|
+
drawingArea
|
|
31
|
+
} = useCartesianChartContext();
|
|
32
|
+
const clipPathId = useId();
|
|
33
|
+
const targetSeries = useMemo(() => {
|
|
34
|
+
// Then filter by seriesIds if provided
|
|
35
|
+
if (seriesIds !== undefined) {
|
|
36
|
+
return allSeries.filter(s => seriesIds.includes(s.id));
|
|
37
|
+
}
|
|
38
|
+
return allSeries;
|
|
39
|
+
}, [allSeries, seriesIds]);
|
|
40
|
+
const stackGroups = useMemo(() => {
|
|
41
|
+
const groups = new Map();
|
|
42
|
+
|
|
43
|
+
// Group series into stacks based on stackId + yAxisId combination
|
|
44
|
+
targetSeries.forEach(series => {
|
|
45
|
+
var _series$yAxisId;
|
|
46
|
+
const yAxisId = (_series$yAxisId = series.yAxisId) != null ? _series$yAxisId : defaultAxisId;
|
|
47
|
+
const stackId = series.stackId || "individual-" + series.id;
|
|
48
|
+
const stackKey = stackId + ":" + yAxisId;
|
|
49
|
+
if (!groups.has(stackKey)) {
|
|
50
|
+
groups.set(stackKey, {
|
|
51
|
+
stackId: stackKey,
|
|
52
|
+
series: [],
|
|
53
|
+
yAxisId: series.yAxisId
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const group = groups.get(stackKey);
|
|
57
|
+
group.series.push(series);
|
|
58
|
+
});
|
|
59
|
+
return Array.from(groups.values());
|
|
60
|
+
}, [targetSeries]);
|
|
61
|
+
if (!drawingArea) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
65
|
+
children: [/*#__PURE__*/_jsx(Defs, {
|
|
66
|
+
children: /*#__PURE__*/_jsx(ClipPath, {
|
|
67
|
+
id: clipPathId,
|
|
68
|
+
children: /*#__PURE__*/_jsx(Rect, {
|
|
69
|
+
height: drawingArea.height,
|
|
70
|
+
width: drawingArea.width,
|
|
71
|
+
x: drawingArea.x,
|
|
72
|
+
y: drawingArea.y
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
}), /*#__PURE__*/_jsx(G, {
|
|
76
|
+
clipPath: "url(#" + clipPathId + ")",
|
|
77
|
+
children: stackGroups.map((group, stackIndex) => /*#__PURE__*/_jsx(BarStackGroup, {
|
|
78
|
+
BarComponent: defaultBarComponent,
|
|
79
|
+
BarStackComponent: BarStackComponent,
|
|
80
|
+
barMinSize: barMinSize,
|
|
81
|
+
barPadding: barPadding,
|
|
82
|
+
borderRadius: defaultBorderRadius,
|
|
83
|
+
fillOpacity: defaultFillOpacity,
|
|
84
|
+
roundBaseline: roundBaseline,
|
|
85
|
+
series: group.series,
|
|
86
|
+
stackGap: stackGap,
|
|
87
|
+
stackIndex: stackIndex,
|
|
88
|
+
stackMinSize: stackMinSize,
|
|
89
|
+
stroke: defaultStroke,
|
|
90
|
+
strokeWidth: defaultStrokeWidth,
|
|
91
|
+
totalStacks: stackGroups.length,
|
|
92
|
+
yAxisId: group.yAxisId
|
|
93
|
+
}, group.stackId))
|
|
94
|
+
})]
|
|
95
|
+
});
|
|
96
|
+
});
|