Skip to content

Instantly share code, notes, and snippets.

@krishicks
Created April 10, 2010 21:04
Show Gist options
  • Save krishicks/362300 to your computer and use it in GitHub Desktop.
Save krishicks/362300 to your computer and use it in GitHub Desktop.
diff --git a/dygraph.js b/dygraph.js
index 3d3326e..374c355 100644
--- a/dygraph.js
+++ b/dygraph.js
@@ -1521,8 +1521,18 @@ Dygraph.prototype.drawGraph_ = function(data) {
for (var i = 1; i < data[0].length; i++) {
if (!this.visibility()[i - 1]) continue;
+ // Reduce the resolution of the dataset if necessary.
+ var data_length = data.length
+ if (this.dateWindow_) {
+ data_length = this.dateWindow_[1] - this.dateWindow_[0];
+ }
+ var step = 1;
+ if (data_length > Math.round(this.width_/4)) {
+ step = Math.round(data_length/(this.width_/4));
+ }
+
var series = [];
- for (var j = 0; j < data.length; j++) {
+ for (var j = 0; j < data.length; j+=step) {
if (data[j][i] || !connectSeparatedPoints) {
var date = data[j][0];
series.push([date, data[j][i]]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment