@coinbase/cds-mobile-visualization 3.4.0-beta.17 → 3.4.0-beta.19
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 +12 -0
- package/dts/chart/Path.d.ts +35 -13
- package/dts/chart/Path.d.ts.map +1 -1
- package/dts/chart/area/Area.d.ts +7 -11
- package/dts/chart/area/Area.d.ts.map +1 -1
- package/dts/chart/area/AreaChart.d.ts +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/bar/Bar.d.ts +32 -2
- package/dts/chart/bar/Bar.d.ts.map +1 -1
- package/dts/chart/bar/BarChart.d.ts +2 -0
- 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 +5 -10
- package/dts/chart/bar/BarStack.d.ts.map +1 -1
- package/dts/chart/bar/BarStackGroup.d.ts +1 -0
- 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/line/DottedLine.d.ts.map +1 -1
- package/dts/chart/line/Line.d.ts +4 -9
- package/dts/chart/line/Line.d.ts.map +1 -1
- package/dts/chart/line/LineChart.d.ts +1 -1
- package/dts/chart/line/SolidLine.d.ts.map +1 -1
- package/dts/chart/point/Point.d.ts +18 -2
- package/dts/chart/point/Point.d.ts.map +1 -1
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +9 -1
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -1
- package/dts/chart/scrubber/Scrubber.d.ts +45 -24
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +9 -1
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -1
- package/dts/chart/utils/bar.d.ts +34 -0
- package/dts/chart/utils/bar.d.ts.map +1 -1
- package/dts/chart/utils/path.d.ts +6 -0
- package/dts/chart/utils/path.d.ts.map +1 -1
- package/dts/chart/utils/transition.d.ts +59 -21
- package/dts/chart/utils/transition.d.ts.map +1 -1
- package/esm/chart/Path.js +18 -17
- package/esm/chart/__stories__/CartesianChart.stories.js +3 -77
- package/esm/chart/__stories__/ChartTransitions.stories.js +629 -0
- package/esm/chart/area/Area.js +2 -0
- package/esm/chart/area/DottedArea.js +7 -3
- package/esm/chart/area/GradientArea.js +4 -2
- package/esm/chart/area/SolidArea.js +4 -2
- package/esm/chart/bar/Bar.js +2 -0
- package/esm/chart/bar/BarChart.js +4 -2
- package/esm/chart/bar/BarPlot.js +2 -0
- package/esm/chart/bar/BarStack.js +3 -0
- package/esm/chart/bar/DefaultBar.js +15 -15
- package/esm/chart/bar/DefaultBarStack.js +14 -3
- package/esm/chart/bar/__stories__/BarChart.stories.js +448 -52
- package/esm/chart/line/DottedLine.js +4 -2
- package/esm/chart/line/Line.js +6 -17
- package/esm/chart/line/SolidLine.js +4 -2
- package/esm/chart/line/__stories__/LineChart.stories.js +130 -235
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +95 -1
- package/esm/chart/point/Point.js +33 -35
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +2 -5
- package/esm/chart/scrubber/Scrubber.js +15 -14
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +29 -7
- package/esm/chart/utils/bar.js +43 -0
- package/esm/chart/utils/path.js +8 -0
- package/esm/chart/utils/transition.js +96 -61
- package/package.json +5 -5
- package/esm/chart/__stories__/Chart.stories.js +0 -77
|
@@ -0,0 +1,629 @@
|
|
|
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, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { Button } from '@coinbase/cds-mobile/buttons/Button';
|
|
4
|
+
import { IconButton } from '@coinbase/cds-mobile/buttons/IconButton';
|
|
5
|
+
import { ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
|
|
6
|
+
import { Box, HStack, VStack } from '@coinbase/cds-mobile/layout';
|
|
7
|
+
import { Text } from '@coinbase/cds-mobile/typography';
|
|
8
|
+
import { Area } from '../area/Area';
|
|
9
|
+
import { BarChart } from '../bar/BarChart';
|
|
10
|
+
import { CartesianChart } from '../CartesianChart';
|
|
11
|
+
import { Line } from '../line/Line';
|
|
12
|
+
import { Scrubber } from '../scrubber';
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
const dataCount = 15;
|
|
15
|
+
const updateInterval = 2500;
|
|
16
|
+
const rapidUpdateInterval = 800;
|
|
17
|
+
function generateNextValue(previousValue) {
|
|
18
|
+
const step = Math.random() * 30 - 15;
|
|
19
|
+
return Math.max(0, Math.min(100, previousValue + step));
|
|
20
|
+
}
|
|
21
|
+
function generateInitialData() {
|
|
22
|
+
const data = [50];
|
|
23
|
+
for (let i = 1; i < dataCount; i++) {
|
|
24
|
+
data.push(generateNextValue(data[i - 1]));
|
|
25
|
+
}
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Transition presets
|
|
30
|
+
const enterOnly = {
|
|
31
|
+
update: null
|
|
32
|
+
};
|
|
33
|
+
const updateOnly = {
|
|
34
|
+
enter: null
|
|
35
|
+
};
|
|
36
|
+
const bothDisabled = {
|
|
37
|
+
enter: null,
|
|
38
|
+
update: null
|
|
39
|
+
};
|
|
40
|
+
const customEnterUpdate = {
|
|
41
|
+
enter: {
|
|
42
|
+
type: 'timing',
|
|
43
|
+
duration: 1500
|
|
44
|
+
},
|
|
45
|
+
update: {
|
|
46
|
+
type: 'spring',
|
|
47
|
+
stiffness: 400,
|
|
48
|
+
damping: 30
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const customEnterUpdateBeacon = {
|
|
52
|
+
enter: {
|
|
53
|
+
type: 'timing',
|
|
54
|
+
duration: 500,
|
|
55
|
+
delay: 1000
|
|
56
|
+
},
|
|
57
|
+
update: {
|
|
58
|
+
type: 'spring',
|
|
59
|
+
stiffness: 400,
|
|
60
|
+
damping: 30
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const slowSpringBoth = {
|
|
64
|
+
enter: {
|
|
65
|
+
type: 'spring',
|
|
66
|
+
stiffness: 100,
|
|
67
|
+
damping: 10
|
|
68
|
+
},
|
|
69
|
+
update: {
|
|
70
|
+
type: 'spring',
|
|
71
|
+
stiffness: 100,
|
|
72
|
+
damping: 10
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const staggeredBoth = {
|
|
76
|
+
enter: {
|
|
77
|
+
type: 'timing',
|
|
78
|
+
duration: 750,
|
|
79
|
+
staggerDelay: 250
|
|
80
|
+
},
|
|
81
|
+
update: {
|
|
82
|
+
type: 'spring',
|
|
83
|
+
stiffness: 300,
|
|
84
|
+
damping: 20,
|
|
85
|
+
staggerDelay: 150
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const slowTimingBoth = {
|
|
89
|
+
enter: {
|
|
90
|
+
type: 'timing',
|
|
91
|
+
duration: 2000
|
|
92
|
+
},
|
|
93
|
+
update: {
|
|
94
|
+
type: 'timing',
|
|
95
|
+
duration: 2000
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// --- Reusable Chart Components ---
|
|
100
|
+
|
|
101
|
+
const TransitionLineChart = /*#__PURE__*/memo(_ref => {
|
|
102
|
+
let {
|
|
103
|
+
data,
|
|
104
|
+
transitions,
|
|
105
|
+
scrubberTransitions,
|
|
106
|
+
animate: animateProp,
|
|
107
|
+
idlePulse,
|
|
108
|
+
scrubberRef,
|
|
109
|
+
enableScrubbing = true,
|
|
110
|
+
points
|
|
111
|
+
} = _ref;
|
|
112
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
113
|
+
animate: animateProp,
|
|
114
|
+
enableScrubbing: enableScrubbing,
|
|
115
|
+
height: 200,
|
|
116
|
+
inset: {
|
|
117
|
+
top: 16,
|
|
118
|
+
bottom: 16,
|
|
119
|
+
left: 16,
|
|
120
|
+
right: 16
|
|
121
|
+
},
|
|
122
|
+
series: [{
|
|
123
|
+
id: 'values',
|
|
124
|
+
data
|
|
125
|
+
}],
|
|
126
|
+
children: [/*#__PURE__*/_jsx(Line, {
|
|
127
|
+
points: points,
|
|
128
|
+
seriesId: "values",
|
|
129
|
+
strokeWidth: 3,
|
|
130
|
+
transitions: transitions
|
|
131
|
+
}), enableScrubbing && /*#__PURE__*/_jsx(Scrubber, {
|
|
132
|
+
ref: scrubberRef,
|
|
133
|
+
hideOverlay: true,
|
|
134
|
+
idlePulse: idlePulse,
|
|
135
|
+
transitions: scrubberTransitions != null ? scrubberTransitions : transitions
|
|
136
|
+
})]
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
const TransitionAreaChart = /*#__PURE__*/memo(_ref2 => {
|
|
140
|
+
let {
|
|
141
|
+
data,
|
|
142
|
+
transitions,
|
|
143
|
+
idlePulse,
|
|
144
|
+
scrubberRef
|
|
145
|
+
} = _ref2;
|
|
146
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
147
|
+
enableScrubbing: true,
|
|
148
|
+
height: 200,
|
|
149
|
+
inset: {
|
|
150
|
+
top: 16,
|
|
151
|
+
bottom: 16,
|
|
152
|
+
left: 16,
|
|
153
|
+
right: 16
|
|
154
|
+
},
|
|
155
|
+
series: [{
|
|
156
|
+
id: 'values',
|
|
157
|
+
data
|
|
158
|
+
}],
|
|
159
|
+
children: [/*#__PURE__*/_jsx(Area, {
|
|
160
|
+
seriesId: "values",
|
|
161
|
+
transitions: transitions
|
|
162
|
+
}), /*#__PURE__*/_jsx(Line, {
|
|
163
|
+
seriesId: "values",
|
|
164
|
+
transitions: transitions
|
|
165
|
+
}), /*#__PURE__*/_jsx(Scrubber, {
|
|
166
|
+
ref: scrubberRef,
|
|
167
|
+
hideOverlay: true,
|
|
168
|
+
idlePulse: idlePulse,
|
|
169
|
+
transitions: transitions
|
|
170
|
+
})]
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
const MultiLineChart = /*#__PURE__*/memo(_ref3 => {
|
|
174
|
+
let {
|
|
175
|
+
data1,
|
|
176
|
+
data2,
|
|
177
|
+
transitions
|
|
178
|
+
} = _ref3;
|
|
179
|
+
return /*#__PURE__*/_jsxs(CartesianChart, {
|
|
180
|
+
enableScrubbing: true,
|
|
181
|
+
height: 200,
|
|
182
|
+
inset: {
|
|
183
|
+
top: 16,
|
|
184
|
+
bottom: 16,
|
|
185
|
+
left: 16,
|
|
186
|
+
right: 16
|
|
187
|
+
},
|
|
188
|
+
series: [{
|
|
189
|
+
id: 'series1',
|
|
190
|
+
data: data1,
|
|
191
|
+
label: 'Series 1'
|
|
192
|
+
}, {
|
|
193
|
+
id: 'series2',
|
|
194
|
+
data: data2,
|
|
195
|
+
label: 'Series 2'
|
|
196
|
+
}],
|
|
197
|
+
children: [/*#__PURE__*/_jsx(Line, {
|
|
198
|
+
seriesId: "series1",
|
|
199
|
+
strokeWidth: 3,
|
|
200
|
+
transitions: transitions
|
|
201
|
+
}), /*#__PURE__*/_jsx(Line, {
|
|
202
|
+
seriesId: "series2",
|
|
203
|
+
strokeWidth: 3,
|
|
204
|
+
transitions: transitions
|
|
205
|
+
}), /*#__PURE__*/_jsx(Scrubber, {
|
|
206
|
+
hideOverlay: true,
|
|
207
|
+
idlePulse: true,
|
|
208
|
+
transitions: transitions
|
|
209
|
+
})]
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// --- Self-contained Example Wrappers ---
|
|
214
|
+
|
|
215
|
+
function LineExample(_ref4) {
|
|
216
|
+
let {
|
|
217
|
+
transitions,
|
|
218
|
+
scrubberTransitions,
|
|
219
|
+
pointTransitions,
|
|
220
|
+
animate,
|
|
221
|
+
idlePulse,
|
|
222
|
+
resettable = true,
|
|
223
|
+
imperative = false,
|
|
224
|
+
points
|
|
225
|
+
} = _ref4;
|
|
226
|
+
const scrubberRef = useRef(null);
|
|
227
|
+
const [data, setData] = useState(generateInitialData);
|
|
228
|
+
const [resetKey, setResetKey] = useState(0);
|
|
229
|
+
const handleReset = useCallback(() => setResetKey(k => k + 1), []);
|
|
230
|
+
useEffect(() => {
|
|
231
|
+
const intervalId = setInterval(() => {
|
|
232
|
+
var _scrubberRef$current;
|
|
233
|
+
setData(current => {
|
|
234
|
+
const last = current[current.length - 1];
|
|
235
|
+
return [...current.slice(1), generateNextValue(last)];
|
|
236
|
+
});
|
|
237
|
+
if (imperative) (_scrubberRef$current = scrubberRef.current) == null || _scrubberRef$current.pulse();
|
|
238
|
+
}, updateInterval);
|
|
239
|
+
return () => clearInterval(intervalId);
|
|
240
|
+
}, [imperative]);
|
|
241
|
+
const pointFunction = props => _extends({}, props, {
|
|
242
|
+
transitions: pointTransitions
|
|
243
|
+
});
|
|
244
|
+
const pointProps = points ? pointFunction : false;
|
|
245
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
246
|
+
gap: 2,
|
|
247
|
+
children: [/*#__PURE__*/_jsx(TransitionLineChart, {
|
|
248
|
+
animate: animate,
|
|
249
|
+
data: data,
|
|
250
|
+
idlePulse: idlePulse,
|
|
251
|
+
points: pointProps,
|
|
252
|
+
scrubberRef: imperative ? scrubberRef : undefined,
|
|
253
|
+
scrubberTransitions: scrubberTransitions,
|
|
254
|
+
transitions: transitions
|
|
255
|
+
}, resetKey), resettable && /*#__PURE__*/_jsx(Box, {
|
|
256
|
+
paddingX: 2,
|
|
257
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
258
|
+
compact: true,
|
|
259
|
+
onPress: handleReset,
|
|
260
|
+
variant: "secondary",
|
|
261
|
+
children: "Reset"
|
|
262
|
+
})
|
|
263
|
+
})]
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
function AreaExample(_ref5) {
|
|
267
|
+
let {
|
|
268
|
+
transitions,
|
|
269
|
+
idlePulse,
|
|
270
|
+
resettable = true,
|
|
271
|
+
imperative = false
|
|
272
|
+
} = _ref5;
|
|
273
|
+
const scrubberRef = useRef(null);
|
|
274
|
+
const [data, setData] = useState(generateInitialData);
|
|
275
|
+
const [resetKey, setResetKey] = useState(0);
|
|
276
|
+
const handleReset = useCallback(() => setResetKey(k => k + 1), []);
|
|
277
|
+
useEffect(() => {
|
|
278
|
+
const intervalId = setInterval(() => {
|
|
279
|
+
var _scrubberRef$current2;
|
|
280
|
+
setData(current => {
|
|
281
|
+
const last = current[current.length - 1];
|
|
282
|
+
return [...current.slice(1), generateNextValue(last)];
|
|
283
|
+
});
|
|
284
|
+
if (imperative) (_scrubberRef$current2 = scrubberRef.current) == null || _scrubberRef$current2.pulse();
|
|
285
|
+
}, updateInterval);
|
|
286
|
+
return () => clearInterval(intervalId);
|
|
287
|
+
}, [imperative]);
|
|
288
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
289
|
+
gap: 2,
|
|
290
|
+
children: [/*#__PURE__*/_jsx(TransitionAreaChart, {
|
|
291
|
+
data: data,
|
|
292
|
+
idlePulse: idlePulse,
|
|
293
|
+
scrubberRef: imperative ? scrubberRef : undefined,
|
|
294
|
+
transitions: transitions
|
|
295
|
+
}, resetKey), resettable && /*#__PURE__*/_jsx(Box, {
|
|
296
|
+
paddingX: 2,
|
|
297
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
298
|
+
compact: true,
|
|
299
|
+
onPress: handleReset,
|
|
300
|
+
variant: "secondary",
|
|
301
|
+
children: "Reset"
|
|
302
|
+
})
|
|
303
|
+
})]
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// --- Bar Chart Components ---
|
|
308
|
+
|
|
309
|
+
const barCategories = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
|
310
|
+
function generateBarData() {
|
|
311
|
+
return barCategories.map(() => Math.round(Math.random() * 80 + 10));
|
|
312
|
+
}
|
|
313
|
+
const barChartProps = {
|
|
314
|
+
showXAxis: true,
|
|
315
|
+
enableScrubbing: true,
|
|
316
|
+
height: 200,
|
|
317
|
+
xAxis: {
|
|
318
|
+
data: barCategories
|
|
319
|
+
},
|
|
320
|
+
yAxis: {
|
|
321
|
+
domain: {
|
|
322
|
+
min: 0,
|
|
323
|
+
max: 100
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
const TransitionBarChart = /*#__PURE__*/memo(_ref6 => {
|
|
328
|
+
let {
|
|
329
|
+
data,
|
|
330
|
+
transitions
|
|
331
|
+
} = _ref6;
|
|
332
|
+
return /*#__PURE__*/_jsx(BarChart, _extends({}, barChartProps, {
|
|
333
|
+
series: [{
|
|
334
|
+
id: 'values',
|
|
335
|
+
data
|
|
336
|
+
}],
|
|
337
|
+
transitions: transitions,
|
|
338
|
+
children: /*#__PURE__*/_jsx(Scrubber, {
|
|
339
|
+
hideOverlay: true,
|
|
340
|
+
seriesIds: [],
|
|
341
|
+
transitions: transitions
|
|
342
|
+
})
|
|
343
|
+
}));
|
|
344
|
+
});
|
|
345
|
+
function BarExample(_ref7) {
|
|
346
|
+
let {
|
|
347
|
+
transitions,
|
|
348
|
+
resettable = true
|
|
349
|
+
} = _ref7;
|
|
350
|
+
const [data, setData] = useState(generateBarData);
|
|
351
|
+
const [resetKey, setResetKey] = useState(0);
|
|
352
|
+
const handleReset = useCallback(() => setResetKey(k => k + 1), []);
|
|
353
|
+
useEffect(() => {
|
|
354
|
+
const intervalId = setInterval(() => {
|
|
355
|
+
setData(generateBarData());
|
|
356
|
+
}, updateInterval);
|
|
357
|
+
return () => clearInterval(intervalId);
|
|
358
|
+
}, []);
|
|
359
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
360
|
+
gap: 2,
|
|
361
|
+
children: [/*#__PURE__*/_jsx(TransitionBarChart, {
|
|
362
|
+
data: data,
|
|
363
|
+
transitions: transitions
|
|
364
|
+
}, resetKey), resettable && /*#__PURE__*/_jsx(Box, {
|
|
365
|
+
paddingX: 2,
|
|
366
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
367
|
+
compact: true,
|
|
368
|
+
onPress: handleReset,
|
|
369
|
+
variant: "secondary",
|
|
370
|
+
children: "Reset"
|
|
371
|
+
})
|
|
372
|
+
})]
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
function RapidLineExample(_ref8) {
|
|
376
|
+
let {
|
|
377
|
+
transitions
|
|
378
|
+
} = _ref8;
|
|
379
|
+
const [data, setData] = useState(generateInitialData);
|
|
380
|
+
const [resetKey, setResetKey] = useState(0);
|
|
381
|
+
const handleReset = useCallback(() => setResetKey(k => k + 1), []);
|
|
382
|
+
useEffect(() => {
|
|
383
|
+
const intervalId = setInterval(() => {
|
|
384
|
+
setData(current => {
|
|
385
|
+
const last = current[current.length - 1];
|
|
386
|
+
return [...current.slice(1), generateNextValue(last)];
|
|
387
|
+
});
|
|
388
|
+
}, rapidUpdateInterval);
|
|
389
|
+
return () => clearInterval(intervalId);
|
|
390
|
+
}, []);
|
|
391
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
392
|
+
gap: 2,
|
|
393
|
+
children: [/*#__PURE__*/_jsx(TransitionLineChart, {
|
|
394
|
+
data: data,
|
|
395
|
+
transitions: transitions
|
|
396
|
+
}, resetKey), /*#__PURE__*/_jsx(Box, {
|
|
397
|
+
paddingX: 2,
|
|
398
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
399
|
+
compact: true,
|
|
400
|
+
onPress: handleReset,
|
|
401
|
+
variant: "secondary",
|
|
402
|
+
children: "Reset"
|
|
403
|
+
})
|
|
404
|
+
})]
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
function RapidBarExample(_ref9) {
|
|
408
|
+
let {
|
|
409
|
+
transitions
|
|
410
|
+
} = _ref9;
|
|
411
|
+
const [data, setData] = useState(generateBarData);
|
|
412
|
+
const [resetKey, setResetKey] = useState(0);
|
|
413
|
+
const handleReset = useCallback(() => setResetKey(k => k + 1), []);
|
|
414
|
+
useEffect(() => {
|
|
415
|
+
const intervalId = setInterval(() => {
|
|
416
|
+
setData(generateBarData());
|
|
417
|
+
}, rapidUpdateInterval);
|
|
418
|
+
return () => clearInterval(intervalId);
|
|
419
|
+
}, []);
|
|
420
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
421
|
+
gap: 2,
|
|
422
|
+
children: [/*#__PURE__*/_jsx(TransitionBarChart, {
|
|
423
|
+
data: data,
|
|
424
|
+
transitions: transitions
|
|
425
|
+
}, resetKey), /*#__PURE__*/_jsx(Box, {
|
|
426
|
+
paddingX: 2,
|
|
427
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
428
|
+
compact: true,
|
|
429
|
+
onPress: handleReset,
|
|
430
|
+
variant: "secondary",
|
|
431
|
+
children: "Reset"
|
|
432
|
+
})
|
|
433
|
+
})]
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
function MultiLineExample(_ref0) {
|
|
437
|
+
let {
|
|
438
|
+
transitions
|
|
439
|
+
} = _ref0;
|
|
440
|
+
const [data1, setData1] = useState(generateInitialData);
|
|
441
|
+
const [data2, setData2] = useState(generateInitialData);
|
|
442
|
+
const [resetKey, setResetKey] = useState(0);
|
|
443
|
+
const handleReset = useCallback(() => setResetKey(k => k + 1), []);
|
|
444
|
+
useEffect(() => {
|
|
445
|
+
const intervalId = setInterval(() => {
|
|
446
|
+
setData1(current => {
|
|
447
|
+
const last = current[current.length - 1];
|
|
448
|
+
return [...current.slice(1), generateNextValue(last)];
|
|
449
|
+
});
|
|
450
|
+
setData2(current => {
|
|
451
|
+
const last = current[current.length - 1];
|
|
452
|
+
return [...current.slice(1), generateNextValue(last)];
|
|
453
|
+
});
|
|
454
|
+
}, updateInterval);
|
|
455
|
+
return () => clearInterval(intervalId);
|
|
456
|
+
}, []);
|
|
457
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
458
|
+
gap: 2,
|
|
459
|
+
children: [/*#__PURE__*/_jsx(MultiLineChart, {
|
|
460
|
+
data1: data1,
|
|
461
|
+
data2: data2,
|
|
462
|
+
transitions: transitions
|
|
463
|
+
}, resetKey), /*#__PURE__*/_jsx(Box, {
|
|
464
|
+
paddingX: 2,
|
|
465
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
466
|
+
compact: true,
|
|
467
|
+
onPress: handleReset,
|
|
468
|
+
variant: "secondary",
|
|
469
|
+
children: "Reset"
|
|
470
|
+
})
|
|
471
|
+
})]
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// --- Main Navigator ---
|
|
476
|
+
|
|
477
|
+
function ExampleNavigator() {
|
|
478
|
+
const [currentIndex, setCurrentIndex] = useState(0);
|
|
479
|
+
const examples = useMemo(() => [{
|
|
480
|
+
category: 'Line',
|
|
481
|
+
title: 'Enter Only',
|
|
482
|
+
component: /*#__PURE__*/_jsx(LineExample, {
|
|
483
|
+
idlePulse: true,
|
|
484
|
+
transitions: enterOnly
|
|
485
|
+
})
|
|
486
|
+
}, {
|
|
487
|
+
category: 'Line',
|
|
488
|
+
title: 'Update Only',
|
|
489
|
+
component: /*#__PURE__*/_jsx(LineExample, {
|
|
490
|
+
idlePulse: true,
|
|
491
|
+
points: true,
|
|
492
|
+
pointTransitions: updateOnly,
|
|
493
|
+
transitions: updateOnly
|
|
494
|
+
})
|
|
495
|
+
}, {
|
|
496
|
+
category: 'Line',
|
|
497
|
+
title: 'Both Disabled',
|
|
498
|
+
component: /*#__PURE__*/_jsx(LineExample, {
|
|
499
|
+
transitions: bothDisabled
|
|
500
|
+
})
|
|
501
|
+
}, {
|
|
502
|
+
category: 'Line',
|
|
503
|
+
title: 'Custom 2',
|
|
504
|
+
component: /*#__PURE__*/_jsx(LineExample, {
|
|
505
|
+
points: true,
|
|
506
|
+
pointTransitions: customEnterUpdateBeacon,
|
|
507
|
+
scrubberTransitions: customEnterUpdateBeacon,
|
|
508
|
+
transitions: customEnterUpdate
|
|
509
|
+
})
|
|
510
|
+
}, {
|
|
511
|
+
category: 'Line',
|
|
512
|
+
title: 'Imperative Pulse',
|
|
513
|
+
component: /*#__PURE__*/_jsx(LineExample, {
|
|
514
|
+
imperative: true,
|
|
515
|
+
resettable: false,
|
|
516
|
+
transitions: updateOnly
|
|
517
|
+
})
|
|
518
|
+
}, {
|
|
519
|
+
category: 'Multi-Line',
|
|
520
|
+
title: 'Update Only',
|
|
521
|
+
component: /*#__PURE__*/_jsx(MultiLineExample, {
|
|
522
|
+
transitions: updateOnly
|
|
523
|
+
})
|
|
524
|
+
}, {
|
|
525
|
+
category: 'Area',
|
|
526
|
+
title: 'Both Disabled',
|
|
527
|
+
component: /*#__PURE__*/_jsx(AreaExample, {
|
|
528
|
+
transitions: bothDisabled
|
|
529
|
+
})
|
|
530
|
+
}, {
|
|
531
|
+
category: 'Area',
|
|
532
|
+
title: 'Imperative Pulse',
|
|
533
|
+
component: /*#__PURE__*/_jsx(AreaExample, {
|
|
534
|
+
imperative: true,
|
|
535
|
+
resettable: false,
|
|
536
|
+
transitions: updateOnly
|
|
537
|
+
})
|
|
538
|
+
}, {
|
|
539
|
+
category: 'Bar',
|
|
540
|
+
title: 'Enter Only',
|
|
541
|
+
component: /*#__PURE__*/_jsx(BarExample, {
|
|
542
|
+
transitions: enterOnly
|
|
543
|
+
})
|
|
544
|
+
}, {
|
|
545
|
+
category: 'Bar',
|
|
546
|
+
title: 'Update Only',
|
|
547
|
+
component: /*#__PURE__*/_jsx(BarExample, {
|
|
548
|
+
transitions: updateOnly
|
|
549
|
+
})
|
|
550
|
+
}, {
|
|
551
|
+
category: 'Bar',
|
|
552
|
+
title: 'Both Disabled',
|
|
553
|
+
component: /*#__PURE__*/_jsx(BarExample, {
|
|
554
|
+
transitions: bothDisabled
|
|
555
|
+
})
|
|
556
|
+
}, {
|
|
557
|
+
category: 'Bar',
|
|
558
|
+
title: 'Slow Spring Both',
|
|
559
|
+
component: /*#__PURE__*/_jsx(BarExample, {
|
|
560
|
+
transitions: slowSpringBoth
|
|
561
|
+
})
|
|
562
|
+
}, {
|
|
563
|
+
category: 'Bar',
|
|
564
|
+
title: 'Staggered Both',
|
|
565
|
+
component: /*#__PURE__*/_jsx(BarExample, {
|
|
566
|
+
transitions: staggeredBoth
|
|
567
|
+
})
|
|
568
|
+
}, {
|
|
569
|
+
category: 'Line',
|
|
570
|
+
title: 'Rapid Interrupts',
|
|
571
|
+
component: /*#__PURE__*/_jsx(RapidLineExample, {
|
|
572
|
+
transitions: slowTimingBoth
|
|
573
|
+
})
|
|
574
|
+
}, {
|
|
575
|
+
category: 'Bar',
|
|
576
|
+
title: 'Rapid Interrupts',
|
|
577
|
+
component: /*#__PURE__*/_jsx(RapidBarExample, {
|
|
578
|
+
transitions: slowTimingBoth
|
|
579
|
+
})
|
|
580
|
+
}], []);
|
|
581
|
+
const currentExample = examples[currentIndex];
|
|
582
|
+
const handlePrevious = useCallback(() => {
|
|
583
|
+
setCurrentIndex(prev => (prev - 1 + examples.length) % examples.length);
|
|
584
|
+
}, [examples.length]);
|
|
585
|
+
const handleNext = useCallback(() => {
|
|
586
|
+
setCurrentIndex(prev => (prev + 1) % examples.length);
|
|
587
|
+
}, [examples.length]);
|
|
588
|
+
return /*#__PURE__*/_jsx(ExampleScreen, {
|
|
589
|
+
paddingX: 0,
|
|
590
|
+
children: /*#__PURE__*/_jsxs(VStack, {
|
|
591
|
+
gap: 4,
|
|
592
|
+
children: [/*#__PURE__*/_jsxs(HStack, {
|
|
593
|
+
alignItems: "center",
|
|
594
|
+
justifyContent: "space-between",
|
|
595
|
+
paddingX: 1,
|
|
596
|
+
children: [/*#__PURE__*/_jsx(IconButton, {
|
|
597
|
+
accessibilityHint: "Navigate to previous example",
|
|
598
|
+
accessibilityLabel: "Previous",
|
|
599
|
+
name: "arrowLeft",
|
|
600
|
+
onPress: handlePrevious,
|
|
601
|
+
variant: "secondary"
|
|
602
|
+
}), /*#__PURE__*/_jsxs(VStack, {
|
|
603
|
+
alignItems: "center",
|
|
604
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
605
|
+
color: "fgMuted",
|
|
606
|
+
font: "label2",
|
|
607
|
+
children: currentExample.category
|
|
608
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
609
|
+
font: "title3",
|
|
610
|
+
children: currentExample.title
|
|
611
|
+
}), /*#__PURE__*/_jsxs(Text, {
|
|
612
|
+
color: "fgMuted",
|
|
613
|
+
font: "label1",
|
|
614
|
+
children: [currentIndex + 1, " / ", examples.length]
|
|
615
|
+
})]
|
|
616
|
+
}), /*#__PURE__*/_jsx(IconButton, {
|
|
617
|
+
accessibilityHint: "Navigate to next example",
|
|
618
|
+
accessibilityLabel: "Next",
|
|
619
|
+
name: "arrowRight",
|
|
620
|
+
onPress: handleNext,
|
|
621
|
+
variant: "secondary"
|
|
622
|
+
})]
|
|
623
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
624
|
+
children: currentExample.component
|
|
625
|
+
}, currentIndex)]
|
|
626
|
+
})
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
export default ExampleNavigator;
|
package/esm/chart/area/Area.js
CHANGED
|
@@ -16,6 +16,7 @@ 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;
|
|
@@ -70,6 +71,7 @@ export const Area = /*#__PURE__*/memo(_ref => {
|
|
|
70
71
|
fillOpacity: fillOpacity,
|
|
71
72
|
gradient: gradient,
|
|
72
73
|
transition: transition,
|
|
74
|
+
transitions: transitions,
|
|
73
75
|
yAxisId: matchedSeries == null ? void 0 : matchedSeries.yAxisId
|
|
74
76
|
});
|
|
75
77
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["d", "fill", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "animate", "transition"];
|
|
1
|
+
const _excluded = ["d", "fill", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "animate", "transitions", "transition"];
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
4
|
import { memo, useMemo } from 'react';
|
|
@@ -28,6 +28,7 @@ export const DottedArea = /*#__PURE__*/memo(_ref => {
|
|
|
28
28
|
yAxisId,
|
|
29
29
|
gradient: gradientProp,
|
|
30
30
|
animate: animateProp,
|
|
31
|
+
transitions,
|
|
31
32
|
transition
|
|
32
33
|
} = _ref,
|
|
33
34
|
pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
@@ -50,7 +51,9 @@ export const DottedArea = /*#__PURE__*/memo(_ref => {
|
|
|
50
51
|
}, [drawingArea, patternSize, dotSize]);
|
|
51
52
|
const animatedClipPath = usePathTransition({
|
|
52
53
|
currentPath: d,
|
|
53
|
-
|
|
54
|
+
transitions: {
|
|
55
|
+
update: transition
|
|
56
|
+
}
|
|
54
57
|
});
|
|
55
58
|
const staticClipPath = useMemo(() => {
|
|
56
59
|
var _Skia$Path$MakeFromSV;
|
|
@@ -69,7 +72,8 @@ export const DottedArea = /*#__PURE__*/memo(_ref => {
|
|
|
69
72
|
animate: animateProp != null ? animateProp : animate,
|
|
70
73
|
d: dottedPath,
|
|
71
74
|
fill: fill,
|
|
72
|
-
transition: transition
|
|
75
|
+
transition: transition,
|
|
76
|
+
transitions: transitions
|
|
73
77
|
}, pathProps, {
|
|
74
78
|
children: gradient && /*#__PURE__*/_jsx(Gradient, {
|
|
75
79
|
gradient: gradient,
|
|
@@ -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", "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';
|
|
@@ -24,6 +24,7 @@ export const GradientArea = /*#__PURE__*/memo(_ref => {
|
|
|
24
24
|
baseline,
|
|
25
25
|
yAxisId,
|
|
26
26
|
animate,
|
|
27
|
+
transitions,
|
|
27
28
|
transition
|
|
28
29
|
} = _ref,
|
|
29
30
|
pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
@@ -44,7 +45,8 @@ export const GradientArea = /*#__PURE__*/memo(_ref => {
|
|
|
44
45
|
d: d,
|
|
45
46
|
fill: fill,
|
|
46
47
|
fillOpacity: fillOpacity,
|
|
47
|
-
transition: transition
|
|
48
|
+
transition: transition,
|
|
49
|
+
transitions: transitions
|
|
48
50
|
}, pathProps, {
|
|
49
51
|
children: gradient && /*#__PURE__*/_jsx(Gradient, {
|
|
50
52
|
gradient: gradient,
|