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

Introduced a plotselecting event which is fired while doing a selection

git-svn-id: https://flot.googlecode.com/svn/trunk@114 1e0a6537-2640-0410-bfb7-f154510ff394
parent 6a7f952e
...@@ -1666,8 +1666,15 @@ ...@@ -1666,8 +1666,15 @@
if (options.grid.hoverable && !hoverTimeout) if (options.grid.hoverable && !hoverTimeout)
hoverTimeout = setTimeout(onHover, 100); hoverTimeout = setTimeout(onHover, 100);
if (selection.active) if (selection.active) {
var r = null;
if (selectionIsSane())
r = getSelectionForEvent();
target.trigger("plotselecting", [ r ]);
updateSelection(lastMousePos); updateSelection(lastMousePos);
}
} }
function onMouseDown(e) { function onMouseDown(e) {
...@@ -1861,8 +1868,8 @@ ...@@ -1861,8 +1868,8 @@
drawBar(point[0], point[1], barLeft, barLeft + series.bars.barWidth, drawBar(point[0], point[1], barLeft, barLeft + series.bars.barWidth,
0, true, series.xaxis, series.yaxis, octx); 0, true, series.xaxis, series.yaxis, octx);
} }
function triggerSelectedEvent() { function getSelectionForEvent() {
var x1 = Math.min(selection.first.x, selection.second.x), var x1 = Math.min(selection.first.x, selection.second.x),
x2 = Math.max(selection.first.x, selection.second.x), x2 = Math.max(selection.first.x, selection.second.x),
y1 = Math.max(selection.first.y, selection.second.y), y1 = Math.max(selection.first.y, selection.second.y),
...@@ -1877,6 +1884,11 @@ ...@@ -1877,6 +1884,11 @@
r.yaxis = { from: axes.yaxis.c2p(y1), to: axes.yaxis.c2p(y2) }; r.yaxis = { from: axes.yaxis.c2p(y1), to: axes.yaxis.c2p(y2) };
if (axes.y2axis.used) if (axes.y2axis.used)
r.y2axis = { from: axes.y2axis.c2p(y1), to: axes.y2axis.c2p(y2) }; r.y2axis = { from: axes.y2axis.c2p(y1), to: axes.y2axis.c2p(y2) };
return r;
}
function triggerSelectedEvent() {
var r = getSelectionForEvent();
target.trigger("plotselected", [ r ]); target.trigger("plotselected", [ r ]);
...@@ -1900,6 +1912,9 @@ ...@@ -1900,6 +1912,9 @@
triggerSelectedEvent(); triggerSelectedEvent();
clickIsMouseUp = true; clickIsMouseUp = true;
} }
else
// this counts as a clear
target.trigger("plotselecting", [ null ]);
return false; return false;
} }
...@@ -1928,11 +1943,11 @@ ...@@ -1928,11 +1943,11 @@
pos.y = Math.min(Math.max(0, pos.y), plotHeight); pos.y = Math.min(Math.max(0, pos.y), plotHeight);
} }
} }
function updateSelection(pos) { function updateSelection(pos) {
if (pos.pageX == null) if (pos.pageX == null)
return; return;
setSelectionPos(selection.second, pos); setSelectionPos(selection.second, pos);
if (selectionIsSane()) { if (selectionIsSane()) {
selection.show = true; selection.show = true;
......
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