Add some tepid comments, use of local variables, etc.
authorRobert Konigsberg <konigsberg@google.com>
Fri, 1 Jun 2012 15:35:41 +0000 (11:35 -0400)
committerRobert Konigsberg <konigsberg@google.com>
Fri, 1 Jun 2012 15:35:41 +0000 (11:35 -0400)
dygraph-canvas.js
dygraph-layout.js

index d3e0d4f..de8d4fe 100644 (file)
@@ -698,6 +698,7 @@ DygraphCanvasRenderer.isNullOrNaN_ = function(x) {
 DygraphCanvasRenderer.prototype._drawStyledLine = function(
     ctx, i, setName, color, strokeWidth, strokePattern, drawPoints,
     drawPointCallback, pointSize) {
+  // TODO(konigsberg): Compute attributes outside this method call.
   var stepPlot = this.attr_("stepPlot");
   var firstIndexInSet = this.layout.setPointsOffsets[i];
   var setLength = this.layout.setPointsLengths[i];
@@ -850,6 +851,8 @@ DygraphCanvasRenderer.prototype._drawLine = function(ctx, i) {
   var borderWidth = this.dygraph_.attr_("strokeBorderWidth", setName);
   var drawPointCallback = this.dygraph_.attr_("drawPointCallback", setName) ||
       Dygraph.Circles.DEFAULT;
+
+  // TODO(konigsberg): Turn this into one call, and then consider inlining drawStyledLine.
   if (borderWidth && strokeWidth) {
     this._drawStyledLine(ctx, i, setName,
         this.dygraph_.attr_("strokeBorderColor", setName),
index e55f62b..1fe4228 100644 (file)
@@ -219,6 +219,9 @@ DygraphLayout.prototype._evaluateLineCharts = function() {
   // points and drawing the lines. The brunt of the cost comes from allocating
   // the |point| structures.
   var i = 0;
+
+  // Preallocating the size of points reduces reallocations, and therefore,
+  // calls to collect garbage.
   var totalPoints = 0;
   for (var setIdx = 0; setIdx < this.datasets.length; ++setIdx) {
     totalPoints += this.datasets[setIdx].length;
@@ -241,7 +244,7 @@ DygraphLayout.prototype._evaluateLineCharts = function() {
       // Range from 0-1 where 0 represents top and 1 represents bottom
       var yNormal = DygraphLayout._calcYNormal(axis, yValue);
 
-      if (connectSeparated && item[1] === null) {
+      if (connectSeparated && yValue === null) {
         yValue = null;
       }
       this.points[i] = {