Fix errors/warnings in tests/*.html
[dygraphs.git] / tests / gviz-selection.html
CommitLineData
54425b14 1<!DOCTYPE html>
b263a46e
NAG
2<html>
3 <head>
07dbe090 4 <title>gviz selection</title>
7e5ddc94
DV
5 <!--
6 For production (minified) code, use:
7 <script type="text/javascript" src="dygraph-combined.js"></script>
8 -->
fbd6834a 9 <script type="text/javascript" src="../dist/dygraph.js"></script>
7e5ddc94 10
b263a46e
NAG
11 <script type="text/javascript" src="http://www.google.com/jsapi"></script>
12 <script type="text/javascript">
07dbe090 13 google.load('visualization', '1');
b263a46e
NAG
14
15 function createDataTable(dateType) {
16 data = new google.visualization.DataTable();
17 data.addColumn(dateType, 'Date');
18 data.addColumn('number', 'Column A');
19 data.addColumn('number', 'Column B');
20 data.addRows(10);
21 data.setCell(0, 0, new Date("2009/07/01"));
22 data.setCell(0, 1, 1);
23 data.setCell(0, 2, 7);
24 data.setCell(1, 0, new Date("2009/07/08"));
25 data.setCell(1, 1, 2);
26 data.setCell(1, 2, 4);
27 data.setCell(2, 0, new Date("2009/07/15"));
28 data.setCell(2, 1, 3);
29 data.setCell(2, 2, 3);
30 data.setCell(3, 0, new Date("2009/07/22"));
31 data.setCell(3, 1, 4);
32 data.setCell(3, 2, 0);
33 data.setCell(4, 0, new Date("2009/07/26"));
34 data.setCell(4, 1, 5);
35 data.setCell(4, 2, 2);
36 data.setCell(5, 0, new Date("2009/07/27"));
37 data.setCell(5, 1, 2);
38 data.setCell(5, 2, 7);
39 data.setCell(6, 0, new Date("2009/07/28"));
40 data.setCell(6, 1, 3);
41 data.setCell(6, 2, 8);
42 data.setCell(7, 0, new Date("2009/08/01"));
43 data.setCell(7, 1, 4);
44 data.setCell(7, 2, 9);
45 data.setCell(8, 0, new Date("2009/08/02"));
46 data.setCell(8, 1, 3);
47 data.setCell(8, 2, 10);
48 data.setCell(9, 0, new Date("2009/08/04"));
49 data.setCell(9, 1, 3);
50 data.setCell(9, 2, 8);
51 return data;
52 }
07dbe090 53
b263a46e
NAG
54 var chart;
55
56 function drawVisualization() {
57 data = createDataTable('date');
58
59 chart = new Dygraph.GVizChart(document.getElementById('dygraphs'));
60 chart.draw(data, {hideOverlayOnMouseOut: false});
61
62 }
07dbe090 63
b263a46e
NAG
64 function setSelection() {
65 var sel = [{column: 1, row: 2}, {column: 2, row: 2}];
66 chart.setSelection(sel);
67 }
68 function clearSelection() {
69 var sel = [];
70 chart.setSelection(sel);
71 }
72 function getChartSelection() {
73 var sel = chart.getSelection();
07dbe090 74
b263a46e 75 var html = '<p>Selection: [';
07dbe090
DV
76 for (var i = 0; i < sel.length; i++) {
77 if (i > 0) html += ', ';
78 html += i + '=&gt; {row: '+ sel[i].row +
79 ' col: '+ sel[i].column + '}';
b263a46e
NAG
80 }
81 html += ']</p>';
82 document.getElementById('output').innerHTML += html;
83 }
84 google.setOnLoadCallback(drawVisualization);
85 </script>
86 </head>
87 <body>
07dbe090 88 <p>Get/Set/Clear selection via gviz API:</p>
b263a46e
NAG
89 <div id="dygraphs" style="width:600px; height:300px;"></div>
90 <input type="button" onclick="setSelection()" value="setSelection()"/>
91 <input type="button" onclick="clearSelection()" value="clearSelection()"/>
92 <input type="button" onclick="getChartSelection()" value="getSelection()"/>
93 <div id="output"></div>
94 </body>
95</html>