4 <meta http-equiv=
"X-UA-Compatible" content=
"IE=EmulateIE7; IE=EmulateIE9">
5 <title>gviz selection
</title>
7 <script type=
"text/javascript" src=
"../excanvas.js"></script>
9 <script type=
"text/javascript" src=
"../strftime/strftime-min.js"></script>
10 <script type=
"text/javascript" src=
"../rgbcolor/rgbcolor.js"></script>
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">
15 google.load('visualization', '
1');
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');
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);
58 function drawVisualization() {
59 data = createDataTable('date');
61 chart = new Dygraph.GVizChart(document.getElementById('dygraphs'));
62 chart.draw(data, {hideOverlayOnMouseOut: false});
66 function setSelection() {
67 var sel = [{column:
1, row:
2}, {column:
2, row:
2}];
68 chart.setSelection(sel);
70 function clearSelection() {
72 chart.setSelection(sel);
74 function getChartSelection() {
75 var sel = chart.getSelection();
77 var html = '
<p>Selection: [';
78 for (var i =
0; i < sel.length; i++) {
79 if (i
> 0) html += ', ';
80 html += i + '=
> {row: '+ sel[i].row +
81 ' col: '+ sel[i].column + '}';
84 document.getElementById('output').innerHTML += html;
86 google.setOnLoadCallback(drawVisualization);
90 <p>Get/Set/Clear selection via gviz API:
</p>
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>