axis computation
[dygraphs.git] / tests / gviz-selection.html
CommitLineData
b263a46e
NAG
1<html>
2 <head>
07dbe090 3 <title>gviz selection</title>
b263a46e
NAG
4 <!--[if IE]>
5 <script type="text/javascript" src="excanvas.js"></script>
6 <![endif]-->
67b65269
DV
7 <script type="text/javascript" src="../strftime/strftime-min.js"></script>
8 <script type="text/javascript" src="../rgbcolor/rgbcolor.js"></script>
b263a46e
NAG
9 <script type="text/javascript" src="../dygraph-canvas.js"></script>
10 <script type="text/javascript" src="../dygraph.js"></script>
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>