diff --git a/src/jquery.flot.js b/src/jquery.flot.js index 0b9d4ca..30e4e0d 100644 --- a/src/jquery.flot.js +++ b/src/jquery.flot.js @@ -1593,14 +1593,14 @@ Licensed under the MIT license. var delta; switch (s.bars.align) { - case "left": - delta = 0; - break; - case "right": - delta = -s.bars.barWidth; - break; - default: - delta = -s.bars.barWidth / 2; + case "left": + delta = 0; + break; + case "right": + delta = -s.bars.barWidth; + break; + default: + delta = -s.bars.barWidth / 2; } if (s.bars.horizontal) { @@ -1634,8 +1634,8 @@ Licensed under the MIT license. // padding messes up the positioning placeholder.css("padding", 0) .children().filter(function() { - return !$(this).hasClass("flot-overlay") && !$(this).hasClass("flot-base"); - }).remove(); + return !$(this).hasClass("flot-overlay") && !$(this).hasClass("flot-base"); + }).remove(); if (placeholder.css("position") === "static") { @@ -2271,6 +2271,7 @@ Licensed under the MIT license. if (grid.show && grid.aboveData) { drawGrid(); } + drawSecondMarkings(); surface.render(); @@ -2326,6 +2327,52 @@ Licensed under the MIT license. ctx.restore(); } + function drawSecondMarkings() { + var i, axes, bw, bc; + + ctx.save(); + ctx.translate(plotOffset.left, plotOffset.top); + + var markingLayer = "flot-markings"; + surface.removeText(markingLayer); + + // process markings + var markingsAboveGraph = [], + markings = options.grid.markings; + + if (markings) { + if ($.isFunction(markings)) { + axes = plot.getAxes(); + + // xmin etc. is backwards compatibility, to be + // removed in the future + axes.xmin = axes.xaxis.min; + axes.xmax = axes.xaxis.max; + axes.ymin = axes.yaxis.min; + axes.ymax = axes.yaxis.max; + + markings = markings(axes); + } + + for (i = 0; i < markings.length; ++i) { + var m = markings[i]; + + if (m.aboveGraph) { + markingsAboveGraph.push(m); + } + } + } + + // draw the ticks + axes = allAxes(); + bw = options.grid.borderWidth; + + drawMarkings(markingsAboveGraph, markingLayer); + + + ctx.restore(); + } + function drawGrid() { var i, axes, bw, bc; @@ -2359,7 +2406,7 @@ Licensed under the MIT license. if (m.aboveGrid) { markingsAboveGrid.push(m); - } else { + } else if (!m.aboveGraph) { markingsUnderGrid.push(m); } } @@ -2621,23 +2668,23 @@ Licensed under the MIT license. if (!!m.textAlign) { switch (m.textAlign.toLowerCase()) { - case "right": - xPos = xrange.to + plotOffset.left; - break; - case "center": - xPos = (xrange.from + plotOffset.left + xrange.to + plotOffset.left) / 2; - break; + case "right": + xPos = xrange.to + plotOffset.left; + break; + case "center": + xPos = (xrange.from + plotOffset.left + xrange.to + plotOffset.left) / 2; + break; } } if (!!m.textBaseline) { switch (m.textBaseline.toLowerCase()) { - case "bottom": - yPos = (yrange.from + plotOffset.top); - break; - case "middle": - yPos = (yrange.from + plotOffset.top + yrange.to + plotOffset.top) / 2; - break; + case "bottom": + yPos = (yrange.from + plotOffset.top); + break; + case "middle": + yPos = (yrange.from + plotOffset.top + yrange.to + plotOffset.top) / 2; + break; } } @@ -3070,18 +3117,18 @@ Licensed under the MIT license. ctx.lineWidth = w; ctx.strokeStyle = "rgba(0,0,0,0.1)"; plotPoints(series.datapoints, radius, null, w + w / 2, true, - series.xaxis, series.yaxis, symbol); + series.xaxis, series.yaxis, symbol); ctx.strokeStyle = "rgba(0,0,0,0.2)"; plotPoints(series.datapoints, radius, null, w / 2, true, - series.xaxis, series.yaxis, symbol); + series.xaxis, series.yaxis, symbol); } ctx.lineWidth = lw; ctx.strokeStyle = series.points.strokeColor || series.color; plotPoints(series.datapoints, radius, - getFillStyle(series.points, series.color), 0, false, - series.xaxis, series.yaxis, symbol); + getFillStyle(series.points, series.color), 0, false, + series.xaxis, series.yaxis, symbol); ctx.restore(); } @@ -3216,14 +3263,14 @@ Licensed under the MIT license. var barLeft; switch (series.bars.align) { - case "left": - barLeft = 0; - break; - case "right": - barLeft = -series.bars.barWidth; - break; - default: - barLeft = -series.bars.barWidth / 2; + case "left": + barLeft = 0; + break; + case "right": + barLeft = -series.bars.barWidth; + break; + default: + barLeft = -series.bars.barWidth / 2; } var fillStyleCallback = series.bars.fill ? function(bottom, top) { return getFillStyle(series.bars, series.color, bottom, top); } : null; @@ -3314,16 +3361,16 @@ Licensed under the MIT license. } var colorbox = $("
").css({ - "width": "4px", - "height": 0, - "border": "5px solid " + entry.color, - "overflow": "hidden" - }), - - borderbox = $("").css({ - "border": "1px solid " + options.legend.labelBoxBorderColor, - "padding": "1px" - }); + "width": "4px", + "height": 0, + "border": "5px solid " + entry.color, + "overflow": "hidden" + }), + + borderbox = $("").css({ + "border": "1px solid " + options.legend.labelBoxBorderColor, + "padding": "1px" + }); rowBuffer.append( $("