Kill all the IE/excanvas hacks
[dygraphs.git] / tests / logscale.html
CommitLineData
54425b14 1<!DOCTYPE html>
ff022deb
RK
2<html>
3 <head>
4 <title>log scale</title>
7e5ddc94
DV
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
ff022deb
RK
11 </head>
12
13 <body>
2cae510b 14 <center>
5b9b2142
RK
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>
2cae510b
RK
20 </center>
21
93f26a2d 22 <h2>X axis of dates</h2>
2cae510b 23 <div id="div_g0" style="width:600px; height:300px;"></div>
5b9b2142 24 <div style="font-style: italic; margin-left: 40px;">(Note: when the x-axis is dates, logscale is ignored on that axis.)</div>
2cae510b 25
93f26a2d 26 <h2>X axis of numbers</h2>
2cae510b
RK
27 <div id="div_g1" style="width:600px; height:300px;"></div>
28
ff022deb 29 <script type="text/javascript">
5b9b2142
RK
30 Dygraph.Interaction.DEBUG = true;
31
2cae510b 32 function data0() {
ff022deb 33 return "Date,A\n" +
d59b6f34
RK
34 "20101201,5\n"+
35 "20101202,10\n"+
2cae510b 36 "20101203,-1\n"+
d59b6f34
RK
37 "20101204,250\n"+
38 "20101205,1000\n"+
39 "20101206,30\n"+
40 "20101207,80\n"+
41 "20101208,100\n"+
7d0e7a0d 42 "20101209,500\n"+
ff022deb 43 "";
2cae510b
RK
44 };
45 function data1() {
7d0e7a0d 46 return "X,A\n" +
4b467120 47 "1,0.000001\n"+
7d0e7a0d
RK
48 "2,10\n"+
49 "3,100\n"+
50 "4,250\n"+
51 "5,1000\n"+
52 "6,30\n"+
9d8685cc 53 "7,0\n"+
7d0e7a0d
RK
54 "8,100\n"+
55 "9,500\n"+
44462ba3 56 "101,500\n"+
5b9b2142
RK
57 "30,500\n"+
58 "50,400\n"+
59 "100,300\n"+
60 "300,200\n"+
61 "1000,100\n"+
7d0e7a0d 62 "";
2cae510b 63 };
ff022deb 64
5b9b2142
RK
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;
ff022deb 82 }
5b9b2142
RK
83
84 setLogScale('y', true);
ff022deb
RK
85 </script>
86
87 </body>
88</html>