Commit | Line | Data |
---|---|---|
d9e6fa47 DV |
1 | <html> |
2 | <head> | |
3 | <title>Highlighted Region</title> | |
4 | <!--[if IE]> | |
a2b2c3a1 | 5 | <script type="text/javascript" src="../excanvas.js"></script> |
d9e6fa47 DV |
6 | <![endif]--> |
7 | <script type="text/javascript" src="../strftime/strftime-min.js"></script> | |
8 | <script type="text/javascript" src="../rgbcolor/rgbcolor.js"></script> | |
9 | <script type="text/javascript" src="../dygraph-canvas.js"></script> | |
10 | <script type="text/javascript" src="../dygraph.js"></script> | |
11 | <script type="text/javascript" src="data.js"></script> | |
12 | </head> | |
13 | <body> | |
14 | <p>Should draw a time series with an unusual region highlighted:</p> | |
15 | <div id="div_g" style="width:600px; height:300px;"></div> | |
16 | ||
17 | <p>When you zoom/pan, the region should remain highlighted.</p> | |
18 | ||
19 | <script type="text/javascript"> | |
20 | // A basic sinusoidal data series. | |
21 | var data = []; | |
22 | for (var i = 0; i < 1000; i++) { | |
23 | var base = 10 * Math.sin(i / 90.0); | |
24 | data.push([i, base, base + Math.sin(i / 2.0)]); | |
25 | } | |
26 | ||
27 | // Shift one portion out of line. | |
28 | var highlight_start = 450; | |
29 | var highlight_end = 500; | |
30 | for (var i = highlight_start; i <= highlight_end; i++) { | |
31 | data[i][2] += 5.0; | |
32 | } | |
33 | ||
34 | ||
35 | new Dygraph( | |
36 | document.getElementById("div_g"), | |
37 | data, | |
38 | { | |
39 | labels: ['X', 'Est.', 'Actual'], | |
40 | underlayCallback: function(canvas, area, layout, g) { | |
41 | var bottom_left = g.toDomCoords(highlight_start, -20); | |
42 | var top_right = g.toDomCoords(highlight_end, +20); | |
43 | ||
44 | var left = bottom_left[0]; | |
45 | var right = top_right[0]; | |
46 | ||
eb7bf005 | 47 | canvas.fillStyle = "rgba(255, 255, 102, 1.0)"; |
d9e6fa47 DV |
48 | canvas.fillRect(left, area.y, right - left, area.h); |
49 | } | |
50 | ||
51 | } | |
52 | ); | |
53 | </script> | |
54 | </body> | |
55 | </html> |