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