@coinbase/cds-mobile-visualization 3.4.0-beta.8 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +142 -0
- package/dts/chart/CartesianChart.d.ts +92 -7
- package/dts/chart/CartesianChart.d.ts.map +1 -1
- package/dts/chart/ChartContextBridge.d.ts.map +1 -1
- package/dts/chart/ChartProvider.d.ts +3 -0
- package/dts/chart/ChartProvider.d.ts.map +1 -1
- package/dts/chart/Path.d.ts +36 -13
- package/dts/chart/Path.d.ts.map +1 -1
- package/dts/chart/PeriodSelector.d.ts +21 -6
- package/dts/chart/PeriodSelector.d.ts.map +1 -1
- package/dts/chart/area/Area.d.ts +14 -11
- package/dts/chart/area/Area.d.ts.map +1 -1
- package/dts/chart/area/AreaChart.d.ts +33 -9
- package/dts/chart/area/AreaChart.d.ts.map +1 -1
- package/dts/chart/area/DottedArea.d.ts.map +1 -1
- package/dts/chart/area/GradientArea.d.ts.map +1 -1
- package/dts/chart/area/SolidArea.d.ts.map +1 -1
- package/dts/chart/axis/Axis.d.ts +22 -42
- package/dts/chart/axis/Axis.d.ts.map +1 -1
- package/dts/chart/axis/XAxis.d.ts +6 -0
- package/dts/chart/axis/XAxis.d.ts.map +1 -1
- package/dts/chart/axis/YAxis.d.ts +1 -0
- package/dts/chart/axis/YAxis.d.ts.map +1 -1
- package/dts/chart/bar/Bar.d.ts +51 -51
- package/dts/chart/bar/Bar.d.ts.map +1 -1
- package/dts/chart/bar/BarChart.d.ts +56 -11
- package/dts/chart/bar/BarChart.d.ts.map +1 -1
- package/dts/chart/bar/BarPlot.d.ts +2 -1
- package/dts/chart/bar/BarPlot.d.ts.map +1 -1
- package/dts/chart/bar/BarStack.d.ts +45 -20
- package/dts/chart/bar/BarStack.d.ts.map +1 -1
- package/dts/chart/bar/BarStackGroup.d.ts +2 -1
- package/dts/chart/bar/BarStackGroup.d.ts.map +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 +5 -0
- package/dts/chart/gradient/Gradient.d.ts.map +1 -1
- package/dts/chart/index.d.ts +1 -0
- 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/DottedLine.d.ts.map +1 -1
- package/dts/chart/line/Line.d.ts +23 -19
- package/dts/chart/line/Line.d.ts.map +1 -1
- package/dts/chart/line/LineChart.d.ts +26 -9
- package/dts/chart/line/LineChart.d.ts.map +1 -1
- package/dts/chart/line/ReferenceLine.d.ts +1 -0
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
- package/dts/chart/line/SolidLine.d.ts.map +1 -1
- package/dts/chart/point/Point.d.ts +26 -2
- package/dts/chart/point/Point.d.ts.map +1 -1
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +32 -2
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -1
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +2 -1
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -1
- package/dts/chart/scrubber/Scrubber.d.ts +86 -17
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts +12 -0
- package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +10 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +16 -1
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -1
- package/dts/chart/utils/axis.d.ts +45 -10
- package/dts/chart/utils/axis.d.ts.map +1 -1
- package/dts/chart/utils/bar.d.ts +190 -0
- package/dts/chart/utils/bar.d.ts.map +1 -1
- package/dts/chart/utils/chart.d.ts +32 -0
- package/dts/chart/utils/chart.d.ts.map +1 -1
- package/dts/chart/utils/context.d.ts +21 -6
- package/dts/chart/utils/context.d.ts.map +1 -1
- package/dts/chart/utils/gradient.d.ts +3 -1
- package/dts/chart/utils/gradient.d.ts.map +1 -1
- package/dts/chart/utils/path.d.ts +26 -0
- package/dts/chart/utils/path.d.ts.map +1 -1
- package/dts/chart/utils/point.d.ts +24 -12
- package/dts/chart/utils/point.d.ts.map +1 -1
- package/dts/chart/utils/scale.d.ts +11 -0
- package/dts/chart/utils/scale.d.ts.map +1 -1
- package/dts/chart/utils/scrubber.d.ts +2 -1
- package/dts/chart/utils/scrubber.d.ts.map +1 -1
- package/dts/chart/utils/transition.d.ts +63 -22
- package/dts/chart/utils/transition.d.ts.map +1 -1
- package/dts/sparkline/Sparkline.d.ts +2 -1
- package/dts/sparkline/Sparkline.d.ts.map +1 -1
- package/dts/sparkline/SparklineArea.d.ts +2 -1
- package/dts/sparkline/SparklineArea.d.ts.map +1 -1
- package/dts/sparkline/SparklineGradient.d.ts +2 -1
- package/dts/sparkline/SparklineGradient.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +2 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -1
- package/esm/chart/CartesianChart.js +176 -82
- package/esm/chart/ChartContextBridge.js +14 -3
- package/esm/chart/ChartProvider.js +2 -2
- package/esm/chart/Path.js +34 -29
- package/esm/chart/PeriodSelector.js +6 -2
- package/esm/chart/__stories__/CartesianChart.stories.js +27 -86
- package/esm/chart/__stories__/ChartAccessibility.stories.js +721 -0
- package/esm/chart/__stories__/ChartTransitions.stories.js +625 -0
- package/esm/chart/__stories__/PeriodSelector.stories.js +102 -4
- package/esm/chart/area/Area.js +21 -9
- package/esm/chart/area/AreaChart.js +18 -13
- package/esm/chart/area/DottedArea.js +28 -18
- package/esm/chart/area/GradientArea.js +14 -7
- package/esm/chart/area/SolidArea.js +6 -2
- package/esm/chart/area/__stories__/AreaChart.stories.js +47 -5
- package/esm/chart/axis/Axis.js +5 -41
- package/esm/chart/axis/XAxis.js +116 -47
- package/esm/chart/axis/YAxis.js +105 -26
- package/esm/chart/axis/__stories__/Axis.stories.js +324 -48
- package/esm/chart/bar/Bar.js +17 -15
- package/esm/chart/bar/BarChart.js +38 -33
- package/esm/chart/bar/BarPlot.js +40 -45
- package/esm/chart/bar/BarStack.js +92 -475
- package/esm/chart/bar/BarStackGroup.js +37 -27
- package/esm/chart/bar/DefaultBar.js +27 -18
- package/esm/chart/bar/DefaultBarStack.js +25 -9
- package/esm/chart/bar/__stories__/BarChart.stories.js +728 -54
- package/esm/chart/gradient/Gradient.js +2 -1
- package/esm/chart/index.js +1 -0
- 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/DottedLine.js +6 -2
- package/esm/chart/line/Line.js +42 -38
- package/esm/chart/line/LineChart.js +36 -12
- package/esm/chart/line/SolidLine.js +6 -2
- package/esm/chart/line/__stories__/LineChart.stories.js +241 -594
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +95 -1
- package/esm/chart/point/Point.js +35 -36
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +41 -38
- package/esm/chart/scrubber/DefaultScrubberLabel.js +26 -10
- package/esm/chart/scrubber/Scrubber.js +67 -35
- package/esm/chart/scrubber/ScrubberAccessibilityView.js +177 -0
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +30 -22
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +35 -8
- package/esm/chart/scrubber/ScrubberProvider.js +29 -24
- package/esm/chart/scrubber/__stories__/Scrubber.stories.js +946 -0
- package/esm/chart/utils/axis.js +88 -44
- package/esm/chart/utils/bar.js +820 -0
- package/esm/chart/utils/chart.js +34 -7
- package/esm/chart/utils/context.js +7 -0
- package/esm/chart/utils/gradient.js +8 -4
- package/esm/chart/utils/path.js +91 -61
- package/esm/chart/utils/point.js +92 -39
- package/esm/chart/utils/scale.js +13 -2
- package/esm/chart/utils/scrubber.js +12 -5
- package/esm/chart/utils/transition.js +108 -60
- package/esm/sparkline/Sparkline.js +2 -1
- package/esm/sparkline/SparklineArea.js +2 -1
- package/esm/sparkline/SparklineGradient.js +2 -1
- 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/SparklineInteractive.js +2 -1
- 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 +19 -9
- package/package.json +13 -10
- package/esm/chart/__stories__/Chart.stories.js +0 -77
|
@@ -2,17 +2,19 @@ const _excluded = ["label"],
|
|
|
2
2
|
_excluded2 = ["label", "font", "hideDot", "style"];
|
|
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
|
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
|
-
import { forwardRef, memo, useMemo, useState } from 'react';
|
|
5
|
+
import { forwardRef, memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
6
|
import { ScrollView, View } from 'react-native';
|
|
7
|
+
import { interpolateColor, runOnJS, useAnimatedReaction, useSharedValue, withSpring } from 'react-native-reanimated';
|
|
7
8
|
import { assets } from '@coinbase/cds-common/internal/data/assets';
|
|
8
9
|
import { useTabsContext } from '@coinbase/cds-common/tabs/TabsContext';
|
|
9
10
|
import { IconButton } from '@coinbase/cds-mobile/buttons';
|
|
10
11
|
import { Example, ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
|
|
11
12
|
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
13
|
+
import { Icon } from '@coinbase/cds-mobile/icons';
|
|
12
14
|
import { HStack } from '@coinbase/cds-mobile/layout';
|
|
13
15
|
import { SegmentedTab } from '@coinbase/cds-mobile/tabs/SegmentedTab';
|
|
14
|
-
import {
|
|
15
|
-
import { Text } from '@coinbase/cds-mobile/typography
|
|
16
|
+
import { tabsSpringConfig } from '@coinbase/cds-mobile/tabs/Tabs';
|
|
17
|
+
import { Text } from '@coinbase/cds-mobile/typography';
|
|
16
18
|
import { LiveTabLabel, PeriodSelector, PeriodSelectorActiveIndicator } from '../PeriodSelector';
|
|
17
19
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
20
|
const PeriodSelectorExample = () => {
|
|
@@ -71,6 +73,27 @@ const MinWidthPeriodSelectorExample = () => {
|
|
|
71
73
|
width: "fit-content"
|
|
72
74
|
});
|
|
73
75
|
};
|
|
76
|
+
const PaddedPeriodSelectorExample = () => {
|
|
77
|
+
const tabs = [{
|
|
78
|
+
id: '1W',
|
|
79
|
+
label: '1W'
|
|
80
|
+
}, {
|
|
81
|
+
id: '1M',
|
|
82
|
+
label: '1M'
|
|
83
|
+
}, {
|
|
84
|
+
id: 'YTD',
|
|
85
|
+
label: 'YTD'
|
|
86
|
+
}];
|
|
87
|
+
const [activeTab, setActiveTab] = useState(tabs[0]);
|
|
88
|
+
return /*#__PURE__*/_jsx(PeriodSelector, {
|
|
89
|
+
activeTab: activeTab,
|
|
90
|
+
gap: 2,
|
|
91
|
+
onChange: tab => setActiveTab(tab),
|
|
92
|
+
padding: 3,
|
|
93
|
+
tabs: tabs,
|
|
94
|
+
width: "fit-content"
|
|
95
|
+
});
|
|
96
|
+
};
|
|
74
97
|
const LivePeriodSelectorExample = () => {
|
|
75
98
|
const tabs = useMemo(() => [{
|
|
76
99
|
id: '1H',
|
|
@@ -196,8 +219,9 @@ const BTCTab = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
196
219
|
|
|
197
220
|
// If label is already a React element (like LiveTabLabel), pass it through directly
|
|
198
221
|
// For string labels, wrap with custom BTC color when active
|
|
199
|
-
const wrappedLabel = typeof label === 'string' ? /*#__PURE__*/_jsx(
|
|
222
|
+
const wrappedLabel = typeof label === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
200
223
|
dangerouslySetColor: isActive ? btcColor : theme.color.fg,
|
|
224
|
+
font: "label1",
|
|
201
225
|
children: label
|
|
202
226
|
}) : label;
|
|
203
227
|
return /*#__PURE__*/_jsx(SegmentedTab, _extends({
|
|
@@ -297,6 +321,74 @@ const ColoredExcludingLivePeriodSelectorExample = () => {
|
|
|
297
321
|
tabs: tabs
|
|
298
322
|
});
|
|
299
323
|
};
|
|
324
|
+
const ColoredIcon = /*#__PURE__*/memo(_ref3 => {
|
|
325
|
+
let {
|
|
326
|
+
tabId,
|
|
327
|
+
name
|
|
328
|
+
} = _ref3;
|
|
329
|
+
const {
|
|
330
|
+
activeTab
|
|
331
|
+
} = useTabsContext();
|
|
332
|
+
const isActive = (activeTab == null ? void 0 : activeTab.id) === tabId;
|
|
333
|
+
const theme = useTheme();
|
|
334
|
+
const progress = useSharedValue(isActive ? 1 : 0);
|
|
335
|
+
const [color, setColor] = useState(isActive ? theme.color.fgPrimary : theme.color.fg);
|
|
336
|
+
useEffect(() => {
|
|
337
|
+
progress.value = withSpring(isActive ? 1 : 0, tabsSpringConfig);
|
|
338
|
+
}, [isActive, progress]);
|
|
339
|
+
useAnimatedReaction(() => interpolateColor(progress.value, [0, 1], [theme.color.fg, theme.color.fgPrimary]), newColor => {
|
|
340
|
+
runOnJS(setColor)(newColor);
|
|
341
|
+
});
|
|
342
|
+
return /*#__PURE__*/_jsx(Icon, {
|
|
343
|
+
active: true,
|
|
344
|
+
name: name,
|
|
345
|
+
size: "s",
|
|
346
|
+
styles: {
|
|
347
|
+
icon: {
|
|
348
|
+
color
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
function IconsPeriodSelectorExample() {
|
|
354
|
+
const theme = useTheme();
|
|
355
|
+
const tabs = [{
|
|
356
|
+
id: 'buy',
|
|
357
|
+
label: /*#__PURE__*/_jsx(ColoredIcon, {
|
|
358
|
+
name: "chartLine",
|
|
359
|
+
tabId: "buy"
|
|
360
|
+
})
|
|
361
|
+
}, {
|
|
362
|
+
id: 'sell',
|
|
363
|
+
label: /*#__PURE__*/_jsx(ColoredIcon, {
|
|
364
|
+
name: "chartCandles",
|
|
365
|
+
tabId: "sell"
|
|
366
|
+
})
|
|
367
|
+
}, {
|
|
368
|
+
id: 'convert',
|
|
369
|
+
label: /*#__PURE__*/_jsx(ColoredIcon, {
|
|
370
|
+
name: "chartBar",
|
|
371
|
+
tabId: "convert"
|
|
372
|
+
})
|
|
373
|
+
}];
|
|
374
|
+
const [activeTab, updateActiveTab] = useState(tabs[0]);
|
|
375
|
+
const handleChange = useCallback(activeTab => updateActiveTab(activeTab), []);
|
|
376
|
+
return /*#__PURE__*/_jsx(PeriodSelector, {
|
|
377
|
+
accessibilityLabel: "Switch token action views",
|
|
378
|
+
activeTab: activeTab,
|
|
379
|
+
borderRadius: 300,
|
|
380
|
+
gap: 0.5,
|
|
381
|
+
onChange: handleChange,
|
|
382
|
+
padding: 0.5,
|
|
383
|
+
styles: {
|
|
384
|
+
activeIndicator: {
|
|
385
|
+
borderRadius: theme.borderRadius[200]
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
tabs: tabs,
|
|
389
|
+
width: "fit-content"
|
|
390
|
+
});
|
|
391
|
+
}
|
|
300
392
|
export default function All() {
|
|
301
393
|
return /*#__PURE__*/_jsxs(ExampleScreen, {
|
|
302
394
|
children: [/*#__PURE__*/_jsx(Example, {
|
|
@@ -317,6 +409,12 @@ export default function All() {
|
|
|
317
409
|
}), /*#__PURE__*/_jsx(Example, {
|
|
318
410
|
title: "Colored Excluding Live",
|
|
319
411
|
children: /*#__PURE__*/_jsx(ColoredExcludingLivePeriodSelectorExample, {})
|
|
412
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
413
|
+
title: "With Padding",
|
|
414
|
+
children: /*#__PURE__*/_jsx(PaddedPeriodSelectorExample, {})
|
|
415
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
416
|
+
title: "With Icons",
|
|
417
|
+
children: /*#__PURE__*/_jsx(IconsPeriodSelectorExample, {})
|
|
320
418
|
})]
|
|
321
419
|
});
|
|
322
420
|
}
|
package/esm/chart/area/Area.js
CHANGED
|
@@ -16,37 +16,47 @@ export const Area = /*#__PURE__*/memo(_ref => {
|
|
|
16
16
|
baseline,
|
|
17
17
|
connectNulls,
|
|
18
18
|
gradient: gradientProp,
|
|
19
|
+
transitions,
|
|
19
20
|
transition,
|
|
20
21
|
animate
|
|
21
22
|
} = _ref;
|
|
22
23
|
const {
|
|
24
|
+
layout,
|
|
23
25
|
getSeries,
|
|
24
26
|
getSeriesData,
|
|
25
27
|
getXScale,
|
|
26
28
|
getYScale,
|
|
27
|
-
getXAxis
|
|
29
|
+
getXAxis,
|
|
30
|
+
getYAxis
|
|
28
31
|
} = useCartesianChartContext();
|
|
29
32
|
const matchedSeries = useMemo(() => getSeries(seriesId), [seriesId, getSeries]);
|
|
30
33
|
const gradient = useMemo(() => gradientProp != null ? gradientProp : matchedSeries == null ? void 0 : matchedSeries.gradient, [gradientProp, matchedSeries == null ? void 0 : matchedSeries.gradient]);
|
|
31
34
|
const fill = useMemo(() => fillProp != null ? fillProp : matchedSeries == null ? void 0 : matchedSeries.color, [fillProp, matchedSeries == null ? void 0 : matchedSeries.color]);
|
|
32
35
|
const sourceData = useMemo(() => getSeriesData(seriesId), [seriesId, getSeriesData]);
|
|
33
|
-
const xAxis = getXAxis();
|
|
34
|
-
const xScale = getXScale();
|
|
36
|
+
const xAxis = getXAxis(matchedSeries == null ? void 0 : matchedSeries.xAxisId);
|
|
37
|
+
const xScale = getXScale(matchedSeries == null ? void 0 : matchedSeries.xAxisId);
|
|
35
38
|
const yScale = getYScale(matchedSeries == null ? void 0 : matchedSeries.yAxisId);
|
|
39
|
+
const yAxis = getYAxis(matchedSeries == null ? void 0 : matchedSeries.yAxisId);
|
|
40
|
+
const categoryAxisIsX = useMemo(() => {
|
|
41
|
+
return layout !== 'horizontal';
|
|
42
|
+
}, [layout]);
|
|
43
|
+
const categoryAxis = useMemo(() => {
|
|
44
|
+
return categoryAxisIsX ? xAxis : yAxis;
|
|
45
|
+
}, [categoryAxisIsX, xAxis, yAxis]);
|
|
36
46
|
const area = useMemo(() => {
|
|
37
47
|
if (!sourceData || sourceData.length === 0 || !xScale || !yScale) return '';
|
|
38
|
-
|
|
39
|
-
// Get numeric x-axis data if available
|
|
40
|
-
const xData = xAxis != null && xAxis.data && Array.isArray(xAxis.data) && typeof xAxis.data[0] === 'number' ? xAxis.data : undefined;
|
|
48
|
+
const indexData = categoryAxis != null && categoryAxis.data && Array.isArray(categoryAxis.data) && typeof categoryAxis.data[0] === 'number' ? categoryAxis.data : undefined;
|
|
41
49
|
return getAreaPath({
|
|
42
50
|
data: sourceData,
|
|
43
51
|
xScale,
|
|
44
52
|
yScale,
|
|
45
53
|
curve,
|
|
46
|
-
xData,
|
|
47
|
-
|
|
54
|
+
xData: categoryAxisIsX ? indexData : undefined,
|
|
55
|
+
yData: !categoryAxisIsX ? indexData : undefined,
|
|
56
|
+
connectNulls,
|
|
57
|
+
layout
|
|
48
58
|
});
|
|
49
|
-
}, [sourceData, xScale, yScale, curve,
|
|
59
|
+
}, [sourceData, xScale, yScale, curve, categoryAxis, categoryAxisIsX, connectNulls, layout]);
|
|
50
60
|
const AreaComponent = useMemo(() => {
|
|
51
61
|
if (AreaComponentProp) {
|
|
52
62
|
return AreaComponentProp;
|
|
@@ -70,6 +80,8 @@ export const Area = /*#__PURE__*/memo(_ref => {
|
|
|
70
80
|
fillOpacity: fillOpacity,
|
|
71
81
|
gradient: gradient,
|
|
72
82
|
transition: transition,
|
|
83
|
+
transitions: transitions,
|
|
84
|
+
xAxisId: matchedSeries == null ? void 0 : matchedSeries.xAxisId,
|
|
73
85
|
yAxisId: matchedSeries == null ? void 0 : matchedSeries.yAxisId
|
|
74
86
|
});
|
|
75
87
|
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const _excluded = ["series", "stacked", "AreaComponent", "curve", "fillOpacity", "type", "connectNulls", "transition", "LineComponent", "strokeWidth", "showXAxis", "showYAxis", "showLines", "lineType", "xAxis", "yAxis", "inset", "children"],
|
|
2
|
-
_excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range"],
|
|
1
|
+
const _excluded = ["series", "stacked", "AreaComponent", "curve", "fillOpacity", "type", "connectNulls", "transition", "transitions", "LineComponent", "strokeWidth", "showXAxis", "showYAxis", "showLines", "lineType", "xAxis", "yAxis", "inset", "children"],
|
|
2
|
+
_excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"],
|
|
3
3
|
_excluded3 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"],
|
|
4
|
-
_excluded4 = ["id", "data", "label", "color", "yAxisId", "opacity", "LineComponent", "stackId"],
|
|
5
|
-
_excluded5 = ["id", "data", "label", "color", "yAxisId", "fill", "fillOpacity", "stackId", "type"
|
|
4
|
+
_excluded4 = ["id", "data", "label", "color", "xAxisId", "yAxisId", "opacity", "LineComponent", "stackId"],
|
|
5
|
+
_excluded5 = ["id", "data", "label", "color", "xAxisId", "yAxisId", "fill", "fillOpacity", "stackId", "type"];
|
|
6
6
|
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); }
|
|
7
7
|
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; }
|
|
8
8
|
import { forwardRef, memo, useMemo } from 'react';
|
|
9
9
|
import { XAxis, YAxis } from '../axis';
|
|
10
10
|
import { CartesianChart } from '../CartesianChart';
|
|
11
11
|
import { Line } from '../line/Line';
|
|
12
|
-
import {
|
|
12
|
+
import { defaultStackId } from '../utils';
|
|
13
13
|
import { Area } from './Area';
|
|
14
14
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
15
|
export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
@@ -22,6 +22,7 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
22
22
|
type,
|
|
23
23
|
connectNulls,
|
|
24
24
|
transition,
|
|
25
|
+
transitions,
|
|
25
26
|
LineComponent,
|
|
26
27
|
strokeWidth,
|
|
27
28
|
showXAxis,
|
|
@@ -34,8 +35,6 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
34
35
|
children
|
|
35
36
|
} = _ref,
|
|
36
37
|
chartProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
37
|
-
const calculatedInset = useMemo(() => getChartInset(inset, defaultChartInset), [inset]);
|
|
38
|
-
|
|
39
38
|
// Convert AreaSeries to Series for Chart context
|
|
40
39
|
const chartSeries = useMemo(() => {
|
|
41
40
|
return series == null ? void 0 : series.map(s => ({
|
|
@@ -44,6 +43,7 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
44
43
|
label: s.label,
|
|
45
44
|
color: s.color,
|
|
46
45
|
gradient: s.gradient,
|
|
46
|
+
xAxisId: s.xAxisId,
|
|
47
47
|
yAxisId: s.yAxisId,
|
|
48
48
|
stackId: s.stackId
|
|
49
49
|
}));
|
|
@@ -67,7 +67,8 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
67
67
|
categoryPadding: xCategoryPadding,
|
|
68
68
|
domain: xDomain,
|
|
69
69
|
domainLimit: xDomainLimit,
|
|
70
|
-
range: xRange
|
|
70
|
+
range: xRange,
|
|
71
|
+
id: xAxisId
|
|
71
72
|
} = _ref2,
|
|
72
73
|
xAxisVisualProps = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
73
74
|
const _ref3 = yAxis || {},
|
|
@@ -110,11 +111,13 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
110
111
|
};
|
|
111
112
|
return /*#__PURE__*/_jsxs(CartesianChart, _extends({}, chartProps, {
|
|
112
113
|
ref: ref,
|
|
113
|
-
inset:
|
|
114
|
+
inset: inset,
|
|
114
115
|
series: seriesToRender,
|
|
115
116
|
xAxis: xAxisConfig,
|
|
116
117
|
yAxis: yAxisConfig,
|
|
117
|
-
children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _extends({
|
|
118
|
+
children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _extends({
|
|
119
|
+
axisId: xAxisId
|
|
120
|
+
}, xAxisVisualProps)), showYAxis && /*#__PURE__*/_jsx(YAxis, _extends({
|
|
118
121
|
axisId: yAxisId
|
|
119
122
|
}, yAxisVisualProps)), series == null ? void 0 : series.map(_ref4 => {
|
|
120
123
|
let {
|
|
@@ -128,13 +131,14 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
128
131
|
fillOpacity: fillOpacity,
|
|
129
132
|
seriesId: id,
|
|
130
133
|
transition: transition,
|
|
134
|
+
transitions: transitions,
|
|
131
135
|
type: type
|
|
132
136
|
}, areaPropsFromSeries), id);
|
|
133
137
|
}), showLines && (series == null ? void 0 : series.map(_ref5 => {
|
|
134
138
|
let {
|
|
135
|
-
id
|
|
139
|
+
id
|
|
140
|
+
|
|
136
141
|
// Area type (don't pass to Line)
|
|
137
|
-
lineType: seriesLineType
|
|
138
142
|
} = _ref5,
|
|
139
143
|
otherPropsFromSeries = _objectWithoutPropertiesLoose(_ref5, _excluded5);
|
|
140
144
|
return /*#__PURE__*/_jsx(Line, _extends({
|
|
@@ -144,7 +148,8 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
144
148
|
seriesId: id,
|
|
145
149
|
strokeWidth: strokeWidth,
|
|
146
150
|
transition: transition,
|
|
147
|
-
|
|
151
|
+
transitions: transitions,
|
|
152
|
+
type: lineType
|
|
148
153
|
}, otherPropsFromSeries), id);
|
|
149
154
|
})), children]
|
|
150
155
|
}));
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const _excluded = ["d", "fill", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "animate", "transition"];
|
|
1
|
+
const _excluded = ["d", "fill", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "xAxisId", "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
4
|
import { memo, useMemo } from 'react';
|
|
5
5
|
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
6
|
-
import { Group
|
|
6
|
+
import { Group } from '@shopify/react-native-skia';
|
|
7
7
|
import { useCartesianChartContext } from '../ChartProvider';
|
|
8
8
|
import { Gradient } from '../gradient';
|
|
9
9
|
import { Path } from '../Path';
|
|
10
10
|
import { createGradient, getBaseline } from '../utils';
|
|
11
11
|
import { getDottedAreaPath } from '../utils/path';
|
|
12
|
-
import { usePathTransition } from '../utils/transition';
|
|
12
|
+
import { defaultTransition, usePathTransition } from '../utils/transition';
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
/**
|
|
15
15
|
* A customizable dotted area gradient component.
|
|
@@ -25,9 +25,11 @@ export const DottedArea = /*#__PURE__*/memo(_ref => {
|
|
|
25
25
|
peakOpacity = 1,
|
|
26
26
|
baselineOpacity = 0,
|
|
27
27
|
baseline,
|
|
28
|
+
xAxisId,
|
|
28
29
|
yAxisId,
|
|
29
30
|
gradient: gradientProp,
|
|
30
31
|
animate: animateProp,
|
|
32
|
+
transitions,
|
|
31
33
|
transition
|
|
32
34
|
} = _ref,
|
|
33
35
|
pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
@@ -35,10 +37,17 @@ export const DottedArea = /*#__PURE__*/memo(_ref => {
|
|
|
35
37
|
const {
|
|
36
38
|
drawingArea,
|
|
37
39
|
animate,
|
|
40
|
+
layout,
|
|
41
|
+
getXAxis,
|
|
38
42
|
getYAxis
|
|
39
43
|
} = useCartesianChartContext();
|
|
40
|
-
const
|
|
44
|
+
const shouldAnimate = animateProp != null ? animateProp : animate;
|
|
45
|
+
const valueAxisConfig = layout !== 'horizontal' ? getYAxis(yAxisId) : getXAxis(xAxisId);
|
|
46
|
+
const gradientAxis = layout !== 'horizontal' ? 'y' : 'x';
|
|
41
47
|
const fill = useMemo(() => fillProp != null ? fillProp : theme.color.fgPrimary, [fillProp, theme.color.fgPrimary]);
|
|
48
|
+
const updateTransition = useMemo(() => {
|
|
49
|
+
return (transitions == null ? void 0 : transitions.update) !== undefined ? transitions.update : transition !== undefined ? transition : defaultTransition;
|
|
50
|
+
}, [transitions == null ? void 0 : transitions.update, transition]);
|
|
42
51
|
const dottedPath = useMemo(() => {
|
|
43
52
|
if (!drawingArea) return '';
|
|
44
53
|
return getDottedAreaPath({
|
|
@@ -48,31 +57,32 @@ export const DottedArea = /*#__PURE__*/memo(_ref => {
|
|
|
48
57
|
height: drawingArea.height
|
|
49
58
|
}, patternSize, dotSize);
|
|
50
59
|
}, [drawingArea, patternSize, dotSize]);
|
|
51
|
-
const
|
|
60
|
+
const clipPath = usePathTransition({
|
|
52
61
|
currentPath: d,
|
|
53
|
-
|
|
62
|
+
transitions: {
|
|
63
|
+
update: shouldAnimate ? updateTransition : null
|
|
64
|
+
}
|
|
54
65
|
});
|
|
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
66
|
const gradient = useMemo(() => {
|
|
61
67
|
if (gradientProp) return gradientProp;
|
|
62
|
-
if (!
|
|
63
|
-
const baselineValue = getBaseline(
|
|
64
|
-
return createGradient(
|
|
65
|
-
}, [gradientProp,
|
|
68
|
+
if (!valueAxisConfig) return;
|
|
69
|
+
const baselineValue = getBaseline(valueAxisConfig.domain, baseline);
|
|
70
|
+
return createGradient(valueAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity, gradientAxis);
|
|
71
|
+
}, [gradientProp, valueAxisConfig, fill, baseline, peakOpacity, baselineOpacity, gradientAxis]);
|
|
72
|
+
|
|
73
|
+
// Update transition is used for clip path, we skip update animation on Path itself
|
|
66
74
|
return /*#__PURE__*/_jsx(Group, {
|
|
67
|
-
clip:
|
|
75
|
+
clip: clipPath,
|
|
68
76
|
children: /*#__PURE__*/_jsx(Path, _extends({
|
|
69
|
-
animate:
|
|
77
|
+
animate: shouldAnimate,
|
|
70
78
|
d: dottedPath,
|
|
71
79
|
fill: fill,
|
|
72
|
-
transition: transition
|
|
80
|
+
transition: transition,
|
|
81
|
+
transitions: transitions
|
|
73
82
|
}, pathProps, {
|
|
74
83
|
children: gradient && /*#__PURE__*/_jsx(Gradient, {
|
|
75
84
|
gradient: gradient,
|
|
85
|
+
xAxisId: xAxisId,
|
|
76
86
|
yAxisId: yAxisId
|
|
77
87
|
})
|
|
78
88
|
}))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["d", "fill", "fillOpacity", "gradient", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "animate", "transition"];
|
|
1
|
+
const _excluded = ["d", "fill", "fillOpacity", "gradient", "peakOpacity", "baselineOpacity", "baseline", "xAxisId", "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
4
|
import { memo, useMemo } from 'react';
|
|
@@ -22,32 +22,39 @@ export const GradientArea = /*#__PURE__*/memo(_ref => {
|
|
|
22
22
|
peakOpacity = 0.3,
|
|
23
23
|
baselineOpacity = 0,
|
|
24
24
|
baseline,
|
|
25
|
+
xAxisId,
|
|
25
26
|
yAxisId,
|
|
26
27
|
animate,
|
|
28
|
+
transitions,
|
|
27
29
|
transition
|
|
28
30
|
} = _ref,
|
|
29
31
|
pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
30
32
|
const {
|
|
33
|
+
layout,
|
|
34
|
+
getXAxis,
|
|
31
35
|
getYAxis
|
|
32
36
|
} = useCartesianChartContext();
|
|
33
37
|
const theme = useTheme();
|
|
34
|
-
const
|
|
38
|
+
const valueAxisConfig = layout !== 'horizontal' ? getYAxis(yAxisId) : getXAxis(xAxisId);
|
|
39
|
+
const gradientAxis = layout !== 'horizontal' ? 'y' : 'x';
|
|
35
40
|
const fill = useMemo(() => fillProp != null ? fillProp : theme.color.fgPrimary, [fillProp, theme.color.fgPrimary]);
|
|
36
41
|
const gradient = useMemo(() => {
|
|
37
42
|
if (gradientProp) return gradientProp;
|
|
38
|
-
if (!
|
|
39
|
-
const baselineValue = getBaseline(
|
|
40
|
-
return createGradient(
|
|
41
|
-
}, [gradientProp,
|
|
43
|
+
if (!valueAxisConfig) return;
|
|
44
|
+
const baselineValue = getBaseline(valueAxisConfig.domain, baseline);
|
|
45
|
+
return createGradient(valueAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity, gradientAxis);
|
|
46
|
+
}, [gradientProp, valueAxisConfig, fill, baseline, peakOpacity, baselineOpacity, gradientAxis]);
|
|
42
47
|
return /*#__PURE__*/_jsx(Path, _extends({
|
|
43
48
|
animate: animate,
|
|
44
49
|
d: d,
|
|
45
50
|
fill: fill,
|
|
46
51
|
fillOpacity: fillOpacity,
|
|
47
|
-
transition: transition
|
|
52
|
+
transition: transition,
|
|
53
|
+
transitions: transitions
|
|
48
54
|
}, pathProps, {
|
|
49
55
|
children: gradient && /*#__PURE__*/_jsx(Gradient, {
|
|
50
56
|
gradient: gradient,
|
|
57
|
+
xAxisId: xAxisId,
|
|
51
58
|
yAxisId: yAxisId
|
|
52
59
|
})
|
|
53
60
|
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["d", "fill", "fillOpacity", "yAxisId", "animate", "transition", "gradient"];
|
|
1
|
+
const _excluded = ["d", "fill", "fillOpacity", "xAxisId", "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';
|
|
@@ -16,8 +16,10 @@ export const SolidArea = /*#__PURE__*/memo(_ref => {
|
|
|
16
16
|
d,
|
|
17
17
|
fill,
|
|
18
18
|
fillOpacity = 1,
|
|
19
|
+
xAxisId,
|
|
19
20
|
yAxisId,
|
|
20
21
|
animate,
|
|
22
|
+
transitions,
|
|
21
23
|
transition,
|
|
22
24
|
gradient
|
|
23
25
|
} = _ref,
|
|
@@ -28,10 +30,12 @@ export const SolidArea = /*#__PURE__*/memo(_ref => {
|
|
|
28
30
|
d: d,
|
|
29
31
|
fill: fill != null ? fill : theme.color.fgPrimary,
|
|
30
32
|
fillOpacity: fillOpacity,
|
|
31
|
-
transition: transition
|
|
33
|
+
transition: transition,
|
|
34
|
+
transitions: transitions
|
|
32
35
|
}, pathProps, {
|
|
33
36
|
children: gradient && /*#__PURE__*/_jsx(Gradient, {
|
|
34
37
|
gradient: gradient,
|
|
38
|
+
xAxisId: xAxisId,
|
|
35
39
|
yAxisId: yAxisId
|
|
36
40
|
})
|
|
37
41
|
}));
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
1
2
|
import { Example, ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
|
|
2
3
|
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
3
4
|
import { DottedLine } from '../../line';
|
|
4
5
|
import { Scrubber } from '../../scrubber/Scrubber';
|
|
5
6
|
import { AreaChart } from '..';
|
|
6
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
const basicData = [24, 13, 98, 39, 48, 38, 43];
|
|
7
9
|
const BasicExample = () => {
|
|
10
|
+
const getScrubberAccessibilityLabel = useCallback(index => "Point " + (index + 1) + ": " + basicData[index], []);
|
|
8
11
|
return /*#__PURE__*/_jsx(AreaChart, {
|
|
9
12
|
enableScrubbing: true,
|
|
10
13
|
showYAxis: true,
|
|
14
|
+
accessibilityLabel: "Area chart with " + basicData.length + " data points. Swipe to navigate.",
|
|
15
|
+
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
11
16
|
height: 400,
|
|
12
17
|
series: [{
|
|
13
18
|
id: 'pageViews',
|
|
14
|
-
data:
|
|
19
|
+
data: basicData
|
|
15
20
|
}],
|
|
16
21
|
yAxis: {
|
|
17
22
|
showGrid: true,
|
|
@@ -22,21 +27,26 @@ const BasicExample = () => {
|
|
|
22
27
|
children: /*#__PURE__*/_jsx(Scrubber, {})
|
|
23
28
|
});
|
|
24
29
|
};
|
|
30
|
+
const currentRewardsData = [100, 150, 200, 280, 380, 500, 650, 820, 1020, 1250, 1510, 1800, 2120, 2470, 2850, 3260, 3700, 4170];
|
|
31
|
+
const potentialRewardsData = [150, 220, 300, 400, 520, 660, 820, 1000, 1200, 1420, 1660, 1920, 2200, 2500, 2820, 3160, 3520, 3900];
|
|
25
32
|
const StackedExample = () => {
|
|
26
33
|
const theme = useTheme();
|
|
34
|
+
const getScrubberAccessibilityLabel = useCallback(index => "Point " + (index + 1) + ": current " + currentRewardsData[index] + ", potential " + potentialRewardsData[index], []);
|
|
27
35
|
return /*#__PURE__*/_jsx(AreaChart, {
|
|
28
36
|
enableScrubbing: true,
|
|
29
37
|
showLines: true,
|
|
30
38
|
stacked: true,
|
|
39
|
+
accessibilityLabel: "Stacked rewards chart with " + currentRewardsData.length + " data points. Swipe to navigate.",
|
|
31
40
|
curve: "natural",
|
|
41
|
+
getScrubberAccessibilityLabel: getScrubberAccessibilityLabel,
|
|
32
42
|
height: 256,
|
|
33
43
|
series: [{
|
|
34
44
|
id: 'currentRewards',
|
|
35
|
-
data:
|
|
45
|
+
data: currentRewardsData,
|
|
36
46
|
color: theme.color.fg
|
|
37
47
|
}, {
|
|
38
48
|
id: 'potentialRewards',
|
|
39
|
-
data:
|
|
49
|
+
data: potentialRewardsData,
|
|
40
50
|
color: theme.color.fgPositive,
|
|
41
51
|
type: 'dotted',
|
|
42
52
|
LineComponent: DottedLine
|
|
@@ -59,12 +69,14 @@ const AreaChartStories = () => {
|
|
|
59
69
|
enableScrubbing: true,
|
|
60
70
|
showLines: true,
|
|
61
71
|
showYAxis: true,
|
|
62
|
-
|
|
72
|
+
accessibilityLabel: "Area chart with negative values. 7 data points. Swipe to navigate.",
|
|
73
|
+
getScrubberAccessibilityLabel: index => "Point " + (index + 1) + ": " + [24, 13, -98, 39, 48, 38, 43][index],
|
|
74
|
+
height: 150,
|
|
63
75
|
series: [{
|
|
64
76
|
id: 'pageViews',
|
|
65
77
|
data: [24, 13, -98, 39, 48, 38, 43]
|
|
66
78
|
}],
|
|
67
|
-
type: "
|
|
79
|
+
type: "gradient",
|
|
68
80
|
yAxis: {
|
|
69
81
|
showGrid: true
|
|
70
82
|
},
|
|
@@ -94,6 +106,36 @@ const AreaChartStories = () => {
|
|
|
94
106
|
type: 'gradient'
|
|
95
107
|
}]
|
|
96
108
|
})
|
|
109
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
110
|
+
title: "Horizontal Layout",
|
|
111
|
+
children: /*#__PURE__*/_jsx(AreaChart, {
|
|
112
|
+
enableScrubbing: true,
|
|
113
|
+
showLines: true,
|
|
114
|
+
showXAxis: true,
|
|
115
|
+
showYAxis: true,
|
|
116
|
+
accessibilityLabel: "Volume by asset. 5 data points. Swipe to navigate.",
|
|
117
|
+
getScrubberAccessibilityLabel: index => ['BTC', 'ETH', 'SOL', 'DOGE', 'ADA'][index] + ": " + [68, 54, 43, 29, 18][index] + "%",
|
|
118
|
+
height: 280,
|
|
119
|
+
layout: "horizontal",
|
|
120
|
+
series: [{
|
|
121
|
+
id: 'volume',
|
|
122
|
+
data: [68, 54, 43, 29, 18],
|
|
123
|
+
label: 'Volume'
|
|
124
|
+
}],
|
|
125
|
+
type: "gradient",
|
|
126
|
+
xAxis: {
|
|
127
|
+
domain: {
|
|
128
|
+
min: 0,
|
|
129
|
+
max: 80
|
|
130
|
+
},
|
|
131
|
+
tickLabelFormatter: value => value + "%"
|
|
132
|
+
},
|
|
133
|
+
yAxis: {
|
|
134
|
+
data: ['BTC', 'ETH', 'SOL', 'DOGE', 'ADA'],
|
|
135
|
+
scaleType: 'band'
|
|
136
|
+
},
|
|
137
|
+
children: /*#__PURE__*/_jsx(Scrubber, {})
|
|
138
|
+
})
|
|
97
139
|
})]
|
|
98
140
|
});
|
|
99
141
|
};
|
package/esm/chart/axis/Axis.js
CHANGED
|
@@ -1,45 +1,9 @@
|
|
|
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
|
-
};
|
|
1
|
+
import { accessoryFadeTransitionDuration } from '../utils';
|
|
24
2
|
|
|
25
3
|
/**
|
|
26
|
-
* Animation
|
|
4
|
+
* Animation transition for axis elements (grid lines, tick marks, tick labels).
|
|
5
|
+
* Matches web's axisUpdateAnimationTransition timing.
|
|
27
6
|
*/
|
|
28
|
-
export const
|
|
29
|
-
|
|
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
|
-
}
|
|
7
|
+
export const axisUpdateAnimationTransition = {
|
|
8
|
+
duration: accessoryFadeTransitionDuration
|
|
45
9
|
};
|