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