Skip to content

Commit

Permalink
Use Ctrl Alt Z to toggle zoom (off by default)
Browse files Browse the repository at this point in the history
Use Ctrl Alt X to reset zoom
  • Loading branch information
jackyaz committed Mar 7, 2020
1 parent d3f7608 commit 8aa6440
Showing 1 changed file with 29 additions and 28 deletions.
57 changes: 29 additions & 28 deletions spdstats_www.asp
Expand Up @@ -177,38 +177,21 @@ var timeunitlist = ["hour","day","day"];
var intervallist = [24,7,30];
var colourlist = ["#fc8500","#42ecf5"];
var timer;
$(document).keydown(function(e){
if (e.ctrlKey) {
if(timer) return;
timer = setInterval(EnableZoom, 4);
}
});
$(document).keyup(function(e){
if (e.ctrlKey){
clearInterval(timer);
timer = null;
chartobj.options.plugins.zoom.zoom.enabled = false;
function keyHandler(e) {
console.log(e)
if (e.ctrlKey && e.shiftKey && e.keyCode == 90){
$(document).off("keydown");
ToggleZoom();
}
});
function EnableZoom(){
if(interfacelist != ""){
var interfacetextarray = interfacelist.split(',');
for(i = 0; i < metriclist.length; i++){
for (i2 = 0; i2 < chartlist.length; i2++) {
for (i3 = 0; i3 < interfacetextarray.length; i3++) {
var chartobj = window["LineChart"+metriclist[i]+chartlist[i2]+"_"+interfacetextarray[i3]];
if(typeof chartobj === 'undefined' || chartobj === null) { continue; }
chartobj.options.plugins.zoom.zoom.enabled = true;
}
}
}
else if (e.ctrlKey && e.shiftKey && e.keyCode == 88){
$(document).off("keydown");
ResetZoom();
}
}
$(document).keydown(function(e){keyHandler(e);});
$(document).keyup(function(e){$(document).keydown(function(e){keyHandler(e);});});
function Draw_Chart_NoData(txtchartname){
document.getElementById("divLineChart"+txtchartname).width="730";
document.getElementById("divLineChart"+txtchartname).height="300";
Expand Down Expand Up @@ -540,13 +523,31 @@ function ResetZoom(){
for(i = 0; i < metriclist.length; i++){
for (i2 = 0; i2 < chartlist.length; i2++) {
for (i3 = 0; i3 < interfacetextarray.length; i3++) {
var chartobj = window["LineChart"+metriclist[i]+chartlist[i2]+"_"+interfacetextarray[i3]];
if(typeof chartobj === 'undefined' || chartobj === null) { continue; }
window["LineChart"+metriclist[i]+chartlist[i2]+"_"+interfacetextarray[i3]].resetZoom();
}
}
}
}
}
function ToggleZoom(){
if(interfacelist != ""){
var interfacetextarray = interfacelist.split(',');
for(i = 0; i < metriclist.length; i++){
for (i2 = 0; i2 < chartlist.length; i2++) {
for (i3 = 0; i3 < interfacetextarray.length; i3++) {
var chartobj = window["LineChart"+metriclist[i]+chartlist[i2]+"_"+interfacetextarray[i3]];
if(typeof chartobj === 'undefined' || chartobj === null) { continue; }
chartobj.options.plugins.zoom.zoom.enabled = ! chartobj.options.plugins.zoom.zoom.enabled;
chartobj.update();
}
}
}
}
}
function applyRule() {
var action_script_tmp = "start_spdmerlin";
document.form.action_script.value = action_script_tmp;
Expand Down

0 comments on commit 8aa6440

Please sign in to comment.