mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix(graph): Fix so that zoom works even when no data exists, fixes #5570
This commit is contained in:
35
public/vendor/flot/jquery.flot.selection.js
vendored
35
public/vendor/flot/jquery.flot.selection.js
vendored
@@ -94,11 +94,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() ]);
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,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();
|
||||
|
||||
@@ -127,13 +127,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;
|
||||
@@ -158,13 +158,22 @@ The plugin allso adds the following methods to the plot object:
|
||||
function getSelection() {
|
||||
if (!selectionIsSane())
|
||||
return null;
|
||||
|
||||
|
||||
if (!selection.show) return null;
|
||||
|
||||
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]);
|
||||
var axes = plot.getAxes();
|
||||
// look if no axis is used
|
||||
var noAxisInUse = true;
|
||||
$.each(axes, function (name, axis) {
|
||||
if (axis.used) {
|
||||
anyUsed = false;
|
||||
}
|
||||
})
|
||||
|
||||
$.each(axes, function (name, axis) {
|
||||
if (axis.used || noAxisInUse) {
|
||||
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) };
|
||||
}
|
||||
});
|
||||
@@ -252,10 +261,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();
|
||||
|
||||
@@ -333,11 +342,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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user