1 /*global Gallery,Dygraph,data */
5 name
: 'Highlighted Region',
6 title
: 'Draws a time series with an unusual region highlighted',
7 setup
: function(parent
) {
9 "<div id='div_g' style='width:600px; height:300px;'></div>",
10 "<p>When you zoom and pan, the region remains highlighted.</p>"].join("\n");
13 // A basic sinusoidal data series.
15 for (var i
= 0; i
< 1000; i
++) {
16 var base
= 10 * Math
.sin(i
/ 90.0);
17 data
.push([i
, base
, base
+ Math
.sin(i
/ 2.0)]);
20 // Shift one portion out of line.
21 var highlight_start
= 450;
22 var highlight_end
= 500;
23 for (var i
= highlight_start
; i
<= highlight_end
; i
++) {
28 document
.getElementById("div_g"),
31 labels
: ['X', 'Est.', 'Actual'],
33 underlayCallback
: function(canvas
, area
, g
) {
34 var bottom_left
= g
.toDomCoords(highlight_start
, -20);
35 var top_right
= g
.toDomCoords(highlight_end
, +20);
37 var left
= bottom_left
[0];
38 var right
= top_right
[0];
40 canvas
.fillStyle
= "rgba(255, 255, 102, 1.0)";
41 canvas
.fillRect(left
, area
.y
, right
- left
, area
.h
);