-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQubesCounter.html
130 lines (111 loc) · 3.1 KB
/
QubesCounter.html
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html>
<head>
<title>Estimated number of Qubes Users</title>
<!-- amCharts javascript sources -->
<script src="http://cdn.amcharts.com/lib/3/amcharts.js" type="text/javascript"></script>
<script src="http://cdn.amcharts.com/lib/3/serial.js" type="text/javascript"></script>
<script src="http://cdn.amcharts.com/lib/3/themes/light.js" type="text/javascript"></script>
<!-- amCharts javascript code -->
<script type="text/javascript">
function loadCSV(file) {
if (window.XMLHttpRequest) {
// IE7+, Firefox, Chrome, Opera, Safari
var request = new XMLHttpRequest();
}
else {
// code for IE6, IE5
var request = new ActiveXObject('Microsoft.XMLHTTP');
}
// anti browser cache
var date = new Date();
var file_nocache = file + "?" + date.getTime();
// load
request.open('GET', file_nocache, false);
request.send();
// page specific function called:
return parseCSV(request.responseText);
};
var ChartData = [];
function parseCSV(data){
//replace UNIX new lines
data = data.replace (/\r\n/g, "\n");
//replace MAC new lines
data = data.replace (/\r/g, "\n");
//split into rows
var rows = data.split("\n");
// loop through all rows
for (var i = 0; i < rows.length; i++) {
// this line helps to skip empty rows
if (rows[i]) {
// our columns are separated by comma
var column = rows[i].split(",");
// column is array now
// first item is date
var date = column[0];
// second item is value of the second column
var value = column[1];
// create object which contains all these items:
var dataObject = {
date: date,
value: value
};
// add object to chartData array
ChartData.push(dataObject);
}
}
}
loadCSV("http://" + window.location.hostname + "/QubesCounter.csv");
AmCharts.makeChart("chartdiv",
{
"type": "serial",
"pathToImages": "http://cdn.amcharts.com/lib/3/images/",
"balloonDateFormat": "MM, YYYY",
"categoryField": "date",
"dataDateFormat": "",
"startDuration": 1,
"handDrawn": true,
"theme": "light",
"categoryAxis": {
"gridPosition": "start",
"minPeriod": "MM",
"title": ""
},
"trendLines": [],
"graphs": [
{
"fillAlphas": 1,
"id": "AmGraph-1",
"title": "graph 1",
"type": "column",
"valueField": "value"
}
],
"guides": [],
"valueAxes": [
{
"id": "ValueAxis",
"minVerticalGap": 34,
"title": ""
}
],
"allLabels": [],
"balloon": {
"offsetY": 0
},
"titles": [
{
"id": "Title-1",
"size": 15,
"text": "Estimated number of Qubes Users"
}
],
"dataProvider": ChartData
}
);
</script>
</head>
<body>
<div id="chartdiv" style="width: 100%; height: 400px; background-color: #FFFFFF;" ></div>
</body>
</html>