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