From 59767e65b076cf902dc6b4eff8518245a8eca38c Mon Sep 17 00:00:00 2001 From: Jeff Tian Date: Fri, 6 Dec 2013 22:06:52 +0800 Subject: [PATCH] Allow 0 sized markings. --- jquery.flot.js | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index f0035dc..3329831 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -2417,35 +2417,33 @@ Licensed under the MIT license. yrange.from = Math.max(yrange.from, yrange.axis.min); yrange.to = Math.min(yrange.to, yrange.axis.max); - if (xrange.from === xrange.to && yrange.from === yrange.to) { - return; - } - // then draw xrange.from = xrange.axis.p2c(xrange.from); xrange.to = xrange.axis.p2c(xrange.to); yrange.from = yrange.axis.p2c(yrange.from); yrange.to = yrange.axis.p2c(yrange.to); - if (xrange.from === xrange.to || yrange.from === yrange.to) { - // draw line - ctx.beginPath(); - ctx.strokeStyle = m.color || options.grid.markingsColor; - ctx.lineWidth = m.lineWidth || options.grid.markingsLineWidth; - ctx.moveTo(xrange.from, yrange.from); - ctx.lineTo(xrange.to, yrange.to); - ctx.stroke(); - } else { - // fill area - ctx.fillStyle = m.color || options.grid.markingsColor; - - if (!m.rounded) { - ctx.fillRect(xrange.from, yrange.to, - xrange.to - xrange.from, - yrange.from - yrange.to); + if (xrange.from !== xrange.to || xrange.from !== yrange.to) { + if (xrange.from === xrange.to || yrange.from === yrange.to) { + // draw line + ctx.beginPath(); + ctx.strokeStyle = m.color || options.grid.markingsColor; + ctx.lineWidth = m.lineWidth || options.grid.markingsLineWidth; + ctx.moveTo(xrange.from, yrange.from); + ctx.lineTo(xrange.to, yrange.to); + ctx.stroke(); } else { - roundRect(ctx, xrange.from, yrange.to, xrange.to - xrange.from, yrange.from - yrange.to, m.rounded); - ctx.fill(); + // fill area + ctx.fillStyle = m.color || options.grid.markingsColor; + + if (!m.rounded) { + ctx.fillRect(xrange.from, yrange.to, + xrange.to - xrange.from, + yrange.from - yrange.to); + } else { + roundRect(ctx, xrange.from, yrange.to, xrange.to - xrange.from, yrange.from - yrange.to, m.rounded); + ctx.fill(); + } } }