From 1d8cb8b3cffd8cb4e13ddf1dbc1abed8e0c9a0d8 Mon Sep 17 00:00:00 2001 From: "olau@iola.dk" Date: Tue, 23 Jun 2009 18:23:45 +0000 Subject: [PATCH] Fixed bug in line calculation with small values of shadow size and line width, reported by lepianiste (issue 179) git-svn-id: https://flot.googlecode.com/svn/trunk@172 1e0a6537-2640-0410-bfb7-f154510ff394 --- jquery.flot.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index 6b10024..105ed5e 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -1439,10 +1439,11 @@ // draw shadow as a thick and thin line with transparency ctx.lineWidth = sw; ctx.strokeStyle = "rgba(0,0,0,0.1)"; - var xoffset = 1; - plotLine(series.datapoints, xoffset, Math.sqrt((lw/2 + sw/2)*(lw/2 + sw/2) - xoffset*xoffset), series.xaxis, series.yaxis); + // position shadow at angle from the mid of line + var angle = Math.PI/18; + plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/2), Math.cos(angle) * (lw/2 + sw/2), series.xaxis, series.yaxis); ctx.lineWidth = sw/2; - plotLine(series.datapoints, xoffset, Math.sqrt((lw/2 + sw/4)*(lw/2 + sw/4) - xoffset*xoffset), series.xaxis, series.yaxis); + plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/4), Math.cos(angle) * (lw/2 + sw/4), series.xaxis, series.yaxis); } ctx.lineWidth = lw;