-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
73 lines (60 loc) · 2.34 KB
/
index.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
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<script>
function getParameterByName(name, url) {
if (!url) {
url = window.location.href;
}
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
</script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script id="dataloader" type="text/javascript">
google.charts.load("current", {packages:["corechart"]});
google.charts.setOnLoadCallback(drawChart);
var sId = getParameterByName('sId');
var sName = getParameterByName('sName');
var qStr = getParameterByName('qStr');
var width = getParameterByName('width');
var height = getParameterByName('height');
var colors = JSON.parse(getParameterByName('colors'));
function drawChart() {
var query = new google.visualization.Query('https://docs.google.com/spreadsheets/d/' + sId + '/gviz/tq?sheet=' + sName + '&headers=1&tq=' + qStr);
query.send(handleSampleDataQueryResponse);
}
setInterval(drawChart, 3000);
function handleSampleDataQueryResponse(response) {
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}
var data = response.getDataTable();
console.log(data);
var options = {
width: width,
height: height,
pieHole: 0.5,
chartArea:{left:0,top:0,width:'100%',height:'100%'},
pieSliceText: 'value',
fontSize: 12,
colors: colors,
legend: {position: 'labeled'}
};
var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="donutchart"></div>
</body>
</html>