3 <title>isZoomedIgnoresProgrammaticZoom Flag
</title>
5 For production (minified) code, use:
6 <script type=
"text/javascript" src=
"dygraph-combined.js"></script>
8 <script type=
"text/javascript" src=
"../dygraph-dev.js"></script>
10 <script type=
"text/javascript" src=
"data.js"></script>
13 <h1 id=
"zoom">Determining Zoom
</h1>
15 It is possible to detect whether a chart has been zoomed in either axis by the use of the
<code>isZoomed
</code> function.
16 If called with no argument, it will report whether
<em>either
</em> axis has been zoomed.
17 Alternatively it can be called with an argument of either
<code>'x'
</code> or
<code>'y'
</code> and it will report the status of just that axis.
20 <p>Here's a simple example using
<code>drawCallback
</code> to display the various zoom states whenever the chart is zoomed:
</p>
22 <div style=
"width:600px; text-align:center; font-weight: bold; font-size: 125%;">OUTPUT
</div>
23 <div style=
"width: 750px">
24 <div style=
"float: right">
25 <p>Zoomed:
<span id=
"zoomed">False
</span><p/>
26 <p>Zoomed X:
<span id=
"zoomedX">False
</span><p/>
27 <p>Zoomed Y:
<span id=
"zoomedY">False
</span><p/>
29 <div class=
"codeoutput" style=
"float:left;">
30 <div id=
"zoomdiv"></div>
31 <script type=
"text/javascript">
35 document.getElementById(
"zoomdiv"),
37 // CSV or path to a CSV file.
48 drawCallback: function(me, initial) {
49 document.getElementById(
"zoomed").innerHTML =
"" + me.isZoomed();
50 document.getElementById(
"zoomedX").innerHTML =
"" + me.isZoomed(
"x");
51 document.getElementById(
"zoomedY").innerHTML =
"" + me.isZoomed(
"y");
60 <div style=
"clear:both; width:600px; text-align:center; font-weight: bold; font-size: 125%;">HTML
</div>
66 document.getElementById(
"zoomdiv
"),
68 // CSV or path to a CSV file.
69 "Date,Temperature
\n" +
70 "2011-
01-
07,
75\n" +
71 "2011-
01-
08,
70\n" +
72 "2011-
01-
09,
90\n" +
73 "2011-
01-
10,
30\n" +
74 "2011-
01-
11,
40\n" +
75 "2011-
01-
12,
60\n" +
76 "2011-
01-
13,
70\n" +
77 "2011-
01-
14,
40\n",
79 drawCallback: function(me, initial) {
80 document.getElementById(
"zoomed
").innerHTML =
"" + me.isZoomed();
81 document.getElementById(
"zoomedX
").innerHTML =
"" + me.isZoomed(
"x
");
82 document.getElementById(
"zoomedY
").innerHTML =
"" + me.isZoomed(
"y
");
89 <p>The
<a href=
"zoom.html">Tests for zoom operations
</a> show a full example of this in action.
</p>
91 <h3>Programmatic Zoom
</h3>
93 When a chart is programmatically zoomed by updating either the
<code>dateWindow
</code>
94 or
<code>valueRange
</code> option, by default the zoomed flags are also updated correspondingly.
95 It is possible to prevent this by specifying the
<code>isZoomedIgnoreProgrammaticZoom
</code> in the same
96 call to the
<code>updateOptions
</code> method.
99 The
<a href=
"tests/is-zoomed-ignore-programmatic-zoom.html">is-zoomed-ignore-programmatic-zoom
</a> test shows this in operation.