Make dblclick event cancelable. (#840)
[dygraphs.git] / tests / logscale.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <link rel="stylesheet" href="../dist/dygraph.css">
5 <title>log scale</title>
6 <script type="text/javascript" src="../dist/dygraph.js"></script>
7
8 </head>
9
10 <body>
11 <center>
12 <input id='ylog' type="button" value="y log scale" onclick="setLogScale('y', true)">
13 <input id='ylinear' type="button" value="y linear scale" onclick="setLogScale('y', false)">
14 <input id='xlog' type="button" value="x log scale" onclick="setLogScale('x', true)">
15 <input id='xlinear' type="button" value="x linear scale" onclick="setLogScale('x', false)">
16 <div>Current scales: <span id="description"></span></div>
17 </center>
18
19 <h2>X axis of dates</h2>
20 <div id="div_g0" style="width:600px; height:300px;"></div>
21 <div style="font-style: italic; margin-left: 40px;">(Note: when the x-axis is dates, logscale is ignored on that axis.)</div>
22
23 <h2>X axis of numbers</h2>
24 <div id="div_g1" style="width:600px; height:300px;"></div>
25
26 <script type="text/javascript">
27 function data0() {
28 return "Date,A\n" +
29 "20101201,5\n"+
30 "20101202,10\n"+
31 "20101203,-1\n"+
32 "20101204,250\n"+
33 "20101205,1000\n"+
34 "20101206,30\n"+
35 "20101207,80\n"+
36 "20101208,100\n"+
37 "20101209,500\n"+
38 "";
39 };
40 function data1() {
41 return "X,A\n" +
42 "1,0.000001\n"+
43 "2,10\n"+
44 "3,100\n"+
45 "4,250\n"+
46 "5,1000\n"+
47 "6,30\n"+
48 "7,0\n"+
49 "8,100\n"+
50 "9,500\n"+
51 "30,500\n"+
52 "50,400\n"+
53 "100,300\n"+
54 "101,500\n"+
55 "300,200\n"+
56 "1000,100\n"+
57 "";
58 };
59
60 var g0 = new Dygraph(document.getElementById("div_g0"), data0, {});
61 var g1 = new Dygraph(document.getElementById("div_g1"), data1, {});
62 var graphs = [ g0, g1 ];
63 var scales = { x : false, y : false };
64 function setLogScale(axis, val) {
65 if (axis === 'y') {
66 for (var idx = 0; idx < graphs.length; idx++) {
67 graphs[idx].updateOptions({ logscale: val });
68 }
69 } else {
70 for (var idx = 0; idx < graphs.length; idx++) {
71 graphs[idx].updateOptions({ axes : { x : { logscale : val } } });
72 }
73 }
74 scales[axis] = val;
75 var text = "y: " + (scales.y ? "log" : "linear") + ", x: " + (scales.x ? "log" : "linear");
76 document.getElementById("description").innerText = text;
77 }
78
79 setLogScale('y', true);
80 </script>
81
82 </body>
83 </html>