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