X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=src%2Fplugins%2Fgrid.js;h=16a83a2b8658f7eb4b0e7c71ed6005a563f423d4;hb=e8c70e4e0f4c124a2c68eb43d6ec4e781d1bf810;hp=bf6e3fecfd41df0d704707d5471780f5740ea4d2;hpb=6ecc073934b76e5076f917112a24ff7094857730;p=dygraphs.git diff --git a/src/plugins/grid.js b/src/plugins/grid.js index bf6e3fe..16a83a2 100644 --- a/src/plugins/grid.js +++ b/src/plugins/grid.js @@ -65,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]; @@ -76,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(); @@ -94,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'); @@ -108,7 +106,7 @@ grid.prototype.willDrawChart = function(e) { ctx.stroke(); } if (stroking) { - ctx.uninstallPattern(); + if (ctx.setLineDash) ctx.setLineDash([]); } ctx.restore(); }