Commit 9b3ef35d authored by olau@iola.dk's avatar olau@iola.dk

Make sure measurement labels are deleted, round widths of labels, fix

recently introduced border margin calculation bug


git-svn-id: https://flot.googlecode.com/svn/trunk@259 1e0a6537-2640-0410-bfb7-f154510ff394
parent 81553910
...@@ -804,7 +804,7 @@ ...@@ -804,7 +804,7 @@
// them, we don't need the exact figures and the // them, we don't need the exact figures and the
// fixed-size box content is easy to center // fixed-size box content is easy to center
if (w == null) if (w == null)
w = canvasWidth / (ticks.length > 0 ? ticks.length : 1); w = Math.floor(canvasWidth / (ticks.length > 0 ? ticks.length : 1));
// measure x label heights // measure x label heights
if (h == null) { if (h == null) {
...@@ -839,6 +839,7 @@ ...@@ -839,6 +839,7 @@
w = dummyDiv.children().width(); w = dummyDiv.children().width();
if (h == null) if (h == null)
h = dummyDiv.find("div.tickLabel").height(); h = dummyDiv.find("div.tickLabel").height();
dummyDiv.remove();
} }
} }
...@@ -968,17 +969,19 @@ ...@@ -968,17 +969,19 @@
// make sure we've got enough space for things that // make sure we've got enough space for things that
// might stick out // might stick out
var maxOutset = options.grid.borderWidth; var maxOutset = 0;
for (var i = 0; i < series.length; ++i) for (var i = 0; i < series.length; ++i)
maxOutset = Math.max(maxOutset, 2 * (series[i].points.radius + series[i].points.lineWidth/2)); maxOutset = Math.max(maxOutset, 2 * (series[i].points.radius + series[i].points.lineWidth/2));
for (var a in plotOffset) for (var a in plotOffset) {
plotOffset[a] += options.grid.borderWidth;
plotOffset[a] = Math.max(maxOutset, plotOffset[a]); plotOffset[a] = Math.max(maxOutset, plotOffset[a]);
}
} }
plotWidth = canvasWidth - plotOffset.left - plotOffset.right; plotWidth = canvasWidth - plotOffset.left - plotOffset.right;
plotHeight = canvasHeight - plotOffset.bottom - plotOffset.top; plotHeight = canvasHeight - plotOffset.bottom - plotOffset.top;
// now we got the proper plotWidth/Height, we can compute the scaling // now we got the proper plotWidth/Height, we can compute the scaling
for (k = 0; k < axes.length; ++k) for (k = 0; k < axes.length; ++k)
setTransformationHelpers(axes[k]); setTransformationHelpers(axes[k]);
...@@ -1495,17 +1498,17 @@ ...@@ -1495,17 +1498,17 @@
// find the edges // find the edges
if (axis.direction == "x") { if (axis.direction == "x") {
x = 0; x = 0;
if (axis.position == "bottom") if (t == "full")
y = box.top - plotOffset.top; y = (axis.position == "top" ? 0 : plotHeight);
else else
y = box.top - plotOffset.top + box.height; y = box.top - plotOffset.top + (axis.position == "top" ? box.height : 0);
} }
else { else {
y = 0; y = 0;
if (axis.position == "left") if (t == "full")
x = box.left - plotOffset.left + box.width; x = (axis.position == "left" ? 0 : plotWidth);
else else
x = box.left - plotOffset.left; x = box.left - plotOffset.left + (axis.position == "left" ? box.width : 0);
} }
// draw tick bar // draw tick bar
...@@ -1516,12 +1519,12 @@ ...@@ -1516,12 +1519,12 @@
xoff = plotWidth; xoff = plotWidth;
else else
yoff = plotHeight; yoff = plotHeight;
if (ctx.lineWidth == 1) { if (ctx.lineWidth == 1) {
x = Math.floor(x) + 0.5; x = Math.floor(x) + 0.5;
y = Math.floor(y) + 0.5; y = Math.floor(y) + 0.5;
} }
ctx.moveTo(x, y); ctx.moveTo(x, y);
ctx.lineTo(x + xoff, y + yoff); ctx.lineTo(x + xoff, y + yoff);
ctx.stroke(); ctx.stroke();
...@@ -1533,7 +1536,7 @@ ...@@ -1533,7 +1536,7 @@
var v = axis.ticks[i].v; var v = axis.ticks[i].v;
xoff = yoff = 0; xoff = yoff = 0;
if (v < axis.min || v > axis.max if (v < axis.min || v > axis.max
// skip those lying on the axes if we got a border // skip those lying on the axes if we got a border
|| (t == "full" && bw > 0 || (t == "full" && bw > 0
...@@ -1556,8 +1559,10 @@ ...@@ -1556,8 +1559,10 @@
} }
if (ctx.lineWidth == 1) { if (ctx.lineWidth == 1) {
x = Math.floor(x) + 0.5; if (axis.direction == "x")
y = Math.floor(y) + 0.5; x = Math.floor(x) + 0.5;
else
y = Math.floor(y) + 0.5;
} }
ctx.moveTo(x, y); ctx.moveTo(x, y);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment