From 85b99f0b7b3020c58fc40e1a0df7e0e9782d50bf Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sun, 13 Dec 2009 00:26:34 -0800 Subject: [PATCH] clean up whitespace issues --- dygraph-canvas.js | 104 ++++++++++++++++++++++++++---------------------------- dygraph.js | 18 +++++----- 2 files changed, 60 insertions(+), 62 deletions(-) diff --git a/dygraph-canvas.js b/dygraph-canvas.js index 70ec659..49dddd4 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -38,14 +38,13 @@ DygraphLayout.prototype.evaluate = function() { DygraphLayout.prototype._evaluateLimits = function() { this.minxval = this.maxxval = null; for (var name in this.datasets) { - if (this.datasets.hasOwnProperty(name)) { - 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.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); @@ -60,30 +59,30 @@ DygraphLayout.prototype._evaluateLineCharts = function() { // add all the rects this.points = new Array(); for (var setName in this.datasets) { - if (this.datasets.hasOwnProperty(setName)) { - var dataset = this.datasets[setName]; - for (var j = 0; j < dataset.length; j++) { - var item = dataset[j]; - var point = { - x: ((parseFloat(item[0]) - this.minxval) * this.xscale), - y: 1.0 - ((parseFloat(item[1]) - this.minyval) * this.yscale), - xval: parseFloat(item[0]), - yval: parseFloat(item[1]), - name: setName - }; - - // limit the x, y values so they do not overdraw - if (point.y <= 0.0) { - point.y = 0.0; - } - if (point.y >= 1.0) { - point.y = 1.0; - } - if ((point.x >= 0.0) && (point.x <= 1.0)) { - this.points.push(point); - } - } - } + if (!this.datasets.hasOwnProperty(setName)) continue; + + var dataset = this.datasets[setName]; + for (var j = 0; j < dataset.length; j++) { + var item = dataset[j]; + var point = { + x: ((parseFloat(item[0]) - this.minxval) * this.xscale), + y: 1.0 - ((parseFloat(item[1]) - this.minyval) * this.yscale), + xval: parseFloat(item[0]), + yval: parseFloat(item[1]), + name: setName + }; + + // limit the x, y values so they do not overdraw + if (point.y <= 0.0) { + point.y = 0.0; + } + if (point.y >= 1.0) { + point.y = 1.0; + } + if ((point.x >= 0.0) && (point.x <= 1.0)) { + this.points.push(point); + } + } } }; @@ -121,21 +120,20 @@ DygraphLayout.prototype.evaluateWithError = function() { // Copy over the error terms var i = 0; // index in this.points for (var setName in this.datasets) { - if (this.datasets.hasOwnProperty(setName)) { - var j = 0; - var dataset = this.datasets[setName]; - for (var j = 0; j < dataset.length; j++, i++) { - var item = dataset[j]; - var xv = parseFloat(item[0]); - var yv = parseFloat(item[1]); - - if (xv == this.points[i].xval && - yv == this.points[i].yval) { - this.points[i].errorMinus = parseFloat(item[2]); - this.points[i].errorPlus = parseFloat(item[3]); - } - } - } + if (!this.datasets.hasOwnProperty(setName)) continue; + var j = 0; + var dataset = this.datasets[setName]; + for (var j = 0; j < dataset.length; j++, i++) { + var item = dataset[j]; + var xv = parseFloat(item[0]); + var yv = parseFloat(item[1]); + + if (xv == this.points[i].xval && + yv == this.points[i].yval) { + this.points[i].errorMinus = parseFloat(item[2]); + this.points[i].errorPlus = parseFloat(item[3]); + } + } } }; @@ -328,9 +326,9 @@ DygraphCanvasRenderer.prototype._renderAxis = function() { var makeDiv = function(txt) { var div = document.createElement("div"); for (var name in labelStyle) { - if (labelStyle.hasOwnProperty(name)) { - div.style[name] = labelStyle[name]; - } + if (labelStyle.hasOwnProperty(name)) { + div.style[name] = labelStyle[name]; + } } div.appendChild(document.createTextNode(txt)); return div; @@ -446,9 +444,9 @@ DygraphCanvasRenderer.prototype._renderLineChart = function() { var setNames = []; for (var name in this.layout.datasets) { - if (this.layout.datasets.hasOwnProperty(name)) { - setNames.push(name); - } + if (this.layout.datasets.hasOwnProperty(name)) { + setNames.push(name); + } } var setCount = setNames.length; diff --git a/dygraph.js b/dygraph.js index 690cb8b..a2048d3 100644 --- a/dygraph.js +++ b/dygraph.js @@ -451,9 +451,9 @@ Dygraph.prototype.createStatusMessage_ = function(){ Dygraph.update(messagestyle, this.attr_('labelsDivStyles')); var div = document.createElement("div"); for (var name in messagestyle) { - if (messagestyle.hasOwnProperty(name)) { - div.style[name] = messagestyle[name]; - } + if (messagestyle.hasOwnProperty(name)) { + div.style[name] = messagestyle[name]; + } } this.graphDiv.appendChild(div); this.attrs_.labelsDiv = div; @@ -478,9 +478,9 @@ Dygraph.prototype.createRollInterface_ = function() { roller.size = "2"; roller.value = this.rollPeriod_; for (var name in textAttr) { - if (textAttr.hasOwnProperty(name)) { - roller.style[name] = textAttr[name]; - } + if (textAttr.hasOwnProperty(name)) { + roller.style[name] = textAttr[name]; + } } var pa = this.graphDiv; @@ -1611,9 +1611,9 @@ Dygraph.prototype.parseDataTable_ = function(data) { Dygraph.update = function (self, o) { if (typeof(o) != 'undefined' && o !== null) { for (var k in o) { - if (o.hasOwnProperty(k)) { - self[k] = o[k]; - } + if (o.hasOwnProperty(k)) { + self[k] = o[k]; + } } } return self; -- 2.7.4