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