Skip to content

Commit d71f8f0

Browse files
committed
docs(demo): 修改面积图 demo
1 parent 3b8f408 commit d71f8f0

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

examples/area/basic/demo/basic.ts

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
import { Area } from '@antv/g2plot';
22

3-
fetch('https://gw.alipayobjects.com/os/bmw-prod/1d565782-dde4-4bb6-8946-ea6a38ccf184.json')
3+
fetch('https://gw.alipayobjects.com/os/bmw-prod/360c3eae-0c73-46f0-a982-4746a6095010.json')
44
.then((res) => res.json())
5-
.then((data) => {
5+
.then((originalData) => {
6+
let cnt = 2;
67
const area = new Area('container', {
7-
data,
8-
xField: 'Date',
9-
yField: 'scales',
8+
data: originalData.slice(0, cnt),
9+
xField: 'timePeriod',
10+
yField: 'value',
1011
xAxis: {
11-
type: 'timeCat',
1212
range: [0, 1],
13-
tickCount: 5,
1413
},
15-
smooth: true,
1614
});
1715
area.render();
1816

19-
let year = 2017;
20-
let month = 2;
2117
const interval = setInterval(() => {
22-
if (year > 2100) {
18+
if (cnt === originalData.length) {
2319
clearInterval(interval);
20+
} else {
21+
cnt += 1;
22+
area.changeData(originalData.slice(0, cnt));
2423
}
25-
month = (month + 1) % 12;
26-
year += Math.ceil(month / 12);
27-
area.changeData([...area.options.data, { Date: `${year}-${month}`, scales: 1300 * Math.random() + 500 }]);
28-
}, 500);
24+
}, 400);
2925
});

0 commit comments

Comments
 (0)