member.js
1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
var chart;
$(document).ready(function() {
//需要获取的数据
//
// function getBefore7TainArr() {
// var nowDate = new Date(); //获取今天日期
// nowDate.setDate(nowDate.getDate() - 7);
// var dateArray = ['x'];
// var flag = 1;
// for (var i = 0; i < 7; i++) {
// dateTemp = (nowDate.getMonth() + 1) + "." + nowDate.getDate();
// dateArray.push(dateTemp);
// nowDate.setDate(nowDate.getDate() + flag);
// }
// return dateArray;
// }
//
//
//
if(!xserials&&(xserials.length<1||xserials[0]=="")){
return;
}
if(!yserials&&yserials.length<1||yserials[0]==""){
return;
}
for(var i=0;i<xserials.length;i++){
var xserial=xserials[i];
xserials[i]=xserial.substring(0,4)+"-"+xserial.substring(4,6)+"-"+xserial.substring(6,8);
}
var maxDate=new Date(xserials[xserials.length-1]);
maxDate.setHours(maxDate.getHours() + 12);
xserials.splice(0, 0, 'x');
ymax = (Math.ceil(d3.max(yserials) / 100) + 1) * 100;
ymin = (Math.floor(d3.min(yserials) / 100) - 1) * 100;
if(ymin<0){
ymin=0;
}
yserials.splice(0, 0, 'y');
chart = c3.generate({
bindto: "#shouyicurve",
data: {
x: "x",
columns: [
xserials, yserials
]
},
grid: {
y: {
show: true
}
},
legend: {
show: false,
},
axis: {
x: {
type : 'timeseries',
tick:{
format: function (x) { return x.getMonth()+1+"."+x.getDate(); }
}
},
y: {
max: ymax,
min: ymin,
tick: {
values: d3.range(ymin, ymax + 100, (ymax - ymin) / 4)
}
}
}
});
})
window.onbeforeunload = function() {
if(chart){
chart.unload({
ids: ['x', 'y']
});
}
}