1 // Copyright 2011 Paul Felix (paul.eric.felix@gmail.com)
2 // All Rights Reserved.
5 * @fileoverview This file contains the DygraphRangeSelector class used to provide
6 * a timeline range selector widget for dygraphs.
9 /*jshint globalstrict: true */
10 /*global Dygraph:false */
14 * The DygraphRangeSelector class provides a timeline range selector widget.
15 * @param {Dygraph} dygraph The dygraph object
18 var DygraphRangeSelector
= function(dygraph
) {
19 this.isIE_
= /MSIE/.test(navigator
.userAgent
) && !window
.opera
;
20 this.isUsingExcanvas_
= dygraph
.isUsingExcanvas_
;
21 this.dygraph_
= dygraph
;
22 this.hasTouchInterface_
= typeof(TouchEvent
) != 'undefined';
23 this.isMobileDevice_
= Math
.min(screen
.width
, screen
.height
) < 480;
24 this.createCanvases_();
25 if (this.isUsingExcanvas_
) {
26 this.createIEPanOverlay_();
28 this.createZoomHandles_();
29 this.initInteraction_();
33 * Adds the range selector to the dygraph.
34 * @param {Object} graphDiv The container div for the range selector.
35 * @param {DygraphLayout} layout The DygraphLayout object for this graph.
37 DygraphRangeSelector
.prototype.addToGraph
= function(graphDiv
, layout
) {
38 this.layout_
= layout
;
40 graphDiv
.appendChild(this.bgcanvas_
);
41 graphDiv
.appendChild(this.fgcanvas_
);
42 graphDiv
.appendChild(this.leftZoomHandle_
);
43 graphDiv
.appendChild(this.rightZoomHandle_
);
47 * Renders the static background portion of the range selector.
49 DygraphRangeSelector
.prototype.renderStaticLayer
= function() {
51 this.drawStaticLayer_();
55 * Renders the interactive foreground portion of the range selector.
57 DygraphRangeSelector
.prototype.renderInteractiveLayer
= function() {
58 if (this.isChangingRange_
) {
61 this.placeZoomHandles_();
62 this.drawInteractiveLayer_();
67 * Resizes the range selector.
69 DygraphRangeSelector
.prototype.resize_
= function() {
70 function setElementRect(canvas
, rect
) {
71 canvas
.style
.top
= rect
.y
+ 'px';
72 canvas
.style
.left
= rect
.x
+ 'px';
73 canvas
.width
= rect
.w
;
74 canvas
.height
= rect
.h
;
75 canvas
.style
.width
= canvas
.width
+ 'px'; // for IE
76 canvas
.style
.height
= canvas
.height
+ 'px'; // for IE
79 var plotArea
= this.layout_
.getPlotArea();
80 var xAxisLabelHeight
= this.attr_('axisLabelFontSize') + 2 * this.attr_('axisTickSize');
83 y
: plotArea
.y
+ plotArea
.h
+ xAxisLabelHeight
+ 4,
85 h
: this.attr_('rangeSelectorHeight')
88 setElementRect(this.bgcanvas_
, this.canvasRect_
);
89 setElementRect(this.fgcanvas_
, this.canvasRect_
);
92 DygraphRangeSelector
.prototype.attr_
= function(name
) {
93 return this.dygraph_
.attr_(name
);
98 * Creates the background and foreground canvases.
100 DygraphRangeSelector
.prototype.createCanvases_
= function() {
101 this.bgcanvas_
= Dygraph
.createCanvas();
102 this.bgcanvas_
.className
= 'dygraph-rangesel-bgcanvas';
103 this.bgcanvas_
.style
.position
= 'absolute';
104 this.bgcanvas_
.style
.zIndex
= 9;
105 this.bgcanvas_ctx_
= Dygraph
.getContext(this.bgcanvas_
);
107 this.fgcanvas_
= Dygraph
.createCanvas();
108 this.fgcanvas_
.className
= 'dygraph-rangesel-fgcanvas';
109 this.fgcanvas_
.style
.position
= 'absolute';
110 this.fgcanvas_
.style
.zIndex
= 9;
111 this.fgcanvas_
.style
.cursor
= 'default';
112 this.fgcanvas_ctx_
= Dygraph
.getContext(this.fgcanvas_
);
117 * Creates overlay divs for IE/Excanvas so that mouse events are handled properly.
119 DygraphRangeSelector
.prototype.createIEPanOverlay_
= function() {
120 this.iePanOverlay_
= document
.createElement("div");
121 this.iePanOverlay_
.style
.position
= 'absolute';
122 this.iePanOverlay_
.style
.backgroundColor
= 'white';
123 this.iePanOverlay_
.style
.filter
= 'alpha(opacity=0)';
124 this.iePanOverlay_
.style
.display
= 'none';
125 this.iePanOverlay_
.style
.cursor
= 'move';
126 this.fgcanvas_
.appendChild(this.iePanOverlay_
);
131 * Creates the zoom handle elements.
133 DygraphRangeSelector
.prototype.createZoomHandles_
= function() {
134 var img
= new Image();
135 img
.className
= 'dygraph-rangesel-zoomhandle';
136 img
.style
.position
= 'absolute';
137 img
.style
.zIndex
= 10;
138 img
.style
.visibility
= 'hidden'; // Initially hidden so they don't show up in the wrong place.
139 img
.style
.cursor
= 'col-resize';
141 if (/MSIE 7/.test(navigator
.userAgent
)) { // IE7 doesn't support embedded src data.
144 img
.style
.backgroundColor
= 'white';
145 img
.style
.border
= '1px solid #333333'; // Just show box in IE7.
149 img
.src
= 'data:image/png;base64,' +
150 'iVBORw0KGgoAAAANSUhEUgAAAAkAAAAQCAYAAADESFVDAAAAAXNSR0IArs4c6QAAAAZiS0dEANAA' +
151 'zwDP4Z7KegAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAAd0SU1FB9sHGw0cMqdt1UwAAAAZdEVYdENv' +
152 'bW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAaElEQVQoz+3SsRFAQBCF4Z9WJM8KCDVwownl' +
153 '6YXsTmCUsyKGkZzcl7zkz3YLkypgAnreFmDEpHkIwVOMfpdi9CEEN2nGpFdwD03yEqDtOgCaun7s' +
154 'qSTDH32I1pQA2Pb9sZecAxc5r3IAb21d6878xsAAAAAASUVORK5CYII=';
157 var minScreenDim
= Math
.min(screen
.width
, screen
.height
);
158 if (minScreenDim
< 480) {
161 } else if (minScreenDim
< 768) {
166 this.leftZoomHandle_
= img
;
167 this.rightZoomHandle_
= img
.cloneNode(false);
172 * Sets up the interaction for the range selector.
174 DygraphRangeSelector
.prototype.initInteraction_
= function() {
176 var topElem
= this.isIE_
? document
: window
;
179 var isZooming
= false;
180 var isPanning
= false;
181 var dynamic
= !this.isMobileDevice_
&& !this.isUsingExcanvas_
;
183 // functions, defined below. Defining them this way (rather than with
184 // "function foo() {...}" makes JSHint happy.
185 var toXDataWindow
, onZoomStart
, onZoom
, onZoomEnd
, doZoom
, isMouseInPanZone
,
186 onPanStart
, onPan
, onPanEnd
, doPan
, onCanvasMouseMove
;
188 // Touch event functions
189 var onZoomHandleTouchEvent
, onCanvasTouchEvent
, addTouchEvents
;
191 toXDataWindow
= function(zoomHandleStatus
) {
192 var xDataLimits
= self
.dygraph_
.xAxisExtremes();
193 var fact
= (xDataLimits
[1] - xDataLimits
[0])/self
.canvasRect_
.w
;
194 var xDataMin
= xDataLimits
[0] + (zoomHandleStatus
.leftHandlePos
- self
.canvasRect_
.x
)*fact
;
195 var xDataMax
= xDataLimits
[0] + (zoomHandleStatus
.rightHandlePos
- self
.canvasRect_
.x
)*fact
;
196 return [xDataMin
, xDataMax
];
199 onZoomStart
= function(e
) {
200 Dygraph
.cancelEvent(e
);
203 handle
= e
.target
? e
.target
: e
.srcElement
;
204 self
.dygraph_
.addEvent(topElem
, 'mousemove', onZoom
);
205 self
.dygraph_
.addEvent(topElem
, 'mouseup', onZoomEnd
);
206 self
.fgcanvas_
.style
.cursor
= 'col-resize';
209 onZoom
= function(e
) {
213 var delX
= e
.screenX
- xLast
;
214 if (Math
.abs(delX
) < 4) {
218 var zoomHandleStatus
= self
.getZoomHandleStatus_();
220 if (handle
== self
.leftZoomHandle_
) {
221 newPos
= zoomHandleStatus
.leftHandlePos
+ delX
;
222 newPos
= Math
.min(newPos
, zoomHandleStatus
.rightHandlePos
- handle
.width
- 3);
223 newPos
= Math
.max(newPos
, self
.canvasRect_
.x
);
225 newPos
= zoomHandleStatus
.rightHandlePos
+ delX
;
226 newPos
= Math
.min(newPos
, self
.canvasRect_
.x
+ self
.canvasRect_
.w
);
227 newPos
= Math
.max(newPos
, zoomHandleStatus
.leftHandlePos
+ handle
.width
+ 3);
229 var halfHandleWidth
= handle
.width
/2;
230 handle
.style
.left
= (newPos
- halfHandleWidth
) + 'px';
231 self
.drawInteractiveLayer_();
233 // Zoom on the fly (if not using excanvas).
239 onZoomEnd
= function(e
) {
244 Dygraph
.removeEvent(topElem
, 'mousemove', onZoom
);
245 Dygraph
.removeEvent(topElem
, 'mouseup', onZoomEnd
);
246 self
.fgcanvas_
.style
.cursor
= 'default';
248 // If using excanvas, Zoom now.
254 doZoom
= function() {
256 var zoomHandleStatus
= self
.getZoomHandleStatus_();
257 self
.isChangingRange_
= true;
258 if (!zoomHandleStatus
.isZoomed
) {
259 self
.dygraph_
.doUnzoom_();
261 var xDataWindow
= toXDataWindow(zoomHandleStatus
);
262 self
.dygraph_
.doZoomXDates_(xDataWindow
[0], xDataWindow
[1]);
265 self
.isChangingRange_
= false;
269 isMouseInPanZone
= function(e
) {
270 if (self
.isUsingExcanvas_
) {
271 return e
.srcElement
== self
.iePanOverlay_
;
273 var rect
= self
.leftZoomHandle_
.getBoundingClientRect();
274 var leftHandleClientX
= rect
.left
+ rect
.width
/2;
275 rect
= self
.rightZoomHandle_
.getBoundingClientRect();
276 var rightHandleClientX
= rect
.left
+ rect
.width
/2;
277 return (e
.clientX
> leftHandleClientX
&& e
.clientX
< rightHandleClientX
);
281 onPanStart
= function(e
) {
282 if (!isPanning
&& isMouseInPanZone(e
) && self
.getZoomHandleStatus_().isZoomed
) {
283 Dygraph
.cancelEvent(e
);
286 self
.dygraph_
.addEvent(topElem
, 'mousemove', onPan
);
287 self
.dygraph_
.addEvent(topElem
, 'mouseup', onPanEnd
);
291 onPan
= function(e
) {
295 Dygraph
.cancelEvent(e
);
297 var delX
= e
.screenX
- xLast
;
298 if (Math
.abs(delX
) < 4) {
304 var zoomHandleStatus
= self
.getZoomHandleStatus_();
305 var leftHandlePos
= zoomHandleStatus
.leftHandlePos
;
306 var rightHandlePos
= zoomHandleStatus
.rightHandlePos
;
307 var rangeSize
= rightHandlePos
- leftHandlePos
;
308 if (leftHandlePos
+ delX
<= self
.canvasRect_
.x
) {
309 leftHandlePos
= self
.canvasRect_
.x
;
310 rightHandlePos
= leftHandlePos
+ rangeSize
;
311 } else if (rightHandlePos
+ delX
>= self
.canvasRect_
.x
+ self
.canvasRect_
.w
) {
312 rightHandlePos
= self
.canvasRect_
.x
+ self
.canvasRect_
.w
;
313 leftHandlePos
= rightHandlePos
- rangeSize
;
315 leftHandlePos
+= delX
;
316 rightHandlePos
+= delX
;
318 var halfHandleWidth
= self
.leftZoomHandle_
.width
/2;
319 self
.leftZoomHandle_
.style
.left
= (leftHandlePos
- halfHandleWidth
) + 'px';
320 self
.rightZoomHandle_
.style
.left
= (rightHandlePos
- halfHandleWidth
) + 'px';
321 self
.drawInteractiveLayer_();
323 // Do pan on the fly (if not using excanvas).
329 onPanEnd
= function(e
) {
334 Dygraph
.removeEvent(topElem
, 'mousemove', onPan
);
335 Dygraph
.removeEvent(topElem
, 'mouseup', onPanEnd
);
336 // If using excanvas, do pan now.
344 self
.isChangingRange_
= true;
345 self
.dygraph_
.dateWindow_
= toXDataWindow(self
.getZoomHandleStatus_());
346 self
.dygraph_
.drawGraph_(false);
348 self
.isChangingRange_
= false;
352 onCanvasMouseMove
= function(e
) {
353 if (isZooming
|| isPanning
) {
356 var cursor
= isMouseInPanZone(e
) ? 'move' : 'default';
357 if (cursor
!= self
.fgcanvas_
.style
.cursor
) {
358 self
.fgcanvas_
.style
.cursor
= cursor
;
362 onZoomHandleTouchEvent
= function(e
) {
364 if (e
.type
== 'touchstart') {
365 onZoomStart(e
.targetTouches
[0]);
366 } else if (e
.type
== 'touchmove') {
367 onZoom(e
.targetTouches
[0]);
373 onCanvasTouchEvent
= function(e
) {
375 if (e
.type
== 'touchstart') {
376 onPanStart(e
.targetTouches
[0]);
377 } else if (e
.type
== 'touchmove') {
378 onPan(e
.targetTouches
[0]);
384 addTouchEvents
= function(elem
, fn
) {
385 var types
= ['touchstart', 'touchend', 'touchmove', 'touchcancel'];
386 for (var i
= 0; i
< types
.length
; i
++) {
387 self
.dygraph_
.addEvent(elem
, types
[i
], fn
);
391 this.dygraph_
.attrs_
.interactionModel
=
392 Dygraph
.Interaction
.dragIsPanInteractionModel
;
393 this.dygraph_
.attrs_
.panEdgeFraction
= 0.0001;
395 var dragStartEvent
= window
.opera
? 'mousedown' : 'dragstart';
396 this.dygraph_
.addEvent(this.leftZoomHandle_
, dragStartEvent
, onZoomStart
);
397 this.dygraph_
.addEvent(this.rightZoomHandle_
, dragStartEvent
, onZoomStart
);
399 if (this.isUsingExcanvas_
) {
400 this.dygraph_
.addEvent(this.iePanOverlay_
, 'mousedown', onPanStart
);
402 this.dygraph_
.addEvent(this.fgcanvas_
, 'mousedown', onPanStart
);
403 this.dygraph_
.addEvent(this.fgcanvas_
, 'mousemove', onCanvasMouseMove
);
407 if (this.hasTouchInterface_
) {
408 addTouchEvents(this.leftZoomHandle_
, onZoomHandleTouchEvent
);
409 addTouchEvents(this.rightZoomHandle_
, onZoomHandleTouchEvent
);
410 addTouchEvents(this.fgcanvas_
, onCanvasTouchEvent
);
416 * Draws the static layer in the background canvas.
418 DygraphRangeSelector
.prototype.drawStaticLayer_
= function() {
419 var ctx
= this.bgcanvas_ctx_
;
420 ctx
.clearRect(0, 0, this.canvasRect_
.w
, this.canvasRect_
.h
);
422 this.drawMiniPlot_();
428 this.bgcanvas_ctx_
.lineWidth
= 1;
429 ctx
.strokeStyle
= 'gray';
431 ctx
.moveTo(margin
, margin
);
432 ctx
.lineTo(margin
, this.canvasRect_
.h
-margin
);
433 ctx
.lineTo(this.canvasRect_
.w
-margin
, this.canvasRect_
.h
-margin
);
434 ctx
.lineTo(this.canvasRect_
.w
-margin
, margin
);
441 * Draws the mini plot in the background canvas.
443 DygraphRangeSelector
.prototype.drawMiniPlot_
= function() {
444 var fillStyle
= this.attr_('rangeSelectorPlotFillColor');
445 var strokeStyle
= this.attr_('rangeSelectorPlotStrokeColor');
446 if (!fillStyle
&& !strokeStyle
) {
450 var combinedSeriesData
= this.computeCombinedSeriesAndLimits_();
451 var yRange
= combinedSeriesData
.yMax
- combinedSeriesData
.yMin
;
453 // Draw the mini plot.
454 var ctx
= this.bgcanvas_ctx_
;
457 var xExtremes
= this.dygraph_
.xAxisExtremes();
458 var xRange
= Math
.max(xExtremes
[1] - xExtremes
[0], 1.e
-30);
459 var xFact
= (this.canvasRect_
.w
- margin
)/xRange
;
460 var yFact
= (this.canvasRect_
.h
- margin
)/yRange
;
461 var canvasWidth
= this.canvasRect_
.w
- margin
;
462 var canvasHeight
= this.canvasRect_
.h
- margin
;
465 ctx
.moveTo(margin
, canvasHeight
);
466 for (var i
= 0; i
< combinedSeriesData
.data
.length
; i
++) {
467 var dataPoint
= combinedSeriesData
.data
[i
];
468 var x
= (dataPoint
[0] - xExtremes
[0])*xFact
;
469 var y
= canvasHeight
- (dataPoint
[1] - combinedSeriesData
.yMin
)*yFact
;
470 if (isFinite(x
) && isFinite(y
)) {
474 ctx
.lineTo(canvasWidth
, canvasHeight
);
478 var lingrad
= this.bgcanvas_ctx_
.createLinearGradient(0, 0, 0, canvasHeight
);
479 lingrad
.addColorStop(0, 'white');
480 lingrad
.addColorStop(1, fillStyle
);
481 this.bgcanvas_ctx_
.fillStyle
= lingrad
;
486 this.bgcanvas_ctx_
.strokeStyle
= strokeStyle
;
487 this.bgcanvas_ctx_
.lineWidth
= 1.5;
494 * Computes and returns the combinded series data along with min/max for the mini plot.
495 * @return {Object} An object containing combinded series array, ymin, ymax.
497 DygraphRangeSelector
.prototype.computeCombinedSeriesAndLimits_
= function() {
498 var data
= this.dygraph_
.rawData_
;
499 var logscale
= this.attr_('logscale');
501 // Create a combined series (average of all series values).
502 var combinedSeries
= [];
509 // Find out if data has multiple values per datapoint.
510 // Go to first data point that actually has values (see http://code.google.com/p/dygraphs/issues/detail
?id
=246)
511 for (i
= 0; i
< data
.length
; i
++) {
512 if (data
[i
].length
> 1 && data
[i
][1] !== null) {
513 mutipleValues
= typeof data
[i
][1] != 'number';
517 for (k
= 0; k
< data
[i
][1].length
; k
++) {
526 for (i
= 0; i
< data
.length
; i
++) {
527 var dataPoint
= data
[i
];
531 for (k
= 0; k
< sum
.length
; k
++) {
532 sum
[k
] = count
[k
] = 0;
538 for (j
= 1; j
< dataPoint
.length
; j
++) {
539 if (this.dygraph_
.visibility()[j
-1]) {
542 for (k
= 0; k
< sum
.length
; k
++) {
544 if (y
=== null || isNaN(y
)) continue;
550 if (y
=== null || isNaN(y
)) continue;
558 for (k
= 0; k
< sum
.length
; k
++) {
566 combinedSeries
.push([xVal
, yVal
]);
569 // Account for roll period, fractions.
570 combinedSeries
= this.dygraph_
.rollingAverage(combinedSeries
, this.dygraph_
.rollPeriod_
);
572 if (typeof combinedSeries
[0][1] != 'number') {
573 for (i
= 0; i
< combinedSeries
.length
; i
++) {
574 yVal
= combinedSeries
[i
][1];
575 combinedSeries
[i
][1] = yVal
[0];
579 // Compute the y range.
580 var yMin
= Number
.MAX_VALUE
;
581 var yMax
= -Number
.MAX_VALUE
;
582 for (i
= 0; i
< combinedSeries
.length
; i
++) {
583 yVal
= combinedSeries
[i
][1];
584 if (yVal
!== null && isFinite(yVal
) && (!logscale
|| yVal
> 0)) {
585 yMin
= Math
.min(yMin
, yVal
);
586 yMax
= Math
.max(yMax
, yVal
);
590 // Convert Y data to log scale if needed.
591 // Also, expand the Y range to compress the mini plot a little.
592 var extraPercent
= 0.25;
594 yMax
= Dygraph
.log10(yMax
);
595 yMax
+= yMax
*extraPercent
;
596 yMin
= Dygraph
.log10(yMin
);
597 for (i
= 0; i
< combinedSeries
.length
; i
++) {
598 combinedSeries
[i
][1] = Dygraph
.log10(combinedSeries
[i
][1]);
602 var yRange
= yMax
- yMin
;
603 if (yRange
<= Number
.MIN_VALUE
) {
604 yExtra
= yMax
*extraPercent
;
606 yExtra
= yRange
*extraPercent
;
612 return {data
: combinedSeries
, yMin
: yMin
, yMax
: yMax
};
617 * Places the zoom handles in the proper position based on the current X data window.
619 DygraphRangeSelector
.prototype.placeZoomHandles_
= function() {
620 var xExtremes
= this.dygraph_
.xAxisExtremes();
621 var xWindowLimits
= this.dygraph_
.xAxisRange();
622 var xRange
= xExtremes
[1] - xExtremes
[0];
623 var leftPercent
= Math
.max(0, (xWindowLimits
[0] - xExtremes
[0])/xRange
);
624 var rightPercent
= Math
.max(0, (xExtremes
[1] - xWindowLimits
[1])/xRange
);
625 var leftCoord
= this.canvasRect_
.x
+ this.canvasRect_
.w
*leftPercent
;
626 var rightCoord
= this.canvasRect_
.x
+ this.canvasRect_
.w
*(1 - rightPercent
);
627 var handleTop
= Math
.max(this.canvasRect_
.y
, this.canvasRect_
.y
+ (this.canvasRect_
.h
- this.leftZoomHandle_
.height
)/2);
628 var halfHandleWidth
= this.leftZoomHandle_
.width
/2;
629 this.leftZoomHandle_
.style
.left
= (leftCoord
- halfHandleWidth
) + 'px';
630 this.leftZoomHandle_
.style
.top
= handleTop
+ 'px';
631 this.rightZoomHandle_
.style
.left
= (rightCoord
- halfHandleWidth
) + 'px';
632 this.rightZoomHandle_
.style
.top
= this.leftZoomHandle_
.style
.top
;
634 this.leftZoomHandle_
.style
.visibility
= 'visible';
635 this.rightZoomHandle_
.style
.visibility
= 'visible';
640 * Draws the interactive layer in the foreground canvas.
642 DygraphRangeSelector
.prototype.drawInteractiveLayer_
= function() {
643 var ctx
= this.fgcanvas_ctx_
;
644 ctx
.clearRect(0, 0, this.canvasRect_
.w
, this.canvasRect_
.h
);
646 var width
= this.canvasRect_
.w
- margin
;
647 var height
= this.canvasRect_
.h
- margin
;
648 var zoomHandleStatus
= this.getZoomHandleStatus_();
650 ctx
.strokeStyle
= 'black';
651 if (!zoomHandleStatus
.isZoomed
) {
653 ctx
.moveTo(margin
, margin
);
654 ctx
.lineTo(margin
, height
);
655 ctx
.lineTo(width
, height
);
656 ctx
.lineTo(width
, margin
);
658 if (this.iePanOverlay_
) {
659 this.iePanOverlay_
.style
.display
= 'none';
662 var leftHandleCanvasPos
= Math
.max(margin
, zoomHandleStatus
.leftHandlePos
- this.canvasRect_
.x
);
663 var rightHandleCanvasPos
= Math
.min(width
, zoomHandleStatus
.rightHandlePos
- this.canvasRect_
.x
);
665 ctx
.fillStyle
= 'rgba(240, 240, 240, 0.6)';
666 ctx
.fillRect(0, 0, leftHandleCanvasPos
, this.canvasRect_
.h
);
667 ctx
.fillRect(rightHandleCanvasPos
, 0, this.canvasRect_
.w
- rightHandleCanvasPos
, this.canvasRect_
.h
);
670 ctx
.moveTo(margin
, margin
);
671 ctx
.lineTo(leftHandleCanvasPos
, margin
);
672 ctx
.lineTo(leftHandleCanvasPos
, height
);
673 ctx
.lineTo(rightHandleCanvasPos
, height
);
674 ctx
.lineTo(rightHandleCanvasPos
, margin
);
675 ctx
.lineTo(width
, margin
);
678 if (this.isUsingExcanvas_
) {
679 this.iePanOverlay_
.style
.width
= (rightHandleCanvasPos
- leftHandleCanvasPos
) + 'px';
680 this.iePanOverlay_
.style
.left
= leftHandleCanvasPos
+ 'px';
681 this.iePanOverlay_
.style
.height
= height
+ 'px';
682 this.iePanOverlay_
.style
.display
= 'inline';
689 * Returns the current zoom handle position information.
690 * @return {Object} The zoom handle status.
692 DygraphRangeSelector
.prototype.getZoomHandleStatus_
= function() {
693 var halfHandleWidth
= this.leftZoomHandle_
.width
/2;
694 var leftHandlePos
= parseInt(this.leftZoomHandle_
.style
.left
, 10) + halfHandleWidth
;
695 var rightHandlePos
= parseInt(this.rightZoomHandle_
.style
.left
, 10) + halfHandleWidth
;
697 leftHandlePos
: leftHandlePos
,
698 rightHandlePos
: rightHandlePos
,
699 isZoomed
: (leftHandlePos
- 1 > this.canvasRect_
.x
|| rightHandlePos
+ 1 < this.canvasRect_
.x
+this.canvasRect_
.w
)