/
annotation-gviz.html
57 lines (50 loc) · 2.42 KB
/
annotation-gviz.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Google Visualisations annotations</title>
<link rel="stylesheet" type="text/css" href="../dist/dygraph.css" />
<link rel="stylesheet" type="text/css" href="../common/vextlnk.css" />
<script type="text/javascript" src="../dist/dygraph.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript"><!--//--><![CDATA[//><!--
Dygraph.onDOMready(function onDOMready() {
google.load('visualization', '1', {'packages':['annotatedtimeline']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addColumn('number', 'Sold Pencils');
data.addColumn('string', 'title1');
data.addColumn('string', 'text1');
data.addColumn('number', 'Sold Pens');
data.addColumn('string', 'title2');
data.addColumn('string', 'text2');
data.addRows([
[new Date(2008, 11 ,1), 30000, undefined, undefined, 40645, undefined, undefined],
[new Date(2008, 11 ,2), 14045, undefined, undefined, 20374, undefined, undefined],
[new Date(2008, 11 ,3), 55022, undefined, undefined, 50766, undefined, undefined],
[new Date(2008, 11 ,4), 75284, undefined, undefined, 14334, 'Out of Stock','Ran out of stock on pens at 4pm'],
[new Date(2008, 11 ,5), 41476, 'Bought Pens','Bought 200k pens', 66467, undefined, undefined],
[new Date(2008, 11 ,6), 33322, undefined, undefined, 39463, undefined, undefined]
]);
for (var i = 1; i < 14; i++) {
data.addRows([
[new Date(2008, 11 , 6 + i), i * 1000, 'title1-' + i, 'text1 ' + (i * 1000 - i), (i * 2000 + i), 'title2-' + i, 'text2' + i * 1000],
]);
}
var chart = new google.visualization.AnnotatedTimeLine(document.getElementById('gviz_div'));
chart.draw(data, {displayAnnotations: true});
var g = new Dygraph.GVizChart(document.getElementById("dg_div"));
g.draw(data, {displayAnnotations: true, labelsKMB: true});
}
});
//--><!]]></script>
</head>
<body>
<h3>Google AnnotatedTimeline:</h3>
<div id='gviz_div' style='width: 700px; height: 240px;'></div>
<h3>Dygraph.GVizChart:</h3>
<div id='dg_div' style='width: 700px; height: 240px;'></div>
</body>
</html>