Crosshair plugin
[dygraphs.git] / gallery / stock.js
CommitLineData
e88a95b4
DV
1/*global Gallery,Dygraph,data */
2/*global stockData */
3381d8fa
RK
3Gallery.register(
4 'stock',
5 {
6 name: 'Stock Chart Demo',
7 title: 'Stock Chart Demo',
8 setup: function(parent) {
605b6119 9 parent.innerHTML = [
10eef8e9
RK
10 "<div id='stock_div' style='width: 600px; height: 300px;'></div><br/>",
11 "<div style='width: 600px; text-align: center;'>",
605b6119
RK
12 " <button id='linear'>Linear Scale</button>&nbsp;",
13 " <button id='log' disabled='true'>Log Scale</button>",
14 "</div>"].join("\n");
3381d8fa
RK
15 },
16 run: function() {
3c10a0f3 17 var g = new Dygraph(document.getElementById("stock_div"), stockData,
3381d8fa
RK
18 {
19 customBars: true,
20 logscale: true
21 });
e1e80cce 22
3c10a0f3
RK
23 var linear = document.getElementById("linear");
24 var log = document.getElementById("log");
3c10a0f3 25 var setLog = function(val) {
3381d8fa 26 g.updateOptions({ logscale: val });
3c10a0f3
RK
27 linear.disabled = !val;
28 log.disabled = val;
e1e80cce 29 };
e88a95b4
DV
30 linear.onclick = function() { setLog(false); };
31 log.onclick = function() { setLog(true); };
3381d8fa 32 }
e1e80cce 33 });