X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=dygraph-layout.js;h=28f1f285f0ed5fb307838b19050438a7f10b9651;hb=947ab5a6dd8278d85ff74e42151797cf8b9dbaf4;hp=4f8656e8b5801f1bdda09622a9993e006caf4a23;hpb=ecf9b464f6a10e3b99f22132ec300e2f83584aaf;p=dygraphs.git diff --git a/dygraph-layout.js b/dygraph-layout.js index 4f8656e..28f1f28 100644 --- a/dygraph-layout.js +++ b/dygraph-layout.js @@ -129,23 +129,19 @@ DygraphLayout.prototype._evaluateLimits = function() { DygraphLayout.prototype._evaluateLineCharts = function() { // add all the rects this.points = new Array(); + // An array to keep track of how many points will be drawn for each set. + // This will allow for the canvas renderer to not have to check every point + // for every data set since the points are added in order of the sets in + // datasets. + this.setPointsLengths = new Array(); + for (var setName in this.datasets) { if (!this.datasets.hasOwnProperty(setName)) continue; var dataset = this.datasets[setName]; var axis = this.dygraph_.axisPropertiesForSeries(setName); - var graphWidth = this.dygraph_.width_; - var graphHeight = this.dygraph_.height_; - var prevXPx = NaN; - var prevYPx = NaN; - var currXPx = NaN; - var currYPx = NaN; - - // Ignore the pixel skipping optimization if there are error bars. - var skip_opt = (this.attr_("errorBars") || - this.attr_("customBars") || - this.annotations.length > 0); + var setPointsLength = 0; for (var j = 0; j < dataset.length; j++) { var item = dataset[j]; @@ -161,27 +157,18 @@ DygraphLayout.prototype._evaluateLineCharts = function() { } else { yNormal = 1.0 - ((yValue - axis.minyval) * axis.yscale); } - - // Current pixel coordinates that the data point would fill. - currXPx = Math.round(xNormal * graphWidth); - currYPx = Math.round(yNormal * graphHeight); - - // Skip over pushing points that lie on the same pixel. - // TODO(antrob): optimize this for graphs with error bars. - if (skip_opt || prevXPx != currXPx || prevYPx != currYPx) { - var point = { - // TODO(danvk): here - x: xNormal, - y: yNormal, - xval: xValue, - yval: yValue, - name: setName - }; - this.points.push(point); - } - prevXPx = currXPx; - prevYPx = currYPx; + var point = { + // TODO(danvk): here + x: xNormal, + y: yNormal, + xval: xValue, + yval: yValue, + name: setName + }; + this.points.push(point); + setPointsLength += 1; } + this.setPointsLengths.push(setPointsLength); } };