Better gallery; separates out the HTML, Javascript and CSS. Although the CSS is missi...
[dygraphs.git] / gallery / stock.js
1 Gallery.register(
2 'stock',
3 {
4 name: 'Stock Chart Demo',
5 title: 'Stock Chart Demo',
6 setup: function(parent) {
7 parent.innerHTML = [
8 "<div id='stock_div' style='width: 600px; height: 300px;'></div><br/>",
9 "<div style='width: 600px; text-align: center;'>",
10 " <button id='linear'>Linear Scale</button>&nbsp;",
11 " <button id='log' disabled='true'>Log Scale</button>",
12 "</div>"].join("\n");
13 },
14 run: function() {
15 var g = new Dygraph(document.getElementById("stock_div"), stockData,
16 {
17 customBars: true,
18 logscale: true
19 });
20
21 var linear = document.getElementById("linear");
22 var log = document.getElementById("log");
23 linear.onclick = function() { setLog(false); }
24 log.onclick = function() { setLog(true); }
25 var setLog = function(val) {
26 g.updateOptions({ logscale: val });
27 linear.disabled = !val;
28 log.disabled = val;
29 }
30 }
31 });