*/
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.
<body>
<h3>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.</h3>
+ buttons are useful for testing.</h3>
<h4>Window coordinates (in dates and values):</h4>
- <div id = "dimensions"></div>
+ <div id="xdimensions"></div> <div id="ydimensions"></div>
<div id="div_g" style="width:600px; height:300px;"></div>
<p><b>Zoom operations:</b></p>
showDimensions(minDate, maxDate, minValue, maxValue);
function showDimensions(minDate, maxDate, minValue, maxValue) {
- var elem = document.getElementById("dimensions");
- elem.innerHTML =
- "dateWindow : [" + minDate + " , "+ maxDate + "],<br>" +
- "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
+ });
}
</script>