DygraphLayout.prototype._evaluateLimits = function() {
this.minxval = this.maxxval = null;
- for (var name in this.datasets) {
- if (!this.datasets.hasOwnProperty(name)) continue;
- var series = this.datasets[name];
- var x1 = series[0][0];
- if (!this.minxval || x1 < this.minxval) this.minxval = x1;
-
- var x2 = series[series.length - 1][0];
- if (!this.maxxval || x2 > this.maxxval) this.maxxval = x2;
+ if (this.options.dateWindow) {
+ this.minxval = this.options.dateWindow[0];
+ this.maxxval = this.options.dateWindow[1];
+ } else {
+ for (var name in this.datasets) {
+ if (!this.datasets.hasOwnProperty(name)) continue;
+ var series = this.datasets[name];
+ var x1 = series[0][0];
+ if (!this.minxval || x1 < this.minxval) this.minxval = x1;
+
+ var x2 = series[series.length - 1][0];
+ if (!this.maxxval || x2 > this.maxxval) this.maxxval = x2;
+ }
}
this.xrange = this.maxxval - this.minxval;
this.xscale = (this.xrange != 0 ? 1/this.xrange : 1.0);
this.addXTicks_();
// Tell PlotKit to use this new data and render itself
+ if (this.dateWindow_) {
+ this.layout_.updateOptions({dateWindow: this.dateWindow_});
+ }
this.layout_.evaluateWithError();
this.plotter_.clear();
this.plotter_.render();
- this.canvas_.getContext('2d').clearRect(0, 0,
- this.canvas_.width, this.canvas_.height);
+ this.canvas_.getContext('2d').clearRect(0, 0, this.canvas_.width,
+ this.canvas_.height);
};
/**
--- /dev/null
+<html>
+ <head>
+ <title>dateWindow</title>
+ <!--[if IE]>
+ <script type="text/javascript" src="excanvas.js"></script>
+ <![endif]-->
+ <script type="text/javascript" src="../dygraph-combined.js"></script>
+ <script type="text/javascript" src="../dygraph-canvas.js"></script>
+ <script type="text/javascript" src="../dygraph.js"></script>
+ </head>
+ <body>
+ <p>dateWindow is set to something other than an x-value in the data set.
+ Grid lines should still go through data points.</p>
+
+ <div id="div_g" style="width:600px; height:300px;"></div>
+
+ <script type="text/javascript">
+ var data = [];
+ for (var i = 0; i < 10; i++) {
+ data.push([i, i%2, i%3]);
+ }
+
+ g = new Dygraph(
+ document.getElementById("div_g"),
+ data, {
+ dateWindow: [ -15, 15 ]
+ }
+ );
+ </script>
+ </body>
+</html>