Changes due to code review.
[dygraphs.git] / gallery / demo.js
1 Gallery.register(
2 'demo',
3 {
4 name: 'Interesting Shapes',
5 title: 'The original demo!',
6 setup: function(parent) {
7 parent.innerHTML =
8 "<span style='font-size: small;'>(Mouse over to highlight individual values. Click and drag to zoom. Double-click to zoom out.)</span><br/>" +
9 "<table><tr><td>" +
10 "<div id='demodiv'></div>" +
11 "</td><td valign=top>" +
12 "<div id='status' style='width:200px; font-size:0.8em; padding-top:5px;'></div>" +
13 "</td>" +
14 "</tr></table>";
15 },
16 run: function() {
17 var g = new Dygraph(
18 document.getElementById("demodiv"),
19 function() {
20 var zp = function(x) { if (x < 10) return "0"+x; else return x; };
21 var r = "date,parabola,line,another line,sine wave\n";
22 for (var i=1; i<=31; i++) {
23 r += "200610" + zp(i);
24 r += "," + 10*(i*(31-i));
25 r += "," + 10*(8*i);
26 r += "," + 10*(250 - 8*i);
27 r += "," + 10*(125 + 125 * Math.sin(0.3*i));
28 r += "\n";
29 }
30 return r;
31 },
32 {
33 labelsDiv: document.getElementById('status'),
34 labelsSeparateLines: true,
35 labelsKMB: true,
36 legend: 'always',
37 colors: ["rgb(51,204,204)",
38 "rgb(255,100,100)",
39 "#00DD55",
40 "rgba(50,50,200,0.4)"],
41 width: 640,
42 height: 480,
43 title: 'Interesting Shapes',
44 xlabel: 'Date',
45 ylabel: 'Count',
46 axisLineColor: 'white',
47 drawXGrid: false
48 }
49 );
50 }
51 });