Sampling data (aggregateWindow) for responsitivity + fixed old values not shown bug + readme

This commit is contained in:
l_samenv
2024-07-26 10:00:28 +02:00
parent 676e7e4f10
commit dd422e89d8
5 changed files with 87 additions and 19 deletions

View File

@ -216,6 +216,8 @@ let graphs = (function (){
let minTime, maxTime; // the queried time range
let lastTime = 0; // time of most recent data point
let resolution = undefined;
let container = document.createElement('div');
container.classList.add("graphs-container");
@ -336,7 +338,11 @@ let graphs = (function (){
//let varlist = top_vars.concat(bottom_vars);
varlist = vars_array[gindex];
let graph_elm = graph_elm_array[gindex];
AJAX("http://" + hostPort + "/graph?time=" + minTime/1000 + "," + maxTime/1000 + "&variables=" + varlist + "&id=" + clientID).getJSON().then(function(data){
timeDeltaAxis = maxTime - minTime
setResolution(timeDeltaAxis)
AJAX("http://" + hostPort + "/graph?time=" + minTime/1000 + "," + maxTime/1000 + "&variables=" + varlist + "&interval=" + resolution + "&id=" + clientID).getJSON().then(function(data){
//console.log('Graph', block, data)
let graph = new Graph(gindex, graph_elm, "Time", block.unit, block.tag, type);
@ -492,7 +498,7 @@ let graphs = (function (){
/**
* Function called when the graph container is clicked
* Shows the legend, disable livemode, put a cursor then applies the changes
* Shows the legend, shows the go to now button, put a cursor then applies the changes
* If the click is located on the legend, brings it to the front
* @param {*} evt - The JS event triggered by the click
*/
@ -556,7 +562,11 @@ let graphs = (function (){
}else{
max = max/1000;
}
AJAX("http://" + hostPort + "/graph?time=" + min + ","+max+"&variables=" + variables() + "&id=" + clientID).getJSON().then(function(data){
timeDelta = currentMaxTime - currentMinTime
setResolution(timeDelta)
AJAX("http://" + hostPort + "/graph?time=" + min + ","+max+"&variables=" + variables() + "&interval=" + resolution + "&id=" + clientID).getJSON().then(function(data){
for(let key in data.graph){
let pdata = [];
for(let e of data.graph[key]){
@ -673,6 +683,14 @@ let graphs = (function (){
update();
}
/**
* Sets the resolution of the viewing window in seconds
* @param {*} timeDelta - The difference between the maximum time and the minimum time of the window
*/
function setResolution(timeDelta){
resolution = Math.ceil((timeDelta / container.getBoundingClientRect().width)/1000)
}
/**
* The function called when the viewing window is moved by the mouse.
*