Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added a new property to indicate the direction of selection on each axis #20

Open
wants to merge 2 commits into from

1 participant

@klim-iv

Added a new property to indicate the direction of selection on each axis, may be useful for zoom-in and zoom-out based on selection.

klim-iv and others added some commits
@klim-iv

Merged with last revision

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 21, 2011
  1. @klim-iv

    Added a new property to indicate the direction of selection on each a…

    klim-iv authored
    …xis, may be useful for zoom-in and zoom-out based on selection.
Commits on Sep 28, 2012
  1. Merge branch 'master' of git://github.com/flot/flot

    Igor Makarov authored
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 12 deletions.
  1. +12 −12 jquery.flot.selection.js
View
24 jquery.flot.selection.js
@@ -52,7 +52,7 @@ The plugin allso adds the following methods to the plot object:
are using multiple axes, you can specify the ranges on any of those,
e.g. as x2axis/x3axis/... instead of xaxis, the plugin picks the
first one it sees.
-
+
- clearSelection(preventEvent)
Clear the selection rectangle. Pass in true to avoid getting a
@@ -82,11 +82,11 @@ The plugin allso adds the following methods to the plot object:
var savedhandlers = {};
var mouseUpHandler = null;
-
+
function onMouseMove(e) {
if (selection.active) {
updateSelection(e);
-
+
plot.getPlaceholder().trigger("plotselecting", [ getSelection() ]);
}
}
@@ -94,7 +94,7 @@ The plugin allso adds the following methods to the plot object:
function onMouseDown(e) {
if (e.which != 1) // only accept left-click
return;
-
+
// cancel out any text selections
document.body.focus();
@@ -115,13 +115,13 @@ The plugin allso adds the following methods to the plot object:
// this is a bit silly, but we have to use a closure to be
// able to whack the same handler again
mouseUpHandler = function (e) { onMouseUp(e); };
-
+
$(document).one("mouseup", mouseUpHandler);
}
function onMouseUp(e) {
mouseUpHandler = null;
-
+
// revert drag stuff for old-school browsers
if (document.onselectstart !== undefined)
document.onselectstart = savedhandlers.onselectstart;
@@ -150,8 +150,8 @@ The plugin allso adds the following methods to the plot object:
var r = {}, c1 = selection.first, c2 = selection.second;
$.each(plot.getAxes(), function (name, axis) {
if (axis.used) {
- var p1 = axis.c2p(c1[axis.direction]), p2 = axis.c2p(c2[axis.direction]);
- r[name] = { from: Math.min(p1, p2), to: Math.max(p1, p2) };
+ var p1 = axis.c2p(c1[axis.direction]), p2 = axis.c2p(c2[axis.direction]);
+ r[name] = { from: Math.min(p1, p2), to: Math.max(p1, p2), growing: p1 <= p2 };
}
});
return r;
@@ -238,10 +238,10 @@ The plugin allso adds the following methods to the plot object:
from = to;
to = tmp;
}
-
+
return { from: from, to: to, axis: axis };
}
-
+
function setSelection(ranges, preventEvent) {
var axis, range, o = plot.getOptions();
@@ -319,11 +319,11 @@ The plugin allso adds the following methods to the plot object:
ctx.restore();
}
});
-
+
plot.hooks.shutdown.push(function (plot, eventHolder) {
eventHolder.unbind("mousemove", onMouseMove);
eventHolder.unbind("mousedown", onMouseDown);
-
+
if (mouseUpHandler)
$(document).unbind("mouseup", mouseUpHandler);
});
Something went wrong with that request. Please try again.