Fixed a bug in processed_pastes graph

pull/63/head
Mokaddem 2016-07-14 10:31:47 +02:00
parent 594d2def35
commit 60552bca4d
1 changed files with 9 additions and 12 deletions

View File

@ -6,16 +6,16 @@ $(function() {
function getData() { function getData() {
if (data.length > 0){ if (data.length > 0){
curr_max = curr_max == data[0] ? Math.max.apply(null, data) : curr_max; var data_old = data[0];
data = data.slice(1); data = data.slice(1);
curr_max = curr_max == data_old ? Math.max.apply(null, data) : curr_max;
} }
while (data.length < totalPoints) { while (data.length < totalPoints) {
var y = (typeof window.paste_num_tabvar !== "undefined") ? window.paste_num_tabvar : 0; var y = (typeof window.paste_num_tabvar !== "undefined") ? parseInt(window.paste_num_tabvar) : 0;
curr_max = curr_max < y ? y : curr_max; curr_max = y > curr_max ? y : curr_max;
data.push(y); data.push(y);
} }
// Zip the generated y values with the x values // Zip the generated y values with the x values
var res = []; var res = [];
for (var i = 0; i < data.length; ++i) { for (var i = 0; i < data.length; ++i) {
@ -29,17 +29,15 @@ $(function() {
series: { shadowSize: 1 }, series: { shadowSize: 1 },
lines: { fill: true, fillColor: { colors: [ { opacity: 1 }, { opacity: 0.1 } ] }}, lines: { fill: true, fillColor: { colors: [ { opacity: 1 }, { opacity: 0.1 } ] }},
yaxis: { min: 0, max: 40 }, yaxis: { min: 0, max: 40 },
xaxis: { show: false }, colors: ["#a971ff"],
colors: ["#F4A506"],
grid: { grid: {
tickColor: "#dddddd", tickColor: "#dddddd",
borderWidth: 0 borderWidth: 0
}, },
}; };
var plot = $.plot("#realtimechart", [ getData() ], options); var plot = $.plot("#realtimechart", [ getData() ], options);
function update() { function update() {
console.log(curr_max);
plot.setData([getData()]); plot.setData([getData()]);
plot.getOptions().yaxes[0].max = curr_max; plot.getOptions().yaxes[0].max = curr_max;
plot.setupGrid(); plot.setupGrid();
@ -91,7 +89,6 @@ function create_log_table(obj_json) {
if (parsedmess[0] == "Global"){ if (parsedmess[0] == "Global"){
var paste_processed = parsedmess[4].split(" ")[2]; var paste_processed = parsedmess[4].split(" ")[2];
console.log(paste_processed)
window.paste_num_tabvar = paste_processed; window.paste_num_tabvar = paste_processed;
return; return;
} }