From: Dan Vanderkam Date: Wed, 28 Dec 2016 17:24:57 +0000 (-0500) Subject: Drop for..of and polyfill X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=16fa9cc380fddc8adbec72796060c1b88af4b16e;p=dygraphs.git Drop for..of and polyfill --- diff --git a/src/dygraph.js b/src/dygraph.js index 68a7d61..c12bbec 100644 --- a/src/dygraph.js +++ b/src/dygraph.js @@ -43,10 +43,6 @@ */ -// Polyfills -import 'core-js/es6/symbol'; -import 'core-js/fn/symbol/iterator'; - import DygraphLayout from './dygraph-layout'; import DygraphCanvasRenderer from './dygraph-canvas'; import DygraphOptions from './dygraph-options'; @@ -1355,9 +1351,9 @@ Dygraph.prototype.resetZoom = function() { // TODO(danvk): merge this block w/ the code below. if (!animatedZooms) { this.dateWindow_ = null; - for (const axis of this.axes_) { + this.axes_.forEach(axis => { if (axis.valueRange) delete axis.valueRange; - } + }); this.drawGraph_(); if (zoomCallback) { @@ -1380,9 +1376,9 @@ Dygraph.prototype.resetZoom = function() { this.doAnimatedZoom(oldWindow, newWindow, oldValueRanges, newValueRanges, () => { this.dateWindow_ = null; - for (const axis of this.axes_) { + this.axes_.forEach(axis => { if (axis.valueRange) delete axis.valueRange; - } + }); if (zoomCallback) { zoomCallback.call(this, minDate, maxDate, this.yAxisRanges()); } diff --git a/src/plugins/axes.js b/src/plugins/axes.js index 2d9e31f..a0169bc 100644 --- a/src/plugins/axes.js +++ b/src/plugins/axes.js @@ -164,8 +164,8 @@ axes.prototype.willDrawChart = function(e) { if (layout.yticks && layout.yticks.length > 0) { var num_axes = g.numAxes(); var getOptions = [makeOptionGetter('y'), makeOptionGetter('y2')]; - for (var tick of layout.yticks) { - if (tick.label === undefined) continue; // this tick only has a grid line. + layout.yticks.forEach(tick => { + if (tick.label === undefined) return; // this tick only has a grid line. x = area.x; var sgn = 1; var prec_axis = 'y1'; @@ -208,7 +208,7 @@ axes.prototype.willDrawChart = function(e) { label.style.width = getAxisOption('axisLabelWidth') + 'px'; containerDiv.appendChild(label); this.ylabels_.push(label); - } + }); // The lowest tick on the y-axis often overlaps with the leftmost // tick on the x-axis. Shift the bottom tick up a little bit to @@ -257,8 +257,8 @@ axes.prototype.willDrawChart = function(e) { if (g.getOptionForAxis('drawAxis', 'x')) { if (layout.xticks) { var getAxisOption = makeOptionGetter('x'); - for (var tick of layout.xticks) { - if (tick.label === undefined) continue; // this tick only has a grid line. + layout.xticks.forEach(tick => { + if (tick.label === undefined) return; // this tick only has a grid line. x = area.x + tick.pos * area.w; y = area.y + area.h; @@ -288,7 +288,7 @@ axes.prototype.willDrawChart = function(e) { label.style.width = getAxisOption('axisLabelWidth') + 'px'; containerDiv.appendChild(label); this.xlabels_.push(label); - } + }); } context.strokeStyle = g.getOptionForAxis('axisLineColor', 'x'); diff --git a/src/plugins/grid.js b/src/plugins/grid.js index 25126db..626ed94 100644 --- a/src/plugins/grid.js +++ b/src/plugins/grid.js @@ -15,7 +15,6 @@ Current bits of jankiness: "use strict"; - /** * Draws the gridlines, i.e. the gray horizontal & vertical lines running the * length of the chart. @@ -62,8 +61,8 @@ grid.prototype.willDrawChart = function(e) { ticks = layout.yticks; ctx.save(); // draw grids for the different y axes - for (var tick of ticks) { - if (!tick.has_tick) continue; + ticks.forEach(tick => { + if (!tick.has_tick) return; var axis = tick.axis; if (drawGrid[axis]) { ctx.save(); @@ -82,7 +81,7 @@ grid.prototype.willDrawChart = function(e) { ctx.restore(); } - } + }); ctx.restore(); } @@ -97,8 +96,8 @@ grid.prototype.willDrawChart = function(e) { } ctx.strokeStyle = g.getOptionForAxis('gridLineColor', 'x'); ctx.lineWidth = g.getOptionForAxis('gridLineWidth', 'x'); - for (var tick of ticks) { - if (!tick.has_tick) continue; + ticks.forEach(tick => { + if (!tick.has_tick) return; x = halfUp(area.x + tick.pos * area.w); y = halfDown(area.y + area.h); ctx.beginPath(); @@ -106,7 +105,7 @@ grid.prototype.willDrawChart = function(e) { ctx.lineTo(x, area.y); ctx.closePath(); ctx.stroke(); - } + }); if (stroking) { if (ctx.setLineDash) ctx.setLineDash([]); }