Commit aed8cd3c authored by olau@iola.dk's avatar olau@iola.dk

Fixed a couple of things related to the crosshair

git-svn-id: https://flot.googlecode.com/svn/trunk@120 1e0a6537-2640-0410-bfb7-f154510ff394
parent f4de9382
...@@ -96,7 +96,6 @@ ...@@ -96,7 +96,6 @@
}, },
crosshair: { crosshair: {
mode: null, // one of null, "x", "y" or "xy", mode: null, // one of null, "x", "y" or "xy",
extendBeyondGrid: null,
color: "#aa0000" color: "#aa0000"
}, },
shadowSize: 4 shadowSize: 4
...@@ -753,7 +752,7 @@ ...@@ -753,7 +752,7 @@
axis.labelHeight = 0; axis.labelHeight = 0;
if (labels.length > 0) { if (labels.length > 0) {
var dummyDiv = $('<div style="position:absolute;top:-10000px;width:10000px;font-size:smaller">' var dummyDiv = $('<div style="position:absolute;top:-10000px;width:10000px;font-size:smaller">'
+ labels.join("") + '<div style="clear:left"></div></div>').prependTo(target); + labels.join("") + '<div style="clear:left"></div></div>').appendTo(target);
axis.labelHeight = dummyDiv.height(); axis.labelHeight = dummyDiv.height();
dummyDiv.remove(); dummyDiv.remove();
} }
...@@ -772,7 +771,7 @@ ...@@ -772,7 +771,7 @@
if (labels.length > 0) { if (labels.length > 0) {
var dummyDiv = $('<div style="position:absolute;top:-10000px;font-size:smaller">' var dummyDiv = $('<div style="position:absolute;top:-10000px;font-size:smaller">'
+ labels.join("") + '</div>').prependTo(target); + labels.join("") + '</div>').appendTo(target);
if (axis.labelWidth == null) if (axis.labelWidth == null)
axis.labelWidth = dummyDiv.width(); axis.labelWidth = dummyDiv.width();
if (axis.labelHeight == null) if (axis.labelHeight == null)
...@@ -1021,7 +1020,7 @@ ...@@ -1021,7 +1020,7 @@
html += '</div>'; html += '</div>';
target.prepend(html); target.append(html);
} }
function drawSeries(series) { function drawSeries(series) {
...@@ -1642,14 +1641,17 @@ ...@@ -1642,14 +1641,17 @@
function (s) { return s["hoverable"] != false; }); function (s) { return s["hoverable"] != false; });
if (options.crosshair.mode != null) { if (options.crosshair.mode != null) {
if (!selection.active) {
setPositionFromEvent(crosshair.pos, lastMousePos); setPositionFromEvent(crosshair.pos, lastMousePos);
triggerRedrawOverlay(); triggerRedrawOverlay();
} }
else
crosshair.pos.x = -1; // hide the crosshair while selecting
}
if (selection.active) { if (selection.active) {
target.trigger("plotselecting", [ selectionIsSane() ? getSelectionForEvent() : null ]); target.trigger("plotselecting", [ selectionIsSane() ? getSelectionForEvent() : null ]);
crosshair.pos.x = -1; // hide the crosshair while selecting
updateSelection(lastMousePos); updateSelection(lastMousePos);
} }
} }
...@@ -1792,17 +1794,16 @@ ...@@ -1792,17 +1794,16 @@
octx.strokeStyle = parseColor(options.crosshair.color).scale(null, null, null, 0.8).toString(); octx.strokeStyle = parseColor(options.crosshair.color).scale(null, null, null, 0.8).toString();
octx.lineWidth = 1; octx.lineWidth = 1;
ctx.lineJoin = "round"; ctx.lineJoin = "round";
var pos = crosshair.pos, var pos = crosshair.pos;
extend = options.crosshair.extendBeyondGrid;
octx.beginPath(); octx.beginPath();
if (options.crosshair.mode.indexOf("x") != -1) { if (options.crosshair.mode.indexOf("x") != -1) {
octx.moveTo(pos.x, extend ? -plotOffset.top : 0); octx.moveTo(pos.x, 0);
octx.lineTo(pos.x, extend ? canvasHeight - plotOffset.top : plotHeight); octx.lineTo(pos.x, plotHeight);
} }
if (options.crosshair.mode.indexOf("y") != -1) { if (options.crosshair.mode.indexOf("y") != -1) {
octx.moveTo(extend ? -plotOffset.left : 0, pos.y); octx.moveTo(0, pos.y);
octx.lineTo(extend ? canvasWidth - plotOffset.left : plotWidth, pos.y); octx.lineTo(plotWidth, pos.y);
} }
octx.stroke(); octx.stroke();
...@@ -2130,10 +2131,10 @@ ...@@ -2130,10 +2131,10 @@
}; };
this.normalize = function() { this.normalize = function() {
this.r = limit(parseInt(this.r), 0, 255); this.r = clamp(0, parseInt(this.r), 255);
this.g = limit(parseInt(this.g), 0, 255); this.g = clamp(0, parseInt(this.g), 255);
this.b = limit(parseInt(this.b), 0, 255); this.b = clamp(0, parseInt(this.b), 255);
this.a = limit(this.a, 0, 1); this.a = clamp(0, this.a, 1);
return this; return this;
}; };
......
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