X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=src%2Fplugins%2Fgrid.js;h=16a83a2b8658f7eb4b0e7c71ed6005a563f423d4;hb=ce31caf22475e3e1fd6d9fea192d61ff4fcd7fac;hp=db1b42d15818242de2375af912f75a6e2f6f6e96;hpb=3123ca57f71d145bb5bcc4a2f754d3dff3225346;p=dygraphs.git diff --git a/src/plugins/grid.js b/src/plugins/grid.js index db1b42d..16a83a2 100644 --- a/src/plugins/grid.js +++ b/src/plugins/grid.js @@ -5,8 +5,6 @@ */ /*global Dygraph:false */ -Dygraph.Plugins.Grid = (function() { - /* Current bits of jankiness: @@ -67,8 +65,9 @@ grid.prototype.willDrawChart = function(e) { for (i = 0; i < ticks.length; i++) { var axis = ticks[i][0]; if(drawGrid[axis]) { + ctx.save(); if (stroking[axis]) { - ctx.installPattern(strokePattern[axis]); + if (ctx.setLineDash) ctx.setLineDash(strokePattern[axis]); } ctx.strokeStyle = strokeStyles[axis]; ctx.lineWidth = lineWidths[axis]; @@ -78,12 +77,9 @@ grid.prototype.willDrawChart = function(e) { ctx.beginPath(); ctx.moveTo(x, y); ctx.lineTo(x + area.w, y); - ctx.closePath(); ctx.stroke(); - if (stroking[axis]) { - ctx.uninstallPattern(); - } + ctx.restore(); } } ctx.restore(); @@ -96,7 +92,7 @@ grid.prototype.willDrawChart = function(e) { var strokePattern = g.getOptionForAxis('gridLinePattern', 'x'); var stroking = strokePattern && (strokePattern.length >= 2); if (stroking) { - ctx.installPattern(strokePattern); + if (ctx.setLineDash) ctx.setLineDash(strokePattern); } ctx.strokeStyle = g.getOptionForAxis('gridLineColor', 'x'); ctx.lineWidth = g.getOptionForAxis('gridLineWidth', 'x'); @@ -110,7 +106,7 @@ grid.prototype.willDrawChart = function(e) { ctx.stroke(); } if (stroking) { - ctx.uninstallPattern(); + if (ctx.setLineDash) ctx.setLineDash([]); } ctx.restore(); } @@ -119,6 +115,4 @@ grid.prototype.willDrawChart = function(e) { grid.prototype.destroy = function() { }; -return grid; - -})(); +export default grid;