From: Robert Konigsberg Date: Fri, 8 Oct 2010 16:22:48 +0000 (-0400) Subject: Fix example to only use public API. This required changing updateOptions to better... X-Git-Tag: v1.0.0~613^2~5 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=c65f2303664330f03787d4e0bc7da5f2d9b4bc5f;p=dygraphs.git Fix example to only use public API. This required changing updateOptions to better be aware of specified, yet undefined, entries. Tweak of docs --- diff --git a/docs/index.html b/docs/index.html index 4369588..928b121 100644 --- a/docs/index.html +++ b/docs/index.html @@ -73,7 +73,7 @@

A demo is worth a thousand words:

-

(Mouse over to highlight individual values. Click and drag to zoom in both axes. Double-click to zoom back out. Change the number and hit enter to adjust the averaging period.)

+

(Mouse over to highlight individual values. Click and drag to zoom. Double-click to zoom back out. Change the number and hit enter to adjust the averaging period.)

Temperatures in New York vs. San Francisco
diff --git a/dygraph.js b/dygraph.js index 216753a..b8ce5e2 100644 --- a/dygraph.js +++ b/dygraph.js @@ -2486,14 +2486,15 @@ Dygraph.prototype.start_ = function() { */ Dygraph.prototype.updateOptions = function(attrs) { // TODO(danvk): this is a mess. Rethink this function. - if (attrs.rollPeriod) { + if ('rollPeriod' in attrs) { this.rollPeriod_ = attrs.rollPeriod; } - if (attrs.dateWindow) { + if ('dateWindow' in attrs) { this.dateWindow_ = attrs.dateWindow; } - if (attrs.valueRange) { + if ('valueRange' in attrs) { this.valueRange_ = attrs.valueRange; + this.valueWindow_ = attrs.valueRange; } // TODO(danvk): validate per-series options. diff --git a/tests/zoom.html b/tests/zoom.html index ee6fbec..353be3b 100644 --- a/tests/zoom.html +++ b/tests/zoom.html @@ -13,9 +13,9 @@

Click the buttons to change the zoom level or just use the normal click-and drag. While zoom typically works by click-and-drag, the - butons are useful for testing.

+ buttons are useful for testing.

Window coordinates (in dates and values):

-
+

Zoom operations:

@@ -54,22 +54,39 @@ showDimensions(minDate, maxDate, minValue, maxValue); function showDimensions(minDate, maxDate, minValue, maxValue) { - var elem = document.getElementById("dimensions"); - elem.innerHTML = - "dateWindow : [" + minDate + " , "+ maxDate + "],
" + - "valueRange : [" + minValue + " , "+ maxValue + "],"; + showXDimensions(minDate, maxDate); + showYDimensions(minValue, maxValue); + } + + function showXDimensions(first, second) { + var elem = document.getElementById("xdimensions"); + elem.innerHTML = "dateWindow : [" + first + ", "+ second + "]"; + } + + function showYDimensions(first, second) { + var elem = document.getElementById("ydimensions"); + elem.innerHTML = "valueRange : [" + first + ", "+ second + "]"; } function zoomGraphX(minDate, maxDate) { - g.doZoomXDates_(minDate, maxDate); + g.updateOptions({ + dateWindow: [minDate, maxDate] + }); + showXDimensions(minDate, maxDate); } function zoomGraphY(minValue, maxValue) { - g.doZoomYValues_(minValue, maxValue); + g.updateOptions({ + valueRange: [minValue, maxValue] + }); + showYDimensions(minValue, maxValue); } function unzoomGraph() { - g.doUnzoom_(); + g.updateOptions({ + dateWindow: undefined, + valueRange: undefined + }); }