forked from user2589/Toggl.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.html
More file actions
167 lines (146 loc) · 5.06 KB
/
template.html
File metadata and controls
167 lines (146 loc) · 5.06 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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Time logger report</title>
<style>
body {
background-color:white;
}
#header {
font-size:3em;
margin-bottom:30px;
}
#timestamp {
font-size:small;
}
#container {
max-width: 1600px;
min-width: 1300px;
}
.course {
margin: 1em 0;
}
.header {
font-size:2em;
margin-top:3em;
}
.chart {}
.table {}
</style>
</head>
<body>
<div id='header'>
Time logger report
<div id='timestamp'></div>
</div>
<div id="container">
</div>
<script src="https://www.google.com/jsapi"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
/* End comment at this line to debug template
// You can account for the following variables in this code:
var week_labels = ["May 25", "Jun 01", "Jun 08", "Jun 15", "Jun 22", "Jun 29", "Jul 06", "Jul 13", "Jul 27"];
var report_data = {
"Project Sunshine": {
"Team Alpha": [5.56, 13.65, 11.62, 10.08, 22.84, 26.76, null, null, null],
"Team Bravo": [22.01, 22.72, 21.77, 22.23, 15.3, 15.64, null, null, null],
"Team Charlie": [8.75, 20.7, 19.77, 15.8, 18.75, 14.84, null, null, null]
},
"Project Smiley": {
"Team Alpha": [5.21, 19.08, 22.65, 27.61, 12.44, 18.63, null, null, null],
"Team Bravo": [0.0, 2.95, 7.69, 11.23, 6.79, 4.93, null, null, null],
"Team Charlie": [11.17, 16.56, 16.64, 23.34, 11.25, 16.34, null, null, null]
}
};
var teams = ["Team Alpha", "Team Charlie", "Team Bravo"];
var courses = ["Project Sunshine", "electives"];
var timestamp = "Jun 09 2015 12:34PM";
var variance = {
"Project Sunshine": {
"Team Alpha": 4.1,
"Team Bravo": 8.79,
"Team Charlie": 63.64,
},
"Project Smiley": {
"Team Alpha": 13.94,
"Team Bravo": 22.93,
"Team Charlie": 6.7,
}
};
var average = {
"Project Sunshine": {
"Team Alpha": 18.0,
"Team Bravo": 19.0,
"Team Charlie": 17.88,
},
"Project Smiley": {
"Team Alpha": 17.37,
"Team Bravo": 6.1,
"Team Charlie": 21.61
}
};
/* */
google.load("visualization", "1", {packages:["table", "corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
// update timestamp
$("#timestamp").text("Last generated "+timestamp);
week_labels.push('Avg');
courses.forEach(function(course, index){
// get teams who have this course
// for all weeks, for a given team,
$('#container').append(
"<div class='"+index+"' id='"+course+"-container'>" +
"<div class='header' id='"+course+"-header'>" + course + "</div>" +
"<div class='chart' id='"+course+"-chart'>" + "</div>" +
"<div class='table' id='"+course+"-table'>" + "</div>" +
"</div>");
// Tables
var data = new google.visualization.DataTable();
data.addColumn('string', 'Team');
week_labels.forEach(function(week){
data.addColumn('number', week);
});
data.addColumn('number', 'Std');
teams.forEach(function(team) {
if (report_data[course].hasOwnProperty(team)) {
report_data[course][team].push(average[course][team]);
var row = [team];
var std = Math.round(Math.sqrt(variance[course][team]) * 100) / 100;
data.addRow(row.concat(report_data[course][team]).concat([std]));
}
});
var table = new google.visualization.Table(document.getElementById(course+'-table'));
table.draw(data, {showRowNumber: false});
// Charts
data = new google.visualization.DataTable();
data.addColumn('string', 'Week');
teams.forEach(function(team) {
if (report_data[course].hasOwnProperty(team)) {
data.addColumn('number', team);
}
});
for (var i=0; i< week_labels.length; i++) {
week = week_labels[i];
var row = [week];
teams.forEach(function(team) {
if (report_data[course].hasOwnProperty(team)) {
row.push(report_data[course][team][i]);
}
});
data.addRow(row);
}
var options = {
chartArea: {left:'5%',top:'5%',width:'75%',height:'85%'},
vAxis: {baseline: 0},
pointShape: 'square',
pointSize: 15,
width: 1100,
height: 430
};
var chart = new google.visualization.LineChart(document.getElementById(course+'-chart'));
chart.draw(data, options);
});
}
</script>