From 05d3a016507c294fa90a7176f1b6e604d25d1647 Mon Sep 17 00:00:00 2001 From: Manuel Luis SanmartĂ­n Rozada Date: Fri, 3 Apr 2015 23:06:54 +0200 Subject: jsrrdgraph: Use dash lines in canvas for the grid. --- js/RrdGfxCanvas.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/js/RrdGfxCanvas.js b/js/RrdGfxCanvas.js index 78b8adf..110c032 100644 --- a/js/RrdGfxCanvas.js +++ b/js/RrdGfxCanvas.js @@ -95,8 +95,21 @@ RrdGfxCanvas.prototype.dashed_line = function (X0, Y0, X1, Y1, width, color, das this.ctx.save(); this.ctx.lineWidth = width; this.ctx.strokeStyle = color; - + this.ctx.setLineDash([ dash_on, dash_off ]); + this.ctx.lineDashOffset = dash_on; this.ctx.beginPath(); + + if (Y0 === Y1) { + Y0 += 0.5; + Y1 += 0.5; + } else if (X0 === X1) { + X0 += 0.5; + X1 += 0.5; + } + + this.ctx.moveTo(X0, Y0); + this.ctx.lineTo(X1, Y1); +/* if (Y0 === Y1) { Y0 += 0.5; Y1 += 0.5; @@ -142,6 +155,7 @@ RrdGfxCanvas.prototype.dashed_line = function (X0, Y0, X1, Y1, width, color, das this.ctx.moveTo(X0, Y0); this.ctx.lineTo(X1, Y1); } +*/ this.ctx.stroke(); this.ctx.restore(); }; -- cgit v1.1