stats.js
1.9 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
$(document)
.ready(
function() {
var options = {
chart : {
renderTo : 'hccontainer',
type : 'spline'
},
title : {
text : 'Snow depth at Vikjafjellet, Norway'
},
subtitle : {
text : 'Irregular time data in Highcharts JS'
},
xAxis : {
type : 'datetime',
},
yAxis : [ {
title : {
text : 'Snow depth (m)'
},
min : 0
}, {
} ],
tooltip : {
formatter : function() {
console.log(this.x);
return '<b>'
+ this.series.name
+ '</b><br/>'
+ Highcharts.dateFormat('%e. %b',
this.x) + ': ' + this.y + ' m';
}
},
series : [
{
name : 'Winter 2007-2008',
data : [ [ Date.UTC(2012, 9, 27), 0 ],
[ Date.UTC(2012, 10, 10), 0.6 ],
[ Date.UTC(2012, 10, 18), 0.7 ],
]
}, {
name : 'asd2',
data : [ {} ]
} ]
};
$.getJSON(
'#{request.contextPath}/rest/acc/boughtTimecount/27',
function(data) {
console.log(options.series);
console.log(data);
var series = data[0].series;
for (var serIdx = 0; serIdx < series.length; ++serIdx) {
var d = series[serIdx].data;
for (var i = 0; i < d.length; i++) {
if (d[i] instanceof Array) {
console
.log("Already array. not traversing");
} else {
series[serIdx].data[i] = d[i].item;
}
}
}
options.series = series;
console.log(options.series);
$("#hccontainer").highcharts(options);
}).done(function() {
console.log("second success");
}).fail(function() {
console.log("error");
}).always(function() {
console.log("complete");
});
});