File tree 1 file changed +11
-15
lines changed
1 file changed +11
-15
lines changed Original file line number Diff line number Diff line change 1
1
import { Area } from '@antv/g2plot' ;
2
2
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' )
4
4
. then ( ( res ) => res . json ( ) )
5
- . then ( ( data ) => {
5
+ . then ( ( originalData ) => {
6
+ let cnt = 2 ;
6
7
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 ' ,
10
11
xAxis : {
11
- type : 'timeCat' ,
12
12
range : [ 0 , 1 ] ,
13
- tickCount : 5 ,
14
13
} ,
15
- smooth : true ,
16
14
} ) ;
17
15
area . render ( ) ;
18
16
19
- let year = 2017 ;
20
- let month = 2 ;
21
17
const interval = setInterval ( ( ) => {
22
- if ( year > 2100 ) {
18
+ if ( cnt === originalData . length ) {
23
19
clearInterval ( interval ) ;
20
+ } else {
21
+ cnt += 1 ;
22
+ area . changeData ( originalData . slice ( 0 , cnt ) ) ;
24
23
}
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 ) ;
29
25
} ) ;
You can’t perform that action at this time.
0 commit comments