Source
* actual data point and adds N pixels to all sides. Then looks if mouse is in calculated area. N is calculated by
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* JQuery class that initializes interactivity for SVG graph.
*
* Supported options:
* - SBox - time range selector;
* - show_problems - show problems in hintbox when mouse is moved over the problem zone;
* - min_period - min period in seconds that must be s-boxed to change the data in dashboard timeselector.
*/
(function ($) {
"use strict";
// Makes SBox selection cancelable pressing Esc.
function sBoxKeyboardInteraction(e) {
if (e.keyCode == 27) {
destroySBox(e, e.data.graph);
}
}
// Disable text selection in document when move mouse pressed cursor.
function disableSelect(e) {
e.preventDefault();
}
// Cancel SBox and unset its variables.
function destroySBox(e, graph) {
var graph = graph || e.data.graph,
data = graph.data('options');
if (data) {
if (!data.isHintBoxFrozen && !data.isTriggerHintBoxFrozen) {
graph.data('widget')._resumeUpdating();
}
jQuery('.svg-graph-selection', graph).attr({'width': 0, 'height': 0});
jQuery('.svg-graph-selection-text', graph).text('');
graph.data('options').boxing = false;
}
dropDocumentListeners(e, graph);
}
/**
* Function removes SBox related $(document) event listeners:
* - if no other widget have active SBox;
* - to avoid another call of destroySBox on 'mouseup' (in case if user has pressed ESC).
*/
function dropDocumentListeners(e, graph) {
let widgets_boxing = 0; // Number of widgets with active SBox.