Commit | Line | Data |
---|---|---|
e5152598 | 1 | <html> |
36dfa958 | 2 | <head> |
36dfa958 | 3 | <title>isZoomedIgnoresProgrammaticZoom Flag</title> |
7e5ddc94 DV |
4 | <!-- |
5 | For production (minified) code, use: | |
6 | <script type="text/javascript" src="dygraph-combined.js"></script> | |
7 | --> | |
8 | <script type="text/javascript" src="../dygraph-dev.js"></script> | |
9 | ||
36dfa958 DV |
10 | <script type="text/javascript" src="data.js"></script> |
11 | </head> | |
12 | <body> | |
13 | <h1 id="zoom">Determining Zoom</h1> | |
14 | <p> | |
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. | |
18 | </p> | |
19 | ||
20 | <p>Here's a simple example using <code>drawCallback</code> to display the various zoom states whenever the chart is zoomed:</p> | |
21 | ||
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/> | |
28 | </div> | |
29 | <div class="codeoutput" style="float:left;"> | |
30 | <div id="zoomdiv"></div> | |
31 | <script type="text/javascript"> | |
f6fbf9e0 | 32 | var g = new Dygraph( |
36dfa958 DV |
33 | |
34 | // containing div | |
35 | document.getElementById("zoomdiv"), | |
36 | ||
37 | // CSV or path to a CSV file. | |
38 | "Date,Value\n" + | |
39 | "2011-01-07,75\n" + | |
40 | "2011-01-08,70\n" + | |
41 | "2011-01-09,90\n" + | |
42 | "2011-01-10,30\n" + | |
43 | "2011-01-11,40\n" + | |
44 | "2011-01-12,60\n" + | |
45 | "2011-01-13,70\n" + | |
46 | "2011-01-14,40\n", | |
47 | { | |
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"); | |
52 | } | |
53 | } | |
54 | ); | |
55 | </script> | |
56 | </div> | |
57 | </div> | |
58 | ||
59 | <p> | |
60 | <div style="clear:both; width:600px; text-align:center; font-weight: bold; font-size: 125%;">HTML</div> | |
e5152598 NN |
61 | |
62 | <pre> | |
63 | new Dygraph( | |
64 | ||
36dfa958 DV |
65 | // containing div |
66 | document.getElementById("zoomdiv"), | |
e5152598 | 67 | |
36dfa958 DV |
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", | |
78 | { | |
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"); | |
e5152598 | 83 | } |
36dfa958 | 84 | } |
e5152598 NN |
85 | ); |
86 | </pre> | |
36dfa958 DV |
87 | </p> |
88 | ||
48e614ac | 89 | <p>The <a href="zoom.html">Tests for zoom operations</a> show a full example of this in action.</p> |
36dfa958 DV |
90 | |
91 | <h3>Programmatic Zoom</h3> | |
92 | <p> | |
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. | |
97 | </p> | |
98 | <p> | |
99 | The <a href="tests/is-zoomed-ignore-programmatic-zoom.html">is-zoomed-ignore-programmatic-zoom</a> test shows this in operation. | |
100 | </p> | |
101 | </body> | |
e5152598 | 102 | </html> |