3 * Copyright 2011 Paul Felix (paul.eric.felix@gmail.com)
4 * MIT-licensed (http://opensource.org/licenses/MIT)
8 * @fileoverview This file contains the DygraphRangeSelector class used to provide
9 * a timeline range selector widget for dygraphs.
12 /*jshint globalstrict: true */
13 /*global Dygraph:false */
17 * The DygraphRangeSelector class provides a timeline range selector widget.
18 * @param {Dygraph} dygraph The dygraph object
21 var DygraphRangeSelector
= function(dygraph
) {
22 this.isIE_
= /MSIE/.test(navigator
.userAgent
) && !window
.opera
;
23 this.isUsingExcanvas_
= dygraph
.isUsingExcanvas_
;
24 this.dygraph_
= dygraph
;
25 this.hasTouchInterface_
= typeof(TouchEvent
) != 'undefined';
26 this.isMobileDevice_
= Math
.min(screen
.width
, screen
.height
) < 480;
27 this.createCanvases_();
28 if (this.isUsingExcanvas_
) {
29 this.createIEPanOverlay_();
31 this.createZoomHandles_();
32 this.initInteraction_();
36 * Adds the range selector to the dygraph.
37 * @param {Object} graphDiv The container div for the range selector.
38 * @param {DygraphLayout} layout The DygraphLayout object for this graph.
40 DygraphRangeSelector
.prototype.addToGraph
= function(graphDiv
, layout
) {
41 this.layout_
= layout
;
43 graphDiv
.appendChild(this.bgcanvas_
);
44 graphDiv
.appendChild(this.fgcanvas_
);
45 graphDiv
.appendChild(this.leftZoomHandle_
);
46 graphDiv
.appendChild(this.rightZoomHandle_
);
50 * Renders the static background portion of the range selector.
52 DygraphRangeSelector
.prototype.renderStaticLayer
= function() {
54 this.drawStaticLayer_();
58 * Renders the interactive foreground portion of the range selector.
60 DygraphRangeSelector
.prototype.renderInteractiveLayer
= function() {
61 if (this.isChangingRange_
) {
64 this.placeZoomHandles_();
65 this.drawInteractiveLayer_();
70 * Resizes the range selector.
72 DygraphRangeSelector
.prototype.resize_
= function() {
73 function setElementRect(canvas
, rect
) {
74 canvas
.style
.top
= rect
.y
+ 'px';
75 canvas
.style
.left
= rect
.x
+ 'px';
76 canvas
.width
= rect
.w
;
77 canvas
.height
= rect
.h
;
78 canvas
.style
.width
= canvas
.width
+ 'px'; // for IE
79 canvas
.style
.height
= canvas
.height
+ 'px'; // for IE
82 var plotArea
= this.layout_
.getPlotArea();
83 var xAxisLabelHeight
= this.attr_('axisLabelFontSize') + 2 * this.attr_('axisTickSize');
86 y
: plotArea
.y
+ plotArea
.h
+ xAxisLabelHeight
+ 4,
88 h
: this.attr_('rangeSelectorHeight')
91 setElementRect(this.bgcanvas_
, this.canvasRect_
);
92 setElementRect(this.fgcanvas_
, this.canvasRect_
);
95 DygraphRangeSelector
.prototype.attr_
= function(name
) {
96 return this.dygraph_
.attr_(name
);
101 * Creates the background and foreground canvases.
103 DygraphRangeSelector
.prototype.createCanvases_
= function() {
104 this.bgcanvas_
= Dygraph
.createCanvas();
105 this.bgcanvas_
.className
= 'dygraph-rangesel-bgcanvas';
106 this.bgcanvas_
.style
.position
= 'absolute';
107 this.bgcanvas_
.style
.zIndex
= 9;
108 this.bgcanvas_ctx_
= Dygraph
.getContext(this.bgcanvas_
);
110 this.fgcanvas_
= Dygraph
.createCanvas();
111 this.fgcanvas_
.className
= 'dygraph-rangesel-fgcanvas';
112 this.fgcanvas_
.style
.position
= 'absolute';
113 this.fgcanvas_
.style
.zIndex
= 9;
114 this.fgcanvas_
.style
.cursor
= 'default';
115 this.fgcanvas_ctx_
= Dygraph
.getContext(this.fgcanvas_
);
120 * Creates overlay divs for IE/Excanvas so that mouse events are handled properly.
122 DygraphRangeSelector
.prototype.createIEPanOverlay_
= function() {
123 this.iePanOverlay_
= document
.createElement("div");
124 this.iePanOverlay_
.style
.position
= 'absolute';
125 this.iePanOverlay_
.style
.backgroundColor
= 'white';
126 this.iePanOverlay_
.style
.filter
= 'alpha(opacity=0)';
127 this.iePanOverlay_
.style
.display
= 'none';
128 this.iePanOverlay_
.style
.cursor
= 'move';
129 this.fgcanvas_
.appendChild(this.iePanOverlay_
);
134 * Creates the zoom handle elements.
136 DygraphRangeSelector
.prototype.createZoomHandles_
= function() {
137 var img
= new Image();
138 img
.className
= 'dygraph-rangesel-zoomhandle';
139 img
.style
.position
= 'absolute';
140 img
.style
.zIndex
= 10;
141 img
.style
.visibility
= 'hidden'; // Initially hidden so they don't show up in the wrong place.
142 img
.style
.cursor
= 'col-resize';
144 if (/MSIE 7/.test(navigator
.userAgent
)) { // IE7 doesn't support embedded src data.
147 img
.style
.backgroundColor
= 'white';
148 img
.style
.border
= '1px solid #333333'; // Just show box in IE7.
152 img
.src
= 'data:image/png;base64,' +
153 'iVBORw0KGgoAAAANSUhEUgAAAAkAAAAQCAYAAADESFVDAAAAAXNSR0IArs4c6QAAAAZiS0dEANAA' +
154 'zwDP4Z7KegAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAAd0SU1FB9sHGw0cMqdt1UwAAAAZdEVYdENv' +
155 'bW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAaElEQVQoz+3SsRFAQBCF4Z9WJM8KCDVwownl' +
156 '6YXsTmCUsyKGkZzcl7zkz3YLkypgAnreFmDEpHkIwVOMfpdi9CEEN2nGpFdwD03yEqDtOgCaun7s' +
157 'qSTDH32I1pQA2Pb9sZecAxc5r3IAb21d6878xsAAAAAASUVORK5CYII=';
160 var minScreenDim
= Math
.min(screen
.width
, screen
.height
);
161 if (minScreenDim
< 480) {
164 } else if (minScreenDim
< 768) {
169 this.leftZoomHandle_
= img
;
170 this.rightZoomHandle_
= img
.cloneNode(false);
175 * Sets up the interaction for the range selector.
177 DygraphRangeSelector
.prototype.initInteraction_
= function() {
179 var topElem
= this.isIE_
? document
: window
;
182 var isZooming
= false;
183 var isPanning
= false;
184 var dynamic
= !this.isMobileDevice_
&& !this.isUsingExcanvas_
;
186 // functions, defined below. Defining them this way (rather than with
187 // "function foo() {...}" makes JSHint happy.
188 var toXDataWindow
, onZoomStart
, onZoom
, onZoomEnd
, doZoom
, isMouseInPanZone
,
189 onPanStart
, onPan
, onPanEnd
, doPan
, onCanvasMouseMove
;
191 // Touch event functions
192 var onZoomHandleTouchEvent
, onCanvasTouchEvent
, addTouchEvents
;
194 toXDataWindow
= function(zoomHandleStatus
) {
195 var xDataLimits
= self
.dygraph_
.xAxisExtremes();
196 var fact
= (xDataLimits
[1] - xDataLimits
[0])/self
.canvasRect_
.w
;
197 var xDataMin
= xDataLimits
[0] + (zoomHandleStatus
.leftHandlePos
- self
.canvasRect_
.x
)*fact
;
198 var xDataMax
= xDataLimits
[0] + (zoomHandleStatus
.rightHandlePos
- self
.canvasRect_
.x
)*fact
;
199 return [xDataMin
, xDataMax
];
202 onZoomStart
= function(e
) {
203 Dygraph
.cancelEvent(e
);
206 handle
= e
.target
? e
.target
: e
.srcElement
;
207 self
.dygraph_
.addEvent(topElem
, 'mousemove', onZoom
);
208 self
.dygraph_
.addEvent(topElem
, 'mouseup', onZoomEnd
);
209 self
.fgcanvas_
.style
.cursor
= 'col-resize';
212 onZoom
= function(e
) {
216 var delX
= e
.screenX
- xLast
;
217 if (Math
.abs(delX
) < 4) {
221 var zoomHandleStatus
= self
.getZoomHandleStatus_();
223 if (handle
== self
.leftZoomHandle_
) {
224 newPos
= zoomHandleStatus
.leftHandlePos
+ delX
;
225 newPos
= Math
.min(newPos
, zoomHandleStatus
.rightHandlePos
- handle
.width
- 3);
226 newPos
= Math
.max(newPos
, self
.canvasRect_
.x
);
228 newPos
= zoomHandleStatus
.rightHandlePos
+ delX
;
229 newPos
= Math
.min(newPos
, self
.canvasRect_
.x
+ self
.canvasRect_
.w
);
230 newPos
= Math
.max(newPos
, zoomHandleStatus
.leftHandlePos
+ handle
.width
+ 3);
232 var halfHandleWidth
= handle
.width
/2;
233 handle
.style
.left
= (newPos
- halfHandleWidth
) + 'px';
234 self
.drawInteractiveLayer_();
236 // Zoom on the fly (if not using excanvas).
242 onZoomEnd
= function(e
) {
247 Dygraph
.removeEvent(topElem
, 'mousemove', onZoom
);
248 Dygraph
.removeEvent(topElem
, 'mouseup', onZoomEnd
);
249 self
.fgcanvas_
.style
.cursor
= 'default';
251 // If using excanvas, Zoom now.
257 doZoom
= function() {
259 var zoomHandleStatus
= self
.getZoomHandleStatus_();
260 self
.isChangingRange_
= true;
261 if (!zoomHandleStatus
.isZoomed
) {
262 self
.dygraph_
.doUnzoom_();
264 var xDataWindow
= toXDataWindow(zoomHandleStatus
);
265 self
.dygraph_
.doZoomXDates_(xDataWindow
[0], xDataWindow
[1]);
268 self
.isChangingRange_
= false;
272 isMouseInPanZone
= function(e
) {
273 if (self
.isUsingExcanvas_
) {
274 return e
.srcElement
== self
.iePanOverlay_
;
276 var rect
= self
.leftZoomHandle_
.getBoundingClientRect();
277 var leftHandleClientX
= rect
.left
+ rect
.width
/2;
278 rect
= self
.rightZoomHandle_
.getBoundingClientRect();
279 var rightHandleClientX
= rect
.left
+ rect
.width
/2;
280 return (e
.clientX
> leftHandleClientX
&& e
.clientX
< rightHandleClientX
);
284 onPanStart
= function(e
) {
285 if (!isPanning
&& isMouseInPanZone(e
) && self
.getZoomHandleStatus_().isZoomed
) {
286 Dygraph
.cancelEvent(e
);
289 self
.dygraph_
.addEvent(topElem
, 'mousemove', onPan
);
290 self
.dygraph_
.addEvent(topElem
, 'mouseup', onPanEnd
);
294 onPan
= function(e
) {
298 Dygraph
.cancelEvent(e
);
300 var delX
= e
.screenX
- xLast
;
301 if (Math
.abs(delX
) < 4) {
307 var zoomHandleStatus
= self
.getZoomHandleStatus_();
308 var leftHandlePos
= zoomHandleStatus
.leftHandlePos
;
309 var rightHandlePos
= zoomHandleStatus
.rightHandlePos
;
310 var rangeSize
= rightHandlePos
- leftHandlePos
;
311 if (leftHandlePos
+ delX
<= self
.canvasRect_
.x
) {
312 leftHandlePos
= self
.canvasRect_
.x
;
313 rightHandlePos
= leftHandlePos
+ rangeSize
;
314 } else if (rightHandlePos
+ delX
>= self
.canvasRect_
.x
+ self
.canvasRect_
.w
) {
315 rightHandlePos
= self
.canvasRect_
.x
+ self
.canvasRect_
.w
;
316 leftHandlePos
= rightHandlePos
- rangeSize
;
318 leftHandlePos
+= delX
;
319 rightHandlePos
+= delX
;
321 var halfHandleWidth
= self
.leftZoomHandle_
.width
/2;
322 self
.leftZoomHandle_
.style
.left
= (leftHandlePos
- halfHandleWidth
) + 'px';
323 self
.rightZoomHandle_
.style
.left
= (rightHandlePos
- halfHandleWidth
) + 'px';
324 self
.drawInteractiveLayer_();
326 // Do pan on the fly (if not using excanvas).
332 onPanEnd
= function(e
) {
337 Dygraph
.removeEvent(topElem
, 'mousemove', onPan
);
338 Dygraph
.removeEvent(topElem
, 'mouseup', onPanEnd
);
339 // If using excanvas, do pan now.
347 self
.isChangingRange_
= true;
348 self
.dygraph_
.dateWindow_
= toXDataWindow(self
.getZoomHandleStatus_());
349 self
.dygraph_
.drawGraph_(false);
351 self
.isChangingRange_
= false;
355 onCanvasMouseMove
= function(e
) {
356 if (isZooming
|| isPanning
) {
359 var cursor
= isMouseInPanZone(e
) ? 'move' : 'default';
360 if (cursor
!= self
.fgcanvas_
.style
.cursor
) {
361 self
.fgcanvas_
.style
.cursor
= cursor
;
365 onZoomHandleTouchEvent
= function(e
) {
367 if (e
.type
== 'touchstart') {
368 onZoomStart(e
.targetTouches
[0]);
369 } else if (e
.type
== 'touchmove') {
370 onZoom(e
.targetTouches
[0]);
376 onCanvasTouchEvent
= function(e
) {
378 if (e
.type
== 'touchstart') {
379 onPanStart(e
.targetTouches
[0]);
380 } else if (e
.type
== 'touchmove') {
381 onPan(e
.targetTouches
[0]);
387 addTouchEvents
= function(elem
, fn
) {
388 var types
= ['touchstart', 'touchend', 'touchmove', 'touchcancel'];
389 for (var i
= 0; i
< types
.length
; i
++) {
390 self
.dygraph_
.addEvent(elem
, types
[i
], fn
);
394 this.dygraph_
.attrs_
.interactionModel
=
395 Dygraph
.Interaction
.dragIsPanInteractionModel
;
396 this.dygraph_
.attrs_
.panEdgeFraction
= 0.0001;
398 var dragStartEvent
= window
.opera
? 'mousedown' : 'dragstart';
399 this.dygraph_
.addEvent(this.leftZoomHandle_
, dragStartEvent
, onZoomStart
);
400 this.dygraph_
.addEvent(this.rightZoomHandle_
, dragStartEvent
, onZoomStart
);
402 if (this.isUsingExcanvas_
) {
403 this.dygraph_
.addEvent(this.iePanOverlay_
, 'mousedown', onPanStart
);
405 this.dygraph_
.addEvent(this.fgcanvas_
, 'mousedown', onPanStart
);
406 this.dygraph_
.addEvent(this.fgcanvas_
, 'mousemove', onCanvasMouseMove
);
410 if (this.hasTouchInterface_
) {
411 addTouchEvents(this.leftZoomHandle_
, onZoomHandleTouchEvent
);
412 addTouchEvents(this.rightZoomHandle_
, onZoomHandleTouchEvent
);
413 addTouchEvents(this.fgcanvas_
, onCanvasTouchEvent
);
419 * Draws the static layer in the background canvas.
421 DygraphRangeSelector
.prototype.drawStaticLayer_
= function() {
422 var ctx
= this.bgcanvas_ctx_
;
423 ctx
.clearRect(0, 0, this.canvasRect_
.w
, this.canvasRect_
.h
);
425 this.drawMiniPlot_();
431 this.bgcanvas_ctx_
.lineWidth
= 1;
432 ctx
.strokeStyle
= 'gray';
434 ctx
.moveTo(margin
, margin
);
435 ctx
.lineTo(margin
, this.canvasRect_
.h
-margin
);
436 ctx
.lineTo(this.canvasRect_
.w
-margin
, this.canvasRect_
.h
-margin
);
437 ctx
.lineTo(this.canvasRect_
.w
-margin
, margin
);
444 * Draws the mini plot in the background canvas.
446 DygraphRangeSelector
.prototype.drawMiniPlot_
= function() {
447 var fillStyle
= this.attr_('rangeSelectorPlotFillColor');
448 var strokeStyle
= this.attr_('rangeSelectorPlotStrokeColor');
449 if (!fillStyle
&& !strokeStyle
) {
453 var combinedSeriesData
= this.computeCombinedSeriesAndLimits_();
454 var yRange
= combinedSeriesData
.yMax
- combinedSeriesData
.yMin
;
456 // Draw the mini plot.
457 var ctx
= this.bgcanvas_ctx_
;
460 var xExtremes
= this.dygraph_
.xAxisExtremes();
461 var xRange
= Math
.max(xExtremes
[1] - xExtremes
[0], 1.e
-30);
462 var xFact
= (this.canvasRect_
.w
- margin
)/xRange
;
463 var yFact
= (this.canvasRect_
.h
- margin
)/yRange
;
464 var canvasWidth
= this.canvasRect_
.w
- margin
;
465 var canvasHeight
= this.canvasRect_
.h
- margin
;
468 ctx
.moveTo(margin
, canvasHeight
);
469 for (var i
= 0; i
< combinedSeriesData
.data
.length
; i
++) {
470 var dataPoint
= combinedSeriesData
.data
[i
];
471 var x
= (dataPoint
[0] - xExtremes
[0])*xFact
;
472 var y
= canvasHeight
- (dataPoint
[1] - combinedSeriesData
.yMin
)*yFact
;
473 if (isFinite(x
) && isFinite(y
)) {
477 ctx
.lineTo(canvasWidth
, canvasHeight
);
481 var lingrad
= this.bgcanvas_ctx_
.createLinearGradient(0, 0, 0, canvasHeight
);
482 lingrad
.addColorStop(0, 'white');
483 lingrad
.addColorStop(1, fillStyle
);
484 this.bgcanvas_ctx_
.fillStyle
= lingrad
;
489 this.bgcanvas_ctx_
.strokeStyle
= strokeStyle
;
490 this.bgcanvas_ctx_
.lineWidth
= 1.5;
497 * Computes and returns the combinded series data along with min/max for the mini plot.
498 * @return {Object} An object containing combinded series array, ymin, ymax.
500 DygraphRangeSelector
.prototype.computeCombinedSeriesAndLimits_
= function() {
501 var data
= this.dygraph_
.rawData_
;
502 var logscale
= this.attr_('logscale');
504 // Create a combined series (average of all series values).
505 var combinedSeries
= [];
512 // Find out if data has multiple values per datapoint.
513 // Go to first data point that actually has values (see http://code.google.com/p/dygraphs/issues/detail
?id
=246)
514 for (i
= 0; i
< data
.length
; i
++) {
515 if (data
[i
].length
> 1 && data
[i
][1] !== null) {
516 mutipleValues
= typeof data
[i
][1] != 'number';
520 for (k
= 0; k
< data
[i
][1].length
; k
++) {
529 for (i
= 0; i
< data
.length
; i
++) {
530 var dataPoint
= data
[i
];
534 for (k
= 0; k
< sum
.length
; k
++) {
535 sum
[k
] = count
[k
] = 0;
541 for (j
= 1; j
< dataPoint
.length
; j
++) {
542 if (this.dygraph_
.visibility()[j
-1]) {
545 for (k
= 0; k
< sum
.length
; k
++) {
547 if (y
=== null || isNaN(y
)) continue;
553 if (y
=== null || isNaN(y
)) continue;
561 for (k
= 0; k
< sum
.length
; k
++) {
569 combinedSeries
.push([xVal
, yVal
]);
572 // Account for roll period, fractions.
573 combinedSeries
= this.dygraph_
.rollingAverage(combinedSeries
, this.dygraph_
.rollPeriod_
);
575 if (typeof combinedSeries
[0][1] != 'number') {
576 for (i
= 0; i
< combinedSeries
.length
; i
++) {
577 yVal
= combinedSeries
[i
][1];
578 combinedSeries
[i
][1] = yVal
[0];
582 // Compute the y range.
583 var yMin
= Number
.MAX_VALUE
;
584 var yMax
= -Number
.MAX_VALUE
;
585 for (i
= 0; i
< combinedSeries
.length
; i
++) {
586 yVal
= combinedSeries
[i
][1];
587 if (yVal
!== null && isFinite(yVal
) && (!logscale
|| yVal
> 0)) {
588 yMin
= Math
.min(yMin
, yVal
);
589 yMax
= Math
.max(yMax
, yVal
);
593 // Convert Y data to log scale if needed.
594 // Also, expand the Y range to compress the mini plot a little.
595 var extraPercent
= 0.25;
597 yMax
= Dygraph
.log10(yMax
);
598 yMax
+= yMax
*extraPercent
;
599 yMin
= Dygraph
.log10(yMin
);
600 for (i
= 0; i
< combinedSeries
.length
; i
++) {
601 combinedSeries
[i
][1] = Dygraph
.log10(combinedSeries
[i
][1]);
605 var yRange
= yMax
- yMin
;
606 if (yRange
<= Number
.MIN_VALUE
) {
607 yExtra
= yMax
*extraPercent
;
609 yExtra
= yRange
*extraPercent
;
615 return {data
: combinedSeries
, yMin
: yMin
, yMax
: yMax
};
620 * Places the zoom handles in the proper position based on the current X data window.
622 DygraphRangeSelector
.prototype.placeZoomHandles_
= function() {
623 var xExtremes
= this.dygraph_
.xAxisExtremes();
624 var xWindowLimits
= this.dygraph_
.xAxisRange();
625 var xRange
= xExtremes
[1] - xExtremes
[0];
626 var leftPercent
= Math
.max(0, (xWindowLimits
[0] - xExtremes
[0])/xRange
);
627 var rightPercent
= Math
.max(0, (xExtremes
[1] - xWindowLimits
[1])/xRange
);
628 var leftCoord
= this.canvasRect_
.x
+ this.canvasRect_
.w
*leftPercent
;
629 var rightCoord
= this.canvasRect_
.x
+ this.canvasRect_
.w
*(1 - rightPercent
);
630 var handleTop
= Math
.max(this.canvasRect_
.y
, this.canvasRect_
.y
+ (this.canvasRect_
.h
- this.leftZoomHandle_
.height
)/2);
631 var halfHandleWidth
= this.leftZoomHandle_
.width
/2;
632 this.leftZoomHandle_
.style
.left
= (leftCoord
- halfHandleWidth
) + 'px';
633 this.leftZoomHandle_
.style
.top
= handleTop
+ 'px';
634 this.rightZoomHandle_
.style
.left
= (rightCoord
- halfHandleWidth
) + 'px';
635 this.rightZoomHandle_
.style
.top
= this.leftZoomHandle_
.style
.top
;
637 this.leftZoomHandle_
.style
.visibility
= 'visible';
638 this.rightZoomHandle_
.style
.visibility
= 'visible';
643 * Draws the interactive layer in the foreground canvas.
645 DygraphRangeSelector
.prototype.drawInteractiveLayer_
= function() {
646 var ctx
= this.fgcanvas_ctx_
;
647 ctx
.clearRect(0, 0, this.canvasRect_
.w
, this.canvasRect_
.h
);
649 var width
= this.canvasRect_
.w
- margin
;
650 var height
= this.canvasRect_
.h
- margin
;
651 var zoomHandleStatus
= this.getZoomHandleStatus_();
653 ctx
.strokeStyle
= 'black';
654 if (!zoomHandleStatus
.isZoomed
) {
656 ctx
.moveTo(margin
, margin
);
657 ctx
.lineTo(margin
, height
);
658 ctx
.lineTo(width
, height
);
659 ctx
.lineTo(width
, margin
);
661 if (this.iePanOverlay_
) {
662 this.iePanOverlay_
.style
.display
= 'none';
665 var leftHandleCanvasPos
= Math
.max(margin
, zoomHandleStatus
.leftHandlePos
- this.canvasRect_
.x
);
666 var rightHandleCanvasPos
= Math
.min(width
, zoomHandleStatus
.rightHandlePos
- this.canvasRect_
.x
);
668 ctx
.fillStyle
= 'rgba(240, 240, 240, 0.6)';
669 ctx
.fillRect(0, 0, leftHandleCanvasPos
, this.canvasRect_
.h
);
670 ctx
.fillRect(rightHandleCanvasPos
, 0, this.canvasRect_
.w
- rightHandleCanvasPos
, this.canvasRect_
.h
);
673 ctx
.moveTo(margin
, margin
);
674 ctx
.lineTo(leftHandleCanvasPos
, margin
);
675 ctx
.lineTo(leftHandleCanvasPos
, height
);
676 ctx
.lineTo(rightHandleCanvasPos
, height
);
677 ctx
.lineTo(rightHandleCanvasPos
, margin
);
678 ctx
.lineTo(width
, margin
);
681 if (this.isUsingExcanvas_
) {
682 this.iePanOverlay_
.style
.width
= (rightHandleCanvasPos
- leftHandleCanvasPos
) + 'px';
683 this.iePanOverlay_
.style
.left
= leftHandleCanvasPos
+ 'px';
684 this.iePanOverlay_
.style
.height
= height
+ 'px';
685 this.iePanOverlay_
.style
.display
= 'inline';
692 * Returns the current zoom handle position information.
693 * @return {Object} The zoom handle status.
695 DygraphRangeSelector
.prototype.getZoomHandleStatus_
= function() {
696 var halfHandleWidth
= this.leftZoomHandle_
.width
/2;
697 var leftHandlePos
= parseInt(this.leftZoomHandle_
.style
.left
, 10) + halfHandleWidth
;
698 var rightHandlePos
= parseInt(this.rightZoomHandle_
.style
.left
, 10) + halfHandleWidth
;
700 leftHandlePos
: leftHandlePos
,
701 rightHandlePos
: rightHandlePos
,
702 isZoomed
: (leftHandlePos
- 1 > this.canvasRect_
.x
|| rightHandlePos
+ 1 < this.canvasRect_
.x
+this.canvasRect_
.w
)