3 <title>gviz selection
</title>
5 <script type=
"text/javascript" src=
"../excanvas.js"></script>
7 <script type=
"text/javascript" src=
"../strftime/strftime-min.js"></script>
8 <script type=
"text/javascript" src=
"../rgbcolor/rgbcolor.js"></script>
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">
13 google.load('visualization', '
1');
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');
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);
56 function drawVisualization() {
57 data = createDataTable('date');
59 chart = new Dygraph.GVizChart(document.getElementById('dygraphs'));
60 chart.draw(data, {hideOverlayOnMouseOut: false});
64 function setSelection() {
65 var sel = [{column:
1, row:
2}, {column:
2, row:
2}];
66 chart.setSelection(sel);
68 function clearSelection() {
70 chart.setSelection(sel);
72 function getChartSelection() {
73 var sel = chart.getSelection();
75 var html = '
<p>Selection: [';
76 for (var i =
0; i < sel.length; i++) {
77 if (i
> 0) html += ', ';
78 html += i + '=
> {row: '+ sel[i].row +
79 ' col: '+ sel[i].column + '}';
82 document.getElementById('output').innerHTML += html;
84 google.setOnLoadCallback(drawVisualization);
88 <p>Get/Set/Clear selection via gviz API:
</p>
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>