Generating traces for the webinterface'sgraphs optimized.

This commit is contained in:
Kai Lauterbach 2023-05-22 09:47:15 +02:00
parent e2ca6ceade
commit 4f3fa1a615
2 changed files with 42 additions and 108 deletions

View file

@ -95,34 +95,17 @@ var indexFloat = lowerIndex + timeDiff / ((upperTime[0] - lowerTime[0]) + ((uppe
if (indexFloat > index) { if (indexFloat > index) {
index = indexFloat; index = indexFloat;
} }
var trace1 = { var traces = [];
for (var i = 1; i <= 4; i++) {
var trace = {
x: time, x: time,
y: channel1, y: eval("channel" + i),
name: 'Channel 1', name: 'Channel ' + i,
type: 'scatter',
mode: 'lines+markers',
};
var trace2 = {
x: time,
y: channel2,
name: 'Channel 2',
type: 'scatter',
mode: 'lines+markers',
};
var trace3 = {
x: time,
y: channel3,
name: 'Channel 3',
type: 'scatter',
mode: 'lines+markers',
};
var trace4 = {
x: time,
y: channel4,
name: 'Channel 4',
type: 'scatter', type: 'scatter',
mode: 'lines+markers', mode: 'lines+markers',
}; };
traces.push(trace);
}
var layout = { var layout = {
title: 'Timing Control Data Blocks', title: 'Timing Control Data Blocks',
xaxis: { xaxis: {
@ -146,7 +129,7 @@ dash: 'dot'
} }
}] }]
}; };
Plotly.newPlot('plot_chart', [trace1, trace2, trace3, trace4], layout); Plotly.newPlot('plot_chart', traces, layout);
}); });
} }
setInterval(loadGraphData, 10000); setInterval(loadGraphData, 10000);
@ -206,34 +189,17 @@ var indexFloat = lowerIndex + timeDiff / ((upperTime[0] - lowerTime[0]) + ((uppe
if (indexFloat > index) { if (indexFloat > index) {
index = indexFloat; index = indexFloat;
} }
var trace1 = { var traces = [];
for (var i = 1; i <= 4; i++) {
var trace = {
x: time, x: time,
y: channel1, y: eval("channel" + i),
name: 'Channel 1', name: 'Channel ' + i,
type: 'scatter',
mode: 'lines+markers',
};
var trace2 = {
x: time,
y: channel2,
name: 'Channel 2',
type: 'scatter',
mode: 'lines+markers',
};
var trace3 = {
x: time,
y: channel3,
name: 'Channel 3',
type: 'scatter',
mode: 'lines+markers',
};
var trace4 = {
x: time,
y: channel4,
name: 'Channel 4',
type: 'scatter', type: 'scatter',
mode: 'lines+markers', mode: 'lines+markers',
}; };
traces.push(trace);
}
var layout = { var layout = {
title: 'Timing Control Data Blocks', title: 'Timing Control Data Blocks',
xaxis: { xaxis: {
@ -257,7 +223,7 @@ dash: 'dot'
} }
}] }]
}; };
Plotly.newPlot('tc_plot_chart', [trace1, trace2, trace3, trace4], layout); Plotly.newPlot('tc_plot_chart', traces, layout);
var plot = document.getElementById('tc_plot_chart'); var plot = document.getElementById('tc_plot_chart');
} }
function rgbaToHex(rgba) { function rgbaToHex(rgba) {

View file

@ -121,34 +121,18 @@ function loadGraphData() {
index = indexFloat; index = indexFloat;
} }
//console.log("index in graph >>>" + index); //console.log("index in graph >>>" + index);
var trace1 = { var traces = [];
x: time, for (var i = 1; i <= 4; i++) {
y: channel1, var trace = {
name: 'Channel 1', x: time,
type: 'scatter', y: eval("channel" + i),
mode: 'lines+markers', name: 'Channel ' + i,
}; type: 'scatter',
var trace2 = { mode: 'lines+markers',
x: time, };
y: channel2,
name: 'Channel 2', traces.push(trace);
type: 'scatter', }
mode: 'lines+markers',
};
var trace3 = {
x: time,
y: channel3,
name: 'Channel 3',
type: 'scatter',
mode: 'lines+markers',
};
var trace4 = {
x: time,
y: channel4,
name: 'Channel 4',
type: 'scatter',
mode: 'lines+markers',
};
var layout = { var layout = {
title: 'Timing Control Data Blocks', title: 'Timing Control Data Blocks',
xaxis: { xaxis: {
@ -172,7 +156,7 @@ function loadGraphData() {
} }
}] }]
}; };
Plotly.newPlot('plot_chart', [trace1, trace2, trace3, trace4], layout); Plotly.newPlot('plot_chart', traces, layout);
}); });
} }
setInterval(loadGraphData, 10000); setInterval(loadGraphData, 10000);
@ -246,34 +230,18 @@ function loadTCGraphData() {
index = indexFloat; index = indexFloat;
} }
//console.log("index in graph >>>" + index); //console.log("index in graph >>>" + index);
var trace1 = { var traces = [];
x: time, for (var i = 1; i <= 4; i++) {
y: channel1, var trace = {
name: 'Channel 1', x: time,
type: 'scatter', y: eval("channel" + i),
mode: 'lines+markers', name: 'Channel ' + i,
}; type: 'scatter',
var trace2 = { mode: 'lines+markers',
x: time, };
y: channel2,
name: 'Channel 2', traces.push(trace);
type: 'scatter', }
mode: 'lines+markers',
};
var trace3 = {
x: time,
y: channel3,
name: 'Channel 3',
type: 'scatter',
mode: 'lines+markers',
};
var trace4 = {
x: time,
y: channel4,
name: 'Channel 4',
type: 'scatter',
mode: 'lines+markers',
};
var layout = { var layout = {
title: 'Timing Control Data Blocks', title: 'Timing Control Data Blocks',
xaxis: { xaxis: {
@ -297,7 +265,7 @@ function loadTCGraphData() {
} }
}] }]
}; };
Plotly.newPlot('tc_plot_chart', [trace1, trace2, trace3, trace4], layout); Plotly.newPlot('tc_plot_chart', traces, layout);
var plot = document.getElementById('tc_plot_chart'); // Das HTML-Div-Element, in dem der Plot angezeigt wird var plot = document.getElementById('tc_plot_chart'); // Das HTML-Div-Element, in dem der Plot angezeigt wird
} }