4 <link rel=
"stylesheet" href=
"../dist/dygraph.css">
5 <title>gviz selection
</title>
6 <script type=
"text/javascript" src=
"../dist/dygraph.js"></script>
8 <script type=
"text/javascript" src=
"http://www.google.com/jsapi"></script>
9 <script type=
"text/javascript">
10 google.load('visualization', '
1');
12 function createDataTable(dateType) {
13 data = new google.visualization.DataTable();
14 data.addColumn(dateType, 'Date');
15 data.addColumn('number', 'Column A');
16 data.addColumn('number', 'Column B');
18 data.setCell(
0,
0, new Date(
"2009/07/01"));
19 data.setCell(
0,
1,
1);
20 data.setCell(
0,
2,
7);
21 data.setCell(
1,
0, new Date(
"2009/07/08"));
22 data.setCell(
1,
1,
2);
23 data.setCell(
1,
2,
4);
24 data.setCell(
2,
0, new Date(
"2009/07/15"));
25 data.setCell(
2,
1,
3);
26 data.setCell(
2,
2,
3);
27 data.setCell(
3,
0, new Date(
"2009/07/22"));
28 data.setCell(
3,
1,
4);
29 data.setCell(
3,
2,
0);
30 data.setCell(
4,
0, new Date(
"2009/07/26"));
31 data.setCell(
4,
1,
5);
32 data.setCell(
4,
2,
2);
33 data.setCell(
5,
0, new Date(
"2009/07/27"));
34 data.setCell(
5,
1,
2);
35 data.setCell(
5,
2,
7);
36 data.setCell(
6,
0, new Date(
"2009/07/28"));
37 data.setCell(
6,
1,
3);
38 data.setCell(
6,
2,
8);
39 data.setCell(
7,
0, new Date(
"2009/08/01"));
40 data.setCell(
7,
1,
4);
41 data.setCell(
7,
2,
9);
42 data.setCell(
8,
0, new Date(
"2009/08/02"));
43 data.setCell(
8,
1,
3);
44 data.setCell(
8,
2,
10);
45 data.setCell(
9,
0, new Date(
"2009/08/04"));
46 data.setCell(
9,
1,
3);
47 data.setCell(
9,
2,
8);
53 function drawVisualization() {
54 data = createDataTable('date');
56 chart = new Dygraph.GVizChart(document.getElementById('dygraphs'));
57 chart.draw(data, {hideOverlayOnMouseOut: false});
61 function setSelection() {
62 var sel = [{column:
1, row:
2}, {column:
2, row:
2}];
63 chart.setSelection(sel);
65 function clearSelection() {
67 chart.setSelection(sel);
69 function getChartSelection() {
70 var sel = chart.getSelection();
72 var html = '
<p>Selection: [';
73 for (var i =
0; i < sel.length; i++) {
74 if (i
> 0) html += ', ';
75 html += i + '=
> {row: '+ sel[i].row +
76 ' col: '+ sel[i].column + '}';
79 document.getElementById('output').innerHTML += html;
81 google.setOnLoadCallback(drawVisualization);
85 <p>Get/Set/Clear selection via gviz API:
</p>
86 <div id=
"dygraphs" style=
"width:600px; height:300px;"></div>
87 <input type=
"button" onclick=
"setSelection()" value=
"setSelection()"/>
88 <input type=
"button" onclick=
"clearSelection()" value=
"clearSelection()"/>
89 <input type=
"button" onclick=
"getChartSelection()" value=
"getSelection()"/>
90 <div id=
"output"></div>