-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
169 lines (151 loc) · 13.8 KB
/
example.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
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
Google Viz Plus Example
</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="src/gvizPlus.js"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['corechart']});
</script>
<script type="text/javascript">
function drawVisualization() {
// If you have data for google with a common horizontal axis...
var hAxis = {type:'datetime', label:'Time'};
// And several different lines to plot...
var lineA = {type:'number', label:'Line A'};
var lineB = {type:'number', label:'Line B'};
var set1Rows = [
[new Date(1.395943214e+12),15,0],[new Date(1.395943215e+12),65,0],[new Date(1.395943216e+12),10,0],[new Date(1.395943218e+12),35,0],
[new Date(1.395943219e+12),35,0],[new Date(1.39594322e+12),40,0],[new Date(1.395943221e+12),30,0],[new Date(1.395943222e+12),35,0],
[new Date(1.395943223e+12),50,0],[new Date(1.395943224e+12),30,0],[new Date(1.395943225e+12),20,0],[new Date(1.395943226e+12),30,0],
[new Date(1.395943227e+12),5,0],[new Date(1.395943228e+12),15,0],[new Date(1.39594323e+12),20,0],[new Date(1.395943231e+12),0,0],
[new Date(1.395943232e+12),10,0],[new Date(1.395943233e+12),50,0],[new Date(1.395943234e+12),80,0],[new Date(1.395943235e+12),15,0],
[new Date(1.395943237e+12),55,0],[new Date(1.395943238e+12),0,0],[new Date(1.395943239e+12),35,0],[new Date(1.39594324e+12),10,0],
[new Date(1.395943244e+12),38,0],[new Date(1.395943245e+12),39,0],[new Date(1.395943246e+12),15,0],[new Date(1.395943247e+12),61,0],
[new Date(1.395943248e+12),37,0],[new Date(1.395943249e+12),28,0],[new Date(1.39594325e+12),36,0],[new Date(1.395943251e+12),35,0],
[new Date(1.395943252e+12),5,0],[new Date(1.395943253e+12),84,0],[new Date(1.395943254e+12),50,0],[new Date(1.395943255e+12),25,0],
[new Date(1.395943256e+12),18,0],[new Date(1.395943257e+12),29,0],[new Date(1.395943258e+12),33,0],[new Date(1.395943259e+12),23,0],
[new Date(1.39594326e+12),28,0],[new Date(1.395943261e+12),19,0],[new Date(1.395943262e+12),35,0],[new Date(1.395943263e+12),36,0],
[new Date(1.395943264e+12),58,0],[new Date(1.395943265e+12),35,0],[new Date(1.395943266e+12),41,0],[new Date(1.395943267e+12),73,0],
[new Date(1.395943268e+12),50,0],[new Date(1.395943269e+12),14,0],[new Date(1.39594327e+12),51,0],[new Date(1.395943271e+12),19,0],
[new Date(1.395943272e+12),41,0],[new Date(1.395943273e+12),49,0],[new Date(1.395943274e+12),66,0],[new Date(1.395943275e+12),49,0],
[new Date(1.395943276e+12),45,0],[new Date(1.395943277e+12),42,0],[new Date(1.395943278e+12),39,0],[new Date(1.395943279e+12),63,0],
[new Date(1.39594328e+12),42,0],[new Date(1.395943281e+12),31,0],[new Date(1.395943282e+12),13,0],[new Date(1.395943283e+12),48,0],
[new Date(1.395943284e+12),105,0],[new Date(1.395943285e+12),23,0],[new Date(1.395943286e+12),67,0],[new Date(1.395943287e+12),35,0],
[new Date(1.395943288e+12),66,0],[new Date(1.395943289e+12),54,0],[new Date(1.39594329e+12),27,0],[new Date(1.395943291e+12),55,0],
[new Date(1.395943292e+12),43,0],[new Date(1.395943293e+12),84,0],[new Date(1.395943294e+12),21,0],[new Date(1.395943295e+12),49,0],
[new Date(1.395943296e+12),79,0],[new Date(1.395943297e+12),38,0],[new Date(1.395943298e+12),101,0],[new Date(1.395943299e+12),54,0],
[new Date(1.3959433e+12),14,0],[new Date(1.395943301e+12),89,0],[new Date(1.395943302e+12),39,0],[new Date(1.395943303e+12),64,0],
[new Date(1.395943304e+12),39,0],[new Date(1.395943305e+12),55,0],[new Date(1.395943306e+12),67,0],[new Date(1.395943307e+12),85,0],
[new Date(1.395943308e+12),48,0],[new Date(1.395943309e+12),38,0],[new Date(1.39594331e+12),58,0],[new Date(1.395943311e+12),92,0],
[new Date(1.395943312e+12),31,0],[new Date(1.395943313e+12),53,0],[new Date(1.395943314e+12),95,0],[new Date(1.395943315e+12),31,0],
[new Date(1.395943316e+12),78,0],[new Date(1.395943317e+12),54,0],[new Date(1.395943318e+12),50,0],[new Date(1.395943319e+12),65,0],
[new Date(1.39594332e+12),83,0],[new Date(1.395943321e+12),45,0],[new Date(1.395943322e+12),65,0],[new Date(1.395943323e+12),46,0],
[new Date(1.395943324e+12),97,0],[new Date(1.395943325e+12),66,0],[new Date(1.395943326e+12),84,0],[new Date(1.395943327e+12),74,0],
[new Date(1.395943328e+12),104,0],[new Date(1.395943329e+12),43,0],[new Date(1.39594333e+12),87,0],[new Date(1.395943331e+12),55,0],
[new Date(1.395943332e+12),42,0],[new Date(1.395943333e+12),53,0],[new Date(1.395943334e+12),116,0],[new Date(1.395943335e+12),95,0],
[new Date(1.395943336e+12),50,0],[new Date(1.395943337e+12),94,0],[new Date(1.395943338e+12),78,0],[new Date(1.395943339e+12),75,0],
[new Date(1.39594334e+12),106,0],[new Date(1.395943341e+12),64,0],[new Date(1.395943342e+12),52,0]
];
// Even split up over different sets...
var lineC = {type:'number', label:'Line C'};
var lineD = {type:'number', label:'Line D'};
var lineE = {type:'number', label:'Line E'};
var set2Rows = [
[new Date(1.395943214e+12),0,0,0],[new Date(1.395943215e+12),0,0,0],[new Date(1.395943216e+12),0,0,0],[new Date(1.395943218e+12),0,0,0],
[new Date(1.395943219e+12),0,0,0],[new Date(1.39594322e+12),0,0,0],[new Date(1.395943221e+12),0,0,0],[new Date(1.395943222e+12),0,0,0],
[new Date(1.395943223e+12),0,0,0],[new Date(1.395943224e+12),0,0,0],[new Date(1.395943225e+12),0,0,0],[new Date(1.395943226e+12),0,0,0],
[new Date(1.395943227e+12),0,0,0],[new Date(1.395943228e+12),0,0,0],[new Date(1.39594323e+12),0,0,0],[new Date(1.395943231e+12),0,0,0],
[new Date(1.395943232e+12),0,0,0],[new Date(1.395943233e+12),0,0,0],[new Date(1.395943234e+12),0,0,0],[new Date(1.395943235e+12),0,0,0],
[new Date(1.395943237e+12),0,0,0],[new Date(1.395943238e+12),0,0,0],[new Date(1.395943239e+12),0,0,0],[new Date(1.39594324e+12),0,0,0],
[new Date(1.395943244e+12),0,0,0],[new Date(1.395943245e+12),0,0,0],[new Date(1.395943246e+12),0,0,0],[new Date(1.395943247e+12),0,0,0],
[new Date(1.395943248e+12),0,0,0],[new Date(1.395943249e+12),0,0,0],[new Date(1.39594325e+12),0,0,0],[new Date(1.395943251e+12),0,0,0],
[new Date(1.395943252e+12),0,0,0],[new Date(1.395943253e+12),0,0,0],[new Date(1.395943254e+12),0,0,0],[new Date(1.395943255e+12),0,0,0],
[new Date(1.395943256e+12),0,0,0],[new Date(1.395943257e+12),0,0,0],[new Date(1.395943258e+12),0,0,0],[new Date(1.395943259e+12),0,0,0],
[new Date(1.39594326e+12),0,0,0],[new Date(1.395943261e+12),0,0,0],[new Date(1.395943262e+12),0,0,0],[new Date(1.395943263e+12),0,0,0],
[new Date(1.395943264e+12),0,0,0],[new Date(1.395943265e+12),0,0,0],[new Date(1.395943266e+12),0,0,0],[new Date(1.395943267e+12),0,0,0],
[new Date(1.395943268e+12),0,0,0],[new Date(1.395943269e+12),0,0,0],[new Date(1.39594327e+12),0,0,0],[new Date(1.395943271e+12),0,0,0],
[new Date(1.395943272e+12),0,0,0],[new Date(1.395943273e+12),0,0,0],[new Date(1.395943274e+12),2,2,28],[new Date(1.395943275e+12),5,5,21],
[new Date(1.395943276e+12),6,6,32],[new Date(1.395943277e+12),7,6,20],[new Date(1.395943278e+12),4,4,30],[new Date(1.395943279e+12),8,7,171],
[new Date(1.39594328e+12),10,12,42],[new Date(1.395943281e+12),0,0,0],[new Date(1.395943282e+12),0,0,0],[new Date(1.395943283e+12),1,1,21],
[new Date(1.395943284e+12),22,22,165],[new Date(1.395943285e+12),0,0,0],[new Date(1.395943286e+12),5,5,19],[new Date(1.395943287e+12),0,0,0],
[new Date(1.395943288e+12),7,1,9],[new Date(1.395943289e+12),0,6,576],[new Date(1.39594329e+12),0,0,0],[new Date(1.395943291e+12),2,2,19],
[new Date(1.395943292e+12),10,10,43],[new Date(1.395943293e+12),3,2,20],[new Date(1.395943294e+12),2,3,21],[new Date(1.395943295e+12),7,7,29],
[new Date(1.395943296e+12),4,2,22],[new Date(1.395943297e+12),9,11,134],[new Date(1.395943298e+12),9,9,22],[new Date(1.395943299e+12),1,1,179],
[new Date(1.3959433e+12),1,1,19],[new Date(1.395943301e+12),7,6,25],[new Date(1.395943302e+12),0,1,41],[new Date(1.395943303e+12),0,0,0],
[new Date(1.395943304e+12),2,2,22],[new Date(1.395943305e+12),1,1,21],[new Date(1.395943306e+12),8,7,39],[new Date(1.395943307e+12),10,11,33],
[new Date(1.395943308e+12),10,10,26],[new Date(1.395943309e+12),2,2,27],[new Date(1.39594331e+12),23,14,42],[new Date(1.395943311e+12),1,10,139],
[new Date(1.395943312e+12),2,2,19],[new Date(1.395943313e+12),14,13,35],[new Date(1.395943314e+12),36,36,69],[new Date(1.395943315e+12),6,6,29],
[new Date(1.395943316e+12),3,4,22],[new Date(1.395943317e+12),2,2,40],[new Date(1.395943318e+12),6,6,22],[new Date(1.395943319e+12),18,16,28],
[new Date(1.39594332e+12),5,7,32],[new Date(1.395943321e+12),0,0,0],[new Date(1.395943322e+12),14,13,40],[new Date(1.395943323e+12),3,4,33],
[new Date(1.395943324e+12),5,5,33],[new Date(1.395943325e+12),12,12,38],[new Date(1.395943326e+12),10,9,33],[new Date(1.395943327e+12),18,18,36],
[new Date(1.395943328e+12),9,9,28],[new Date(1.395943329e+12),1,2,30],[new Date(1.39594333e+12),9,7,32],[new Date(1.395943331e+12),16,18,39],
[new Date(1.395943332e+12),0,0,0],[new Date(1.395943333e+12),0,0,0],[new Date(1.395943334e+12),15,14,36],[new Date(1.395943335e+12),30,31,71],
[new Date(1.395943336e+12),12,12,31],[new Date(1.395943337e+12),13,13,58],[new Date(1.395943338e+12),11,10,69],[new Date(1.395943339e+12),7,8,53],
[new Date(1.39594334e+12),23,23,33],[new Date(1.395943341e+12),1,1,38],[new Date(1.395943342e+12),0,0,0],[new Date(1.395943343e+12),18,15,94],
[new Date(1.395943344e+12),20,22,91],[new Date(1.395943345e+12),20,21,127],[new Date(1.395943346e+12),21,20,65],[new Date(1.395943347e+12),23,24,59],
[new Date(1.395943348e+12),8,7,60],[new Date(1.395943349e+12),23,24,39],[new Date(1.39594335e+12),13,11,35],[new Date(1.395943351e+12),16,17,46],
[new Date(1.395943352e+12),16,17,73],[new Date(1.395943353e+12),8,8,41],[new Date(1.395943354e+12),4,3,21],[new Date(1.395943355e+12),19,20,177]
];
// You could graph it with just google...
var dataTable1 = new google.visualization.DataTable();
dataTable1.addColumn(hAxis);
dataTable1.addColumn(lineA);
dataTable1.addColumn(lineB);
dataTable1.addRows(set1Rows);
var googleChart1 = new google.visualization.LineChart(document.getElementById('googleChart1'));
googleChart1.draw(dataTable1, {
title : 'Chart 1 (using the Google API directly)',
width: 1000,
height: 500,
vAxis: {0: {}, 1: {}},
hAxis: hAxis,
series: {1: {targetAxisIndex:1}}
});
// In multiple unrelated charts...
var dataTable2 = new google.visualization.DataTable();
dataTable2.addColumn(hAxis);
dataTable2.addColumn(lineC);
dataTable2.addColumn(lineD);
dataTable2.addColumn(lineE);
dataTable2.addRows(set2Rows);
var googleChart2 = new google.visualization.LineChart(document.getElementById('googleChart2'));
googleChart2.draw(dataTable2, {
title : 'Chart 2 (using the Google API directly)',
width: 1000,
height: 500,
vAxis: {0: {}, 1: {}},
hAxis: hAxis,
series: {1: {targetAxisIndex:1}}
});
// OR you could do simply combine it into one customizable chart with gvizPlus
// Create your graph by specifying the DIV and title
var graph = new gvizPlus.Graph('awesomeGraphDiv', 'Google Viz Plus Graph');
// Set any properties
graph.width = window.innerWidth - 50;
graph.height = window.innerHeight;
// Initialize the dataset
var dataSet = new gvizPlus.DataSet(hAxis);
// Set your own colors if you don't like the defaults
//dataSet.setColors([...]);
// Grouping lines by categories
dataSet.addCategory('Chart 1 Category', [lineA, lineB], set1Rows);
dataSet.addCategory('Chart 2 Category', [lineC, lineD, lineE], set2Rows);
// You can even group lines in different axes
dataSet.addAxis('Axis 1', [lineA, lineC, lineD]);
dataSet.addAxis('Axis 2', [lineB]);
// Then render
graph.draw(dataSet);
}
google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="awesomeGraphDiv"></div>
<div id="googleChart1"></div>
<div id="googleChart2"></div>
</body>
</html>