File tree 1 file changed +31
-8
lines changed
1 file changed +31
-8
lines changed Original file line number Diff line number Diff line change 6
6
</ head >
7
7
< body >
8
8
< script src ="echarts.min.js "> </ script >
9
+ < script src ="jquery.min.js "> </ script >
9
10
< div id ="main " style ="width: 100%;height:500px; "> </ div >
10
11
11
12
< script >
12
13
var myChart = echarts . init ( document . getElementById ( 'main' ) ) ;
13
14
14
- var date = [ ] ;
15
+ var time_date = [ ] ;
15
16
var randomData = [ ] ;
16
17
17
18
for ( var i = 0 ; i < 30 ; i ++ ) {
18
- date . push ( '第' + ( i + 1 ) + '天' ) ;
19
+ d = new Date ( ) ;
20
+ time_date . push ( d . getMinutes ( ) ) ;
19
21
randomData . push ( Math . floor ( Math . random ( ) * 10 ) ) ;
20
22
}
21
23
22
24
// 指定图表的配置项和数据
23
25
var option = {
24
26
xAxis : {
25
27
type : 'category' ,
26
- data : date
28
+ data : time_date
27
29
} ,
28
30
yAxis : {
29
31
type : 'value'
37
39
// 使用刚指定的配置项和数据显示图表。
38
40
myChart . setOption ( option ) ;
39
41
40
- var len = date . length ;
42
+ var len = time_date . length ;
41
43
42
44
setInterval ( function ( ) {
45
+ $ . ajax ( {
46
+ type : "GET" ,
47
+ url : "https://pk10tv.com/pks/getPksHistoryList.do?date=2020-3-18&lotCode=xyft" ,
48
+ dataType : "json" ,
49
+ success : function ( data ) {
50
+ new_data = data [ 'result' ] [ 'data' ] ;
51
+ // console.log(new_data);
52
+
53
+ time_date . push ( new_data [ new_data . length - 1 ] [ 'preDrawCode' ] ) ;
54
+ console . log ( new_data [ new_data . length - 1 ] [ 'preDrawCode' ] ) ;
55
+ // for (var i = 0; i <new_data.length ; i++) {
56
+ // time_date.push(new_data[i]);
57
+ // console.log(new_data[i]['preDrawCode'])
58
+ // }
59
+
60
+ } ,
61
+ error : function ( error ) {
62
+ // time_date.push(1);
63
+ console . log ( error )
64
+ }
65
+ } ) ;
43
66
randomData . push ( Math . floor ( Math . random ( ) * 10 ) ) ;
44
67
randomData . shift ( ) ;
45
- date . push ( len ++ ) ;
46
- date . shift ( ) ;
68
+ time_date . push ( len ++ ) ;
69
+ time_date . shift ( ) ;
47
70
myChart . setOption ( {
48
71
xAxis : {
49
- data : date
72
+ data : time_date
50
73
} ,
51
74
series : [ {
52
75
data : randomData
53
76
} ]
54
77
} ) ;
55
- } , 2000 )
78
+ } , 5000 )
56
79
</ script >
57
80
58
81
You can’t perform that action at this time.
0 commit comments