4 <meta http-equiv=
"X-UA-Compatible" content=
"IE=EmulateIE7; IE=EmulateIE9">
5 <title>multi-scale
</title>
7 <script type=
"text/javascript" src=
"../excanvas.js"></script>
9 <script type=
"text/javascript" src=
"../dygraph-dev.js"></script>
10 <style type=
"text/css">
16 <body style=
"max-width: 700px;">
17 <p>Gridlines and axis labels make charts easier to understand. They give
18 the lines a clear scale. Unless you tell it otherwise, dygraphs will choose
19 a y-axis and set of gridlines which include all of your data.
</p>
21 <p>If you have many series with different scales, this will compress the
22 variation in all but the largest one. Standard ways to deal with this
23 include
<a href=
"two-axes.html">secondary y-axes
</a> and
<a
24 href=
"logscale.html">log scales
</a>.
</p>
26 <p>If neither of these is to your liking, you can manually rescale your
27 series and undo that scaling for the hover values. This demo shows how to
30 <div id=
"demodiv"></div>
32 <p>Hover over to see the original values. This is what the data looks
33 like without any rescaling:
</p>
35 <div id=
"reference_div"></div>
37 <script type=
"text/javascript">
38 var zp = function(x) { if (x <
10) return
"0"+x; else return x; };
39 var labels = [
"date",
"parabola",
"line",
"another line",
"sine wave"];
41 for (var i=
1; i<=
31; i++) {
43 row.push(new Date(
"2006/10/" + zp(i)));
44 row.push(
10*(i*(
31-i)));
46 row.push(
1000*(
250 -
8*i));
47 row.push(
10000*(
125 +
125 * Math.sin(
0.3*i)));
57 var rescaled_data = [];
58 for (var i =
0; i < data.length; i++) {
62 for (var j =
1; j < src.length; j++) {
63 row.push(src[j] / scales[labels[j]]);
65 rescaled_data.push(row);
69 document.getElementById(
"demodiv"),
76 title: 'Four series on different scales',
81 valueFormatter: function(y, opts, series_name) {
82 var unscaled = y * scales[series_name];
83 if (series_name == 'sine wave') return unscaled.toPrecision(
4);
92 document.getElementById(
"reference_div"),
99 title: 'Four series on the same scale',