2016-05-26 08:57:33 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2016-05-26 13:47:45 +02:00
|
|
|
function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, water_mark, separator, legend_position, height, colors, hide_labels) {
|
2016-05-26 08:57:33 +02:00
|
|
|
var labels = labels.split(separator);
|
|
|
|
var data = values.split(separator);
|
|
|
|
if (colors != '') {
|
|
|
|
colors = colors.split(separator);
|
|
|
|
}
|
2016-05-30 18:47:05 +02:00
|
|
|
|
|
|
|
var pieRadius = 0.9;
|
2016-05-26 08:57:33 +02:00
|
|
|
|
|
|
|
var color = null;
|
|
|
|
for (var i = 0; i < nseries; i++) {
|
|
|
|
if (colors != '') {
|
|
|
|
color = colors[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
data[i] = { label: labels[i], data: parseFloat(data[i]), color: color}
|
|
|
|
}
|
|
|
|
|
|
|
|
var label_conf;
|
|
|
|
|
2016-05-26 13:47:45 +02:00
|
|
|
if (width < 400 || hide_labels) {
|
2016-05-26 08:57:33 +02:00
|
|
|
label_conf = {
|
|
|
|
show: false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
label_conf = {
|
|
|
|
show: true,
|
2016-05-30 18:47:05 +02:00
|
|
|
radius: pieRadius,
|
2016-05-26 08:57:33 +02:00
|
|
|
formatter: function(label, series) {
|
|
|
|
return '<div style="font-size:' + font_size + 'pt;' +
|
|
|
|
'text-align:center;padding:2px;color:white;">' +
|
|
|
|
label + '<br/>' + series.percent.toFixed(2) + '%</div>';
|
|
|
|
},
|
|
|
|
background: {
|
|
|
|
opacity: 0.5,
|
2016-11-21 19:16:48 +01:00
|
|
|
color: ''
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
var show_legend = true;
|
|
|
|
if (legend_position == 'hidden') {
|
|
|
|
show_legend = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var conf_pie = {
|
|
|
|
series: {
|
|
|
|
pie: {
|
|
|
|
show: true,
|
2016-05-30 18:47:05 +02:00
|
|
|
radius: pieRadius,
|
2016-05-26 08:57:33 +02:00
|
|
|
//offset: {top: -100},
|
|
|
|
label: label_conf,
|
|
|
|
//$label_str
|
|
|
|
}
|
|
|
|
},
|
|
|
|
legend: {
|
|
|
|
show: show_legend
|
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
hoverable: true,
|
|
|
|
clickable: true
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (width < 400) {
|
|
|
|
conf_pie.legend.labelFormatter = function(label, series) {
|
|
|
|
return label + " (" + series.percent.toFixed(2) + "%)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (legend_position) {
|
|
|
|
case 'bottom':
|
|
|
|
conf_pie.legend.position = "se";
|
|
|
|
break;
|
|
|
|
case 'right':
|
|
|
|
case 'inner':
|
|
|
|
conf_pie.legend.container = $('#'+graph_id+"_legend");
|
|
|
|
default:
|
|
|
|
//TODO FOR TOP OR LEFT OR RIGHT
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
var plot = $.plot($('#'+graph_id), data, conf_pie);
|
|
|
|
|
|
|
|
var legends = $('#'+graph_id+' .legendLabel');
|
2016-05-26 13:47:45 +02:00
|
|
|
legends.css('font-size', font_size+'pt');
|
2016-05-26 08:57:33 +02:00
|
|
|
|
|
|
|
// Events
|
|
|
|
$('#' + graph_id).bind('plothover', pieHover);
|
|
|
|
$('#' + graph_id).bind('plotclick', pieClick);
|
|
|
|
$('#' + graph_id).bind('mouseout',resetInteractivity);
|
2016-05-26 09:50:13 +02:00
|
|
|
$('#' + graph_id).css('margin-left', 'auto');
|
|
|
|
$('#' + graph_id).css('margin-right', 'auto');
|
2016-05-26 08:57:33 +02:00
|
|
|
|
2016-05-26 13:47:45 +02:00
|
|
|
function pieHover(event, pos, obj) {
|
|
|
|
if (!obj) return;
|
2016-05-26 08:57:33 +02:00
|
|
|
|
|
|
|
index = obj.seriesIndex;
|
2016-05-26 13:47:45 +02:00
|
|
|
legends.css('color', '#3F3F3D');
|
2016-11-21 19:16:48 +01:00
|
|
|
legends.eq(index).css('color', '');
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Reset styles
|
|
|
|
function resetInteractivity() {
|
2016-05-26 13:47:45 +02:00
|
|
|
legends.css('color', '#3F3F3D');
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (water_mark) {
|
|
|
|
set_watermark(graph_id, plot,
|
|
|
|
$('#watermark_image_' + graph_id).attr('src'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-08 15:44:36 +02:00
|
|
|
function pandoraFlotPieCustom(graph_id, values, labels, width,
|
|
|
|
font_size, font, water_mark, separator, legend_position, height,
|
2017-10-09 12:03:19 +02:00
|
|
|
colors,legend,background_color) {
|
|
|
|
|
2016-09-08 15:44:36 +02:00
|
|
|
font = font.split("/").pop().split(".").shift();
|
2016-05-26 08:57:33 +02:00
|
|
|
var labels = labels.split(separator);
|
|
|
|
var legend = legend.split(separator);
|
|
|
|
var data = values.split(separator);
|
|
|
|
var no_data = 0;
|
|
|
|
if (colors != '') {
|
|
|
|
colors = colors.split(separator);
|
|
|
|
}
|
|
|
|
var colors_data = ['#FC4444','#FFA631','#FAD403','#5BB6E5','#F2919D','#80BA27'];
|
|
|
|
var color = null;
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
|
if (colors != '') {
|
2017-08-23 17:21:15 +02:00
|
|
|
color = colors[i];
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
var datos = data[i];
|
|
|
|
data[i] = { label: labels[i], data: parseFloat(data[i]), color: color };
|
|
|
|
if (!datos)
|
|
|
|
no_data++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var label_conf;
|
|
|
|
var show_legend = true;
|
|
|
|
|
2017-03-28 13:01:40 +02:00
|
|
|
if((width <= 450)) {
|
2017-03-27 17:06:55 +02:00
|
|
|
show_legend = false;
|
|
|
|
label_conf = {
|
|
|
|
show: false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
label_conf = {
|
|
|
|
show: true,
|
|
|
|
radius: 0.75,
|
|
|
|
formatter: function(label, series) {
|
|
|
|
return '<div style="font-size:' + font_size + 'pt;' +
|
|
|
|
'text-align:center;padding:2px;color:white;">' +
|
|
|
|
series.percent.toFixed(2) + '%</div>';
|
|
|
|
},
|
|
|
|
background: {
|
|
|
|
opacity: 0.5,
|
|
|
|
color: ''
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
var conf_pie = {
|
|
|
|
series: {
|
|
|
|
pie: {
|
|
|
|
show: true,
|
|
|
|
radius: 3/4,
|
2017-03-07 09:46:40 +01:00
|
|
|
innerRadius: 0.4
|
|
|
|
//label: label_conf
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
legend: {
|
|
|
|
show: show_legend,
|
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
hoverable: true,
|
|
|
|
clickable: true
|
|
|
|
}
|
|
|
|
};
|
2017-03-27 17:06:55 +02:00
|
|
|
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
|
|
|
|
conf_pie.series.pie.label = {show: false};
|
|
|
|
}
|
2016-05-26 08:57:33 +02:00
|
|
|
|
|
|
|
var plot = $.plot($('#'+graph_id), data, conf_pie);
|
|
|
|
if (no_data == data.length) {
|
|
|
|
$('#'+graph_id+' .overlay').remove();
|
|
|
|
$('#'+graph_id+' .base').remove();
|
|
|
|
$('#'+graph_id).prepend("<img style='width:50%;' src='images/no_data_toshow.png' />");
|
|
|
|
|
|
|
|
}
|
|
|
|
var legends = $('#'+graph_id+' .legendLabel');
|
|
|
|
var j = 0;
|
|
|
|
legends.each(function () {
|
|
|
|
//$(this).css('width', $(this).width());
|
|
|
|
$(this).css('font-size', font_size+'pt');
|
2016-09-08 15:44:36 +02:00
|
|
|
$(this).removeClass("legendLabel");
|
|
|
|
$(this).addClass(font);
|
2016-05-26 08:57:33 +02:00
|
|
|
$(this).text(legend[j]);
|
|
|
|
j++;
|
|
|
|
});
|
|
|
|
|
|
|
|
if ($('input[name="custom_graph"]').val()) {
|
|
|
|
$('.legend>div').css('right',($('.legend>div').height()*-1));
|
|
|
|
$('.legend>table').css('right',($('.legend>div').height()*-1));
|
|
|
|
}
|
2017-08-21 13:53:50 +02:00
|
|
|
//$('.legend>table').css('border',"1px solid #E2E2E2");
|
2016-05-26 08:57:33 +02:00
|
|
|
|
2017-12-01 13:32:50 +01:00
|
|
|
if(background_color == 'transparent') {
|
2017-10-09 12:03:19 +02:00
|
|
|
$('.legend>table').css('background-color',"");
|
|
|
|
$('.legend>div').css('background-color',"");
|
|
|
|
$('.legend>table').css('color',"#aaa");
|
2017-12-01 13:32:50 +01:00
|
|
|
} else if (background_color == 'white') {
|
2017-10-09 12:03:19 +02:00
|
|
|
$('.legend>table').css('background-color',"white");
|
|
|
|
$('.legend>table').css('color',"black");
|
2017-12-01 13:32:50 +01:00
|
|
|
} else if (background_color == 'black') {
|
2017-10-09 12:03:19 +02:00
|
|
|
$('.legend>table').css('background-color',"black");
|
|
|
|
$('.legend>table').css('color',"#aaa");
|
|
|
|
}
|
|
|
|
|
2017-12-01 13:32:50 +01:00
|
|
|
$('.legend').hover(function() {
|
2017-10-09 12:03:19 +02:00
|
|
|
return false;
|
|
|
|
});
|
2016-05-26 08:57:33 +02:00
|
|
|
|
|
|
|
var pielegends = $('#'+graph_id+' .pieLabelBackground');
|
|
|
|
pielegends.each(function () {
|
2017-03-27 17:06:55 +02:00
|
|
|
$(this).css('transform', "rotate(-35deg)").css('color', 'black');
|
2016-05-26 08:57:33 +02:00
|
|
|
});
|
|
|
|
var labelpielegends = $('#'+graph_id+' .pieLabel');
|
|
|
|
labelpielegends.each(function () {
|
2017-03-27 17:06:55 +02:00
|
|
|
$(this).css('transform', "rotate(-35deg)").css('color', 'black');
|
2016-05-26 08:57:33 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
// Events
|
|
|
|
$('#' + graph_id).bind('plothover', pieHover);
|
|
|
|
$('#' + graph_id).bind('plotclick', Clickpie);
|
2017-03-27 17:06:55 +02:00
|
|
|
$('#' + graph_id).bind('mouseout', resetInteractivity);
|
2016-05-26 09:50:13 +02:00
|
|
|
$('#' + graph_id).css('margin-left', 'auto');
|
|
|
|
$('#' + graph_id).css('margin-right', 'auto');
|
2016-05-26 08:57:33 +02:00
|
|
|
|
2016-05-26 13:47:45 +02:00
|
|
|
function pieHover(event, pos, obj) {
|
|
|
|
if (!obj) return;
|
2016-05-26 08:57:33 +02:00
|
|
|
|
|
|
|
index = obj.seriesIndex;
|
2016-05-26 13:47:45 +02:00
|
|
|
legends.css('color', '#3F3F3D');
|
2016-11-21 19:16:48 +01:00
|
|
|
legends.eq(index).css('color', '');
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
|
2016-05-26 13:47:45 +02:00
|
|
|
function Clickpie(event, pos, obj) {
|
|
|
|
if (!obj) return;
|
2016-05-26 08:57:33 +02:00
|
|
|
percent = parseFloat(obj.series.percent).toFixed(2);
|
|
|
|
valor = parseFloat(obj.series.data[0][1]);
|
|
|
|
|
|
|
|
if (valor > 1000000){
|
|
|
|
value = Math.round((valor / 1000000)*100)/100;
|
|
|
|
value = value + "M";
|
|
|
|
}else{ if (valor > 1000) {
|
|
|
|
value = Math.round((valor / 1000)*100)/100;
|
|
|
|
value = value + "K";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
value = valor;
|
|
|
|
}
|
|
|
|
|
|
|
|
alert(''+obj.series.label+': '+ value +' ('+percent+'%)');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reset styles
|
|
|
|
function resetInteractivity() {
|
|
|
|
legends.each(function () {
|
|
|
|
// fix the widths so they don't jump around
|
2016-05-26 13:47:45 +02:00
|
|
|
$(this).css('color', '#3F3F3D');
|
2016-05-26 08:57:33 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (water_mark) {
|
|
|
|
set_watermark(graph_id, plot,
|
|
|
|
$('#watermark_image_' + graph_id).attr('src'));
|
|
|
|
}
|
2017-08-21 13:53:50 +02:00
|
|
|
|
|
|
|
window.onresize = function(event) {
|
|
|
|
$.plot($('#' + graph_id), data, conf_pie);
|
|
|
|
if (no_data == data.length) {
|
|
|
|
$('#'+graph_id+' .overlay').remove();
|
|
|
|
$('#'+graph_id+' .base').remove();
|
|
|
|
$('#'+graph_id).prepend("<img style='width:50%;' src='images/no_data_toshow.png' />");
|
|
|
|
}
|
|
|
|
var legends = $('#'+graph_id+' .legendLabel');
|
|
|
|
var j = 0;
|
|
|
|
legends.each(function () {
|
|
|
|
//$(this).css('width', $(this).width());
|
|
|
|
$(this).css('font-size', font_size+'pt');
|
|
|
|
$(this).removeClass("legendLabel");
|
|
|
|
$(this).addClass(font);
|
|
|
|
$(this).text(legend[j]);
|
|
|
|
j++;
|
|
|
|
});
|
2018-06-08 14:30:15 +02:00
|
|
|
|
2017-08-21 13:53:50 +02:00
|
|
|
if ($('input[name="custom_graph"]').val()) {
|
|
|
|
$('.legend>div').css('right',($('.legend>div').height()*-1));
|
|
|
|
$('.legend>table').css('right',($('.legend>div').height()*-1));
|
|
|
|
}
|
|
|
|
//$('.legend>table').css('border',"1px solid #E2E2E2");
|
|
|
|
$('.legend>table').css('background-color',"transparent");
|
2018-06-08 14:30:15 +02:00
|
|
|
|
2017-08-21 13:53:50 +02:00
|
|
|
var pielegends = $('#'+graph_id+' .pieLabelBackground');
|
|
|
|
pielegends.each(function () {
|
|
|
|
$(this).css('transform', "rotate(-35deg)").css('color', 'black');
|
|
|
|
});
|
|
|
|
var labelpielegends = $('#'+graph_id+' .pieLabel');
|
|
|
|
labelpielegends.each(function () {
|
|
|
|
$(this).css('transform', "rotate(-35deg)").css('color', 'black');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function pandoraFlotHBars(graph_id, values, labels, water_mark,
|
2018-06-08 14:30:15 +02:00
|
|
|
maxvalue, water_mark, separator, separator2, font, font_size,
|
|
|
|
background_color, tick_color, min, max) {
|
2016-05-26 08:57:33 +02:00
|
|
|
|
|
|
|
var colors_data = ['#FC4444','#FFA631','#FAD403','#5BB6E5','#F2919D','#80BA27'];
|
|
|
|
values = values.split(separator2);
|
2016-09-08 15:44:36 +02:00
|
|
|
font = font.split("/").pop().split(".").shift();
|
2016-05-26 08:57:33 +02:00
|
|
|
var datas = new Array();
|
|
|
|
for (i = 0; i < values.length; i++) {
|
|
|
|
var serie = values[i].split(separator);
|
|
|
|
|
|
|
|
|
|
|
|
var aux = new Array();
|
|
|
|
for (j = 0; j < serie.length; j++) {
|
|
|
|
var aux2 = parseFloat(serie[j]);
|
|
|
|
aux.push([aux2, j]);
|
|
|
|
datas.push( {
|
|
|
|
data: [[aux2, j]],
|
|
|
|
color: colors_data[j]
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
var labels_total=new Array();
|
|
|
|
labels = labels.split(separator);
|
|
|
|
i = 0;
|
|
|
|
for (i = 0; i < labels.length; i++) {
|
|
|
|
labels_total.push([i, labels[i]]);
|
|
|
|
}
|
|
|
|
|
|
|
|
var stack = 0, bars = true, lines = false, steps = false;
|
|
|
|
var k=0;
|
|
|
|
var options = {
|
|
|
|
series: {
|
|
|
|
bars: {
|
|
|
|
show: true,
|
|
|
|
barWidth: 0.75,
|
|
|
|
align: "center",
|
|
|
|
lineWidth: 1,
|
|
|
|
fill: 1,
|
|
|
|
horizontal: true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
hoverable: true,
|
|
|
|
borderWidth: 1,
|
2017-11-08 09:55:36 +01:00
|
|
|
tickColor: tick_color,
|
2017-10-26 12:23:41 +02:00
|
|
|
backgroundColor: { colors: [background_color, background_color] }
|
2016-05-26 08:57:33 +02:00
|
|
|
},
|
2017-03-27 17:06:55 +02:00
|
|
|
xaxis: {
|
2017-11-08 09:55:36 +01:00
|
|
|
color: tick_color,
|
2017-03-27 17:06:55 +02:00
|
|
|
axisLabelUseCanvas: true,
|
|
|
|
axisLabelFontSizePixels: font_size,
|
|
|
|
axisLabelFontFamily: font+'Font',
|
|
|
|
tickFormatter: xFormatter,
|
|
|
|
},
|
2016-05-26 08:57:33 +02:00
|
|
|
yaxis: {
|
2017-11-08 09:55:36 +01:00
|
|
|
color: tick_color,
|
2017-03-27 17:06:55 +02:00
|
|
|
axisLabelUseCanvas: true,
|
|
|
|
axisLabelFontSizePixels: font_size,
|
|
|
|
axisLabelFontFamily: font+'Font',
|
|
|
|
ticks: yFormatter,
|
|
|
|
},
|
2016-05-26 08:57:33 +02:00
|
|
|
legend: {
|
|
|
|
show: false
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Fixed to avoid the graphs with all 0 datas
|
|
|
|
// the X axis show negative part instead to
|
|
|
|
// show the axis only the positive part.
|
|
|
|
if (maxvalue == 0) {
|
2016-10-24 16:10:41 +02:00
|
|
|
options['yaxis']['min'] = 0;
|
2016-05-26 08:57:33 +02:00
|
|
|
// Fixed the values with a lot of decimals in the situation
|
|
|
|
// with all 0 values.
|
2016-10-24 16:10:41 +02:00
|
|
|
options['yaxis']['tickDecimals'] = 0;
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
2017-11-08 16:41:23 +01:00
|
|
|
|
|
|
|
if (max) {
|
|
|
|
options['xaxis']['max'] = max;
|
|
|
|
}
|
|
|
|
if (min) {
|
|
|
|
options['xaxis']['min'] = min;
|
|
|
|
}
|
2016-05-26 08:57:33 +02:00
|
|
|
|
|
|
|
var plot = $.plot($('#' + graph_id), datas, options );
|
|
|
|
|
|
|
|
$('#' + graph_id).HUseTooltip();
|
2016-05-26 09:50:13 +02:00
|
|
|
$('#' + graph_id).css("margin-left","auto");
|
|
|
|
$('#' + graph_id).css("margin-right","auto");
|
2017-03-28 13:01:40 +02:00
|
|
|
//~ $('#' + graph_id).find('div.legend-tooltip').tooltip({ track: true });
|
2016-05-26 08:57:33 +02:00
|
|
|
|
|
|
|
function yFormatter(v, axis) {
|
|
|
|
format = new Array();
|
2018-02-16 13:41:31 +01:00
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
for (i = 0; i < labels_total.length; i++) {
|
2016-06-13 17:17:54 +02:00
|
|
|
var label = labels_total[i][1];
|
2018-01-11 11:12:41 +01:00
|
|
|
// var shortLabel = reduceText(label, 25);
|
2018-03-21 13:40:15 +01:00
|
|
|
var title = label;
|
|
|
|
var margin_top = 0;
|
2018-01-11 11:12:41 +01:00
|
|
|
if(label.length > 30){
|
2018-04-03 16:41:21 +02:00
|
|
|
label = reduceText(label, 30);
|
2016-06-13 17:17:54 +02:00
|
|
|
}
|
2018-03-21 13:40:15 +01:00
|
|
|
var div_attributes = 'style="font-size:'+font_size+'pt !important;'
|
|
|
|
+ ' margin: 0; max-width: 150px;'
|
|
|
|
+ 'margin-right:5px;';
|
|
|
|
|
|
|
|
if (label.indexOf("<br>") != -1) {
|
|
|
|
div_attributes += "min-height: 2.5em;";
|
|
|
|
}
|
|
|
|
|
2018-04-03 16:41:21 +02:00
|
|
|
div_attributes += '" title="'+title+'" class="'+font+'" '+ ' style="overflow: hidden;"';
|
2018-03-21 13:40:15 +01:00
|
|
|
|
|
|
|
format.push([i,'<div ' + div_attributes + '>'
|
2016-06-13 17:17:54 +02:00
|
|
|
+ label
|
|
|
|
+ '</div>']);
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
return format;
|
|
|
|
}
|
2016-05-26 15:07:47 +02:00
|
|
|
|
2017-03-27 17:06:55 +02:00
|
|
|
function xFormatter(v, axis) {
|
|
|
|
label = parseFloat(v);
|
|
|
|
text = label.toLocaleString();
|
|
|
|
if ( label >= 1000000)
|
|
|
|
text = text.substring(0,4) + "M";
|
|
|
|
else if (label >= 100000)
|
|
|
|
text = text.substring(0,3) + "K";
|
|
|
|
else if (label >= 1000)
|
|
|
|
text = text.substring(0,2) + "K";
|
|
|
|
|
|
|
|
return '<div style="font-size:'+font_size+'pt !important;">'+text+'</div>';
|
|
|
|
}
|
|
|
|
|
2016-05-26 15:07:47 +02:00
|
|
|
if (water_mark) {
|
|
|
|
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
|
|
|
}
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var previousPoint = null, previousLabel = null;
|
|
|
|
|
|
|
|
$.fn.HUseTooltip = function () {
|
|
|
|
$(this).bind("plothover", function (event, pos, item) {
|
|
|
|
if (item) {
|
|
|
|
if ((previousLabel != item.series.label) || (previousPoint != item.seriesIndex)) {
|
|
|
|
previousPoint = item.seriesIndex;
|
|
|
|
previousLabel = item.series.label;
|
|
|
|
$("#tooltip").remove();
|
|
|
|
|
|
|
|
var x = item.datapoint[0];
|
|
|
|
var y = item.datapoint[1];
|
|
|
|
|
|
|
|
var color = item.series.color;
|
|
|
|
showTooltip(pos.pageX,
|
|
|
|
pos.pageY,
|
|
|
|
color,
|
|
|
|
"<strong>" + x + "</strong>");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$("#tooltip").remove();
|
|
|
|
previousPoint = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
$.fn.VUseTooltip = function () {
|
|
|
|
$(this).bind("plothover", function (event, pos, item) {
|
|
|
|
if (item) {
|
|
|
|
if ((previousLabel != item.series.label) || (previousPoint != item.seriesIndex)) {
|
|
|
|
previousPoint = item.seriesIndex;
|
|
|
|
previousLabel = item.series.label;
|
|
|
|
|
|
|
|
$("#tooltip").remove();
|
|
|
|
|
|
|
|
var x = item.datapoint[0];
|
|
|
|
var y = item.datapoint[1];
|
|
|
|
|
|
|
|
var color = item.series.color;
|
|
|
|
showTooltip(pos.pageX,
|
|
|
|
pos.pageY,
|
|
|
|
color,
|
2016-05-26 15:38:01 +02:00
|
|
|
"<strong>" + y + "</strong>");
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$("#tooltip").remove();
|
|
|
|
previousPoint = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
function showTooltip(x, y, color, contents) {
|
|
|
|
$('<div id="tooltip">' + contents + '</div>').css({
|
|
|
|
position: 'absolute',
|
|
|
|
display: 'none',
|
|
|
|
top: y,
|
|
|
|
left: x,
|
|
|
|
border: '2px solid ' + color,
|
|
|
|
padding: '3px',
|
|
|
|
'font-size': '9px',
|
|
|
|
'border-radius': '5px',
|
|
|
|
'background-color': '#fff',
|
|
|
|
'font-family': 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
|
|
|
|
opacity: 0.9
|
|
|
|
}).appendTo("body").fadeIn(200);
|
|
|
|
}
|
|
|
|
|
2017-11-08 09:55:36 +01:00
|
|
|
function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, water_mark, maxvalue, water_mark, separator, separator2, font, font_size , from_ux, from_wux, background_color, tick_color) {
|
2016-05-26 08:57:33 +02:00
|
|
|
values = values.split(separator2);
|
|
|
|
legend = legend.split(separator);
|
2016-09-08 15:44:36 +02:00
|
|
|
font = font.split("/").pop().split(".").shift();
|
2016-06-08 15:48:47 +02:00
|
|
|
labels_long = labels_long.length > 0 ? labels_long.split(separator) : 0;
|
|
|
|
colors = colors.length > 0 ? colors.split(separator) : [];
|
2017-01-23 17:55:27 +01:00
|
|
|
|
2016-06-08 15:48:47 +02:00
|
|
|
var colors_data = colors.length > 0
|
|
|
|
? colors
|
|
|
|
: ['#FFA631','#FC4444','#FAD403','#5BB6E5','#F2919D','#80BA27'];
|
2016-05-26 08:57:33 +02:00
|
|
|
var datas = new Array();
|
|
|
|
|
|
|
|
for (i = 0; i < values.length; i++) {
|
|
|
|
var serie = values[i].split(separator);
|
|
|
|
|
|
|
|
var aux = new Array();
|
|
|
|
for (j = 0; j < serie.length; j++) {
|
|
|
|
var aux2 = parseFloat(serie[j]);
|
|
|
|
aux.push([aux2, j]);
|
2017-01-23 17:55:27 +01:00
|
|
|
if (from_ux) {
|
|
|
|
datas.push( {
|
|
|
|
data: [[j, aux2]],
|
|
|
|
color: colors_data[j]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
datas.push( {
|
|
|
|
data: [[j, aux2]],
|
|
|
|
color: colors_data[0]
|
|
|
|
});
|
|
|
|
}
|
2016-05-26 08:57:33 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
var labels_total=new Array();
|
|
|
|
labels = labels.split(separator);
|
|
|
|
i = 0;
|
|
|
|
for (i = 0; i < labels.length; i++) {
|
|
|
|
labels_total.push([i, labels[i]]);
|
|
|
|
}
|
|
|
|
|
|
|
|
var stack = 0, bars = true, lines = false, steps = false;
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
series: {
|
|
|
|
bars: {
|
|
|
|
show: true,
|
|
|
|
lineWidth: 1,
|
|
|
|
fill: 1,
|
|
|
|
align: "center",
|
|
|
|
barWidth: 1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
xaxis: {
|
2017-11-08 09:55:36 +01:00
|
|
|
color:tick_color,
|
2016-05-26 08:57:33 +02:00
|
|
|
axisLabelUseCanvas: true,
|
2017-03-27 17:06:55 +02:00
|
|
|
axisLabelFontSizePixels: font_size,
|
2016-09-08 15:44:36 +02:00
|
|
|
axisLabelFontFamily: font+'Font',
|
2016-05-26 08:57:33 +02:00
|
|
|
axisLabelPadding: 0,
|
|
|
|
ticks: xFormatter,
|
|
|
|
labelWidth: 130,
|
2017-03-27 17:06:55 +02:00
|
|
|
labelHeight: 50,
|
2016-05-26 08:57:33 +02:00
|
|
|
},
|
|
|
|
yaxis: {
|
2017-11-08 09:55:36 +01:00
|
|
|
color:tick_color,
|
2016-05-26 08:57:33 +02:00
|
|
|
axisLabelUseCanvas: true,
|
2017-03-27 17:06:55 +02:00
|
|
|
axisLabelFontSizePixels: font_size,
|
2016-09-08 15:44:36 +02:00
|
|
|
axisLabelFontFamily: font+'Font',
|
2016-05-26 08:57:33 +02:00
|
|
|
axisLabelPadding: 100,
|
|
|
|
autoscaleMargin: 0.02,
|
|
|
|
tickFormatter: function (v, axis) {
|
2017-03-27 17:06:55 +02:00
|
|
|
label = parseFloat(v);
|
|
|
|
text = label.toLocaleString();
|
|
|
|
if ( label >= 1000000)
|
|
|
|
text = text.substring(0,4) + "M";
|
|
|
|
else if (label >= 100000)
|
|
|
|
text = text.substring(0,3) + "K";
|
|
|
|
else if (label >= 1000)
|
|
|
|
text = text.substring(0,2) + "K";
|
|
|
|
|
|
|
|
return '<div style="font-size:'+font_size+'pt !important;">'+text+'</div>';
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
legend: {
|
|
|
|
noColumns: 100,
|
2016-11-21 19:16:48 +01:00
|
|
|
labelBoxBorderColor: "",
|
2016-05-26 08:57:33 +02:00
|
|
|
margin: 100,
|
|
|
|
container: true,
|
|
|
|
sorted: false
|
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
hoverable: true,
|
|
|
|
borderWidth: 1,
|
2017-11-08 09:55:36 +01:00
|
|
|
tickColor: tick_color,
|
2017-10-26 12:23:41 +02:00
|
|
|
backgroundColor: { colors: [background_color, background_color] }
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-08-17 18:38:12 +02:00
|
|
|
if(from_wux){
|
|
|
|
options.series.bars.barWidth = 0.5;
|
|
|
|
options.grid.aboveData = true;
|
|
|
|
options.grid.borderWidth = 0;
|
|
|
|
options.grid.markings = [ { xaxis: { from: -0.25, to: -0.25 }, color: "#000" },
|
|
|
|
{ yaxis: { from: 0, to: 0 }, color: "#000" }];
|
2017-08-18 13:29:07 +02:00
|
|
|
options.grid.markingsLineWidth = 0.3;
|
2017-08-17 18:38:12 +02:00
|
|
|
|
|
|
|
options.xaxis.tickLength = 0;
|
|
|
|
options.yaxis.tickLength = 0;
|
|
|
|
}
|
|
|
|
|
2017-03-27 17:06:55 +02:00
|
|
|
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
|
|
|
|
options.xaxis.labelWidth = 100;
|
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
var plot = $.plot($('#'+graph_id),datas, options );
|
|
|
|
$('#' + graph_id).VUseTooltip();
|
2016-05-26 09:50:13 +02:00
|
|
|
$('#' + graph_id).css("margin-left","auto");
|
|
|
|
$('#' + graph_id).css("margin-right","auto");
|
2017-10-26 12:23:41 +02:00
|
|
|
|
2017-03-27 17:06:55 +02:00
|
|
|
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
|
|
|
|
$('#'+graph_id+' .xAxis .tickLabel')
|
|
|
|
.find('div')
|
|
|
|
.css('top', '+0px')
|
|
|
|
.css('left', '-20px');
|
2016-05-26 08:57:33 +02:00
|
|
|
// Format functions
|
|
|
|
function xFormatter(v, axis) {
|
2016-06-13 17:17:54 +02:00
|
|
|
var format = new Array();
|
2016-05-26 08:57:33 +02:00
|
|
|
for (i = 0; i < labels_total.length; i++) {
|
2016-06-13 17:17:54 +02:00
|
|
|
var label = labels_total[i][1];
|
2017-03-27 17:06:55 +02:00
|
|
|
var shortLabel = reduceText(label, 28);
|
|
|
|
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
|
|
|
|
shortLabel = reduceText(label, 18);
|
2016-06-13 17:17:54 +02:00
|
|
|
var title = '';
|
|
|
|
if (label !== shortLabel) {
|
|
|
|
title = label;
|
|
|
|
label = shortLabel;
|
|
|
|
}
|
2017-03-27 17:06:55 +02:00
|
|
|
|
2016-06-13 17:17:54 +02:00
|
|
|
format.push([i,
|
2018-04-03 16:41:21 +02:00
|
|
|
'<div class="'+font+'" title="'+title+'" style="word-break: normal; overflow:hidden; transform: rotate(-45deg); position:relative; top:+30px; left:0px; max-width: 100px;font-size:'+font_size+'pt !important;">'
|
2016-06-13 17:17:54 +02:00
|
|
|
+ label
|
|
|
|
+ '</div>']);
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
return format;
|
|
|
|
}
|
|
|
|
|
|
|
|
function yFormatter(v, axis) {
|
2017-03-27 17:06:55 +02:00
|
|
|
return '<div class="'+font+'" style="font-size:'+font_size+'pt !important;">'+v+'</div>';
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function lFormatter(v, axis) {
|
2017-03-27 17:06:55 +02:00
|
|
|
return '<div style="font-size:'+font_size+'pt !important;">'+v+'</div>';
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
2017-03-27 17:06:55 +02:00
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
if (water_mark) {
|
|
|
|
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-10 16:22:41 +02:00
|
|
|
function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumulate_data, intervaltick, water_mark, maxvalue, separator, separator2, graph_javascript, id_agent, full_legend) {
|
2016-05-26 08:57:33 +02:00
|
|
|
values = values.split(separator2);
|
|
|
|
labels = labels.split(separator);
|
|
|
|
legend = legend.split(separator);
|
|
|
|
acumulate_data = acumulate_data.split(separator);
|
|
|
|
datacolor = datacolor.split(separator);
|
2017-07-24 16:34:22 +02:00
|
|
|
if (full_legend != false) {
|
2017-07-10 16:22:41 +02:00
|
|
|
full_legend = full_legend.split(separator);
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
// Check possible adapt_keys on classes
|
|
|
|
check_adaptions(graph_id);
|
|
|
|
|
|
|
|
var datas = new Array();
|
|
|
|
|
|
|
|
for (i=0;i<values.length;i++) {
|
|
|
|
var serie = values[i].split(separator);
|
|
|
|
var aux = new Array();
|
|
|
|
$.each(serie,function(i,v) {
|
|
|
|
aux.push([v, i]);
|
|
|
|
});
|
|
|
|
|
|
|
|
datas.push({
|
|
|
|
data: aux,
|
|
|
|
bars: { show: true, fill: true ,fillColor: datacolor[i] , horizontal: true, lineWidth:0, steps:false }
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
var stack = 0, bars = true, lines = false, steps = false;
|
|
|
|
|
2017-07-13 16:23:16 +02:00
|
|
|
var regex = /visual_console/;
|
|
|
|
var match = regex.exec(window.location.href);
|
|
|
|
|
|
|
|
if (match == null) {
|
|
|
|
var options = {
|
2016-05-26 08:57:33 +02:00
|
|
|
series: {
|
|
|
|
stack: stack,
|
|
|
|
shadowSize: 0.1,
|
|
|
|
color: '#ddd'
|
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
hoverable: true,
|
2016-08-19 12:46:27 +02:00
|
|
|
clickable: true,
|
2016-05-26 08:57:33 +02:00
|
|
|
borderWidth:1,
|
2016-11-21 19:16:48 +01:00
|
|
|
borderColor: '',
|
2016-05-26 08:57:33 +02:00
|
|
|
tickColor: '#fff'
|
|
|
|
},
|
|
|
|
xaxes: [ {
|
|
|
|
tickFormatter: xFormatter,
|
2016-11-21 19:16:48 +01:00
|
|
|
color: '',
|
2016-05-26 08:57:33 +02:00
|
|
|
tickSize: intervaltick,
|
|
|
|
tickLength: 0
|
|
|
|
} ],
|
|
|
|
yaxes: [ {
|
|
|
|
show: false,
|
|
|
|
tickLength: 0
|
|
|
|
}],
|
|
|
|
legend: {
|
|
|
|
show: false
|
|
|
|
}
|
|
|
|
};
|
2017-07-13 16:23:16 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
var options = {
|
|
|
|
series: {
|
|
|
|
stack: stack,
|
|
|
|
shadowSize: 0.1,
|
|
|
|
color: '#ddd'
|
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
hoverable: false,
|
|
|
|
clickable: false,
|
|
|
|
borderWidth:1,
|
|
|
|
borderColor: '',
|
|
|
|
tickColor: '#fff'
|
|
|
|
},
|
|
|
|
xaxes: [ {
|
|
|
|
tickFormatter: xFormatter,
|
|
|
|
color: '',
|
|
|
|
tickSize: intervaltick,
|
|
|
|
tickLength: 0
|
|
|
|
} ],
|
|
|
|
yaxes: [ {
|
|
|
|
show: false,
|
|
|
|
tickLength: 0
|
|
|
|
}],
|
|
|
|
legend: {
|
|
|
|
show: false
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2016-05-26 08:57:33 +02:00
|
|
|
|
|
|
|
var plot = $.plot($('#'+graph_id), datas, options );
|
|
|
|
|
2017-07-13 16:23:16 +02:00
|
|
|
if (match == null) {
|
|
|
|
// Events
|
|
|
|
$('#'+graph_id).bind('plothover', function (event, pos, item) {
|
|
|
|
if (item) {
|
|
|
|
var from = legend[item.seriesIndex];
|
|
|
|
var to = legend[item.seriesIndex+1];
|
2016-05-26 08:57:33 +02:00
|
|
|
|
2017-07-13 16:23:16 +02:00
|
|
|
if (to == undefined) {
|
|
|
|
to = '>';
|
|
|
|
}
|
2016-05-26 08:57:33 +02:00
|
|
|
|
2017-07-13 16:23:16 +02:00
|
|
|
$('#extra_'+graph_id).text(from+'-'+to);
|
|
|
|
var extra_height = parseInt($('#extra_'+graph_id).css('height').split('px')[0]);
|
|
|
|
var extra_width = parseInt($('#extra_'+graph_id).css('width').split('px')[0]);
|
|
|
|
$('#extra_'+graph_id).css('left',pos.pageX-(extra_width/4)+'px');
|
|
|
|
//$('#extra_'+graph_id).css('top',plot.offset().top-extra_height-5+'px');
|
|
|
|
$('#extra_'+graph_id).show();
|
2016-08-19 12:46:27 +02:00
|
|
|
}
|
2017-07-13 16:23:16 +02:00
|
|
|
});
|
2016-08-19 12:46:27 +02:00
|
|
|
|
2017-07-28 10:30:17 +02:00
|
|
|
$('#'+graph_id).bind('plotclick', function(event, pos, item) {
|
|
|
|
if (item) {
|
|
|
|
//from time
|
|
|
|
var from = legend[item.seriesIndex];
|
|
|
|
//to time
|
|
|
|
var to = legend[item.seriesIndex+1];
|
|
|
|
//current date
|
|
|
|
var dateObj = new Date();
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2017-07-28 10:30:17 +02:00
|
|
|
if (full_legend != "") {
|
|
|
|
newdate = full_legend[item.seriesIndex];
|
|
|
|
newdate2 = full_legend[item.seriesIndex+1];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var month = dateObj.getUTCMonth() + 1; //months from 1-12
|
|
|
|
var day = dateObj.getUTCDate();
|
|
|
|
var year = dateObj.getUTCFullYear();
|
|
|
|
newdate = year + "/" + month + "/" + day;
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2017-07-28 10:30:17 +02:00
|
|
|
if(!to){
|
|
|
|
to= '23:59';
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2017-07-28 10:30:17 +02:00
|
|
|
if (full_legend != "") {
|
|
|
|
if (newdate2 == undefined) {
|
|
|
|
window.location='index.php?sec=eventos&sec2=operation/events/events&id_agent='+id_agent+'&date_from='+newdate+'&time_from='+from+'&status=-1';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
window.location='index.php?sec=eventos&sec2=operation/events/events&id_agent='+id_agent+'&date_from='+newdate+'&time_from='+from+'&date_to='+newdate2+'&time_to='+to+'&status=-1';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
window.location='index.php?sec=eventos&sec2=operation/events/events&id_agent='+id_agent+'&date_from='+newdate+'&time_from='+from+'&date_to='+newdate+'&time_to='+to+'&status=-1';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2016-08-19 12:46:27 +02:00
|
|
|
|
2017-07-13 16:23:16 +02:00
|
|
|
$('#'+graph_id).bind('mouseout',resetInteractivity);
|
|
|
|
}
|
2016-05-26 08:57:33 +02:00
|
|
|
|
|
|
|
// Reset interactivity styles
|
|
|
|
function resetInteractivity() {
|
|
|
|
$('#extra_'+graph_id).hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Format functions
|
|
|
|
function xFormatter(v, axis) {
|
|
|
|
for (i = 0; i < acumulate_data.length; i++) {
|
|
|
|
if (acumulate_data[i] == v) {
|
|
|
|
return '<span style=\'font-size: 6pt\'>' + legend[i] + '</span>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-27 16:28:00 +01:00
|
|
|
function pandoraFlotArea(
|
2018-05-10 08:43:09 +02:00
|
|
|
graph_id, values, legend, agent_module_id,
|
2018-06-08 14:30:15 +02:00
|
|
|
series_type, color, water_mark, date_array,
|
2018-05-28 17:47:40 +02:00
|
|
|
data_module_graph, params,
|
2018-06-08 08:58:18 +02:00
|
|
|
force_integer, background_color,
|
|
|
|
legend_color, short_data, events_array
|
2018-05-10 08:43:09 +02:00
|
|
|
) {
|
|
|
|
|
|
|
|
//diferents vars
|
2018-06-06 17:23:32 +02:00
|
|
|
var unit = params.unit ? params.unit : '';
|
|
|
|
var homeurl = params.homeurl;
|
|
|
|
var font_size = params.font_size;
|
|
|
|
var font = params.font;
|
|
|
|
var width = params.width;
|
|
|
|
var height = params.height;
|
|
|
|
var vconsole = params.vconsole;
|
|
|
|
var dashboard = params.dashboard;
|
|
|
|
var menu = params.menu;
|
|
|
|
var min_x = date_array['start_date'] *1000;
|
|
|
|
var max_x = date_array['final_date'] *1000;
|
|
|
|
var type = params.stacked;
|
|
|
|
var show_legend = params.show_legend;
|
|
|
|
var image_treshold = params.image_treshold;
|
2018-05-10 08:43:09 +02:00
|
|
|
|
|
|
|
if(typeof type === 'undefined' || type == ''){
|
2018-05-28 17:47:40 +02:00
|
|
|
type = params.type_graph;
|
2018-05-10 08:43:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//for threshold
|
|
|
|
var threshold = true;
|
|
|
|
var thresholded = false;
|
|
|
|
var yellow_threshold = parseFloat (data_module_graph.w_min);
|
|
|
|
var red_threshold = parseFloat (data_module_graph.c_min);
|
|
|
|
var yellow_up = parseFloat (data_module_graph.w_max);
|
|
|
|
var red_up = parseFloat (data_module_graph.c_max);
|
|
|
|
var yellow_inverse = parseInt (data_module_graph.w_inv);
|
|
|
|
var red_inverse = parseInt (data_module_graph.c_inv);
|
|
|
|
|
|
|
|
//XXXXX
|
|
|
|
var markins_graph = true;
|
|
|
|
|
|
|
|
var legend_events = null;
|
|
|
|
var legend_alerts = null;
|
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
// If threshold and up are the same, that critical or warning is disabled
|
2018-02-19 09:31:45 +01:00
|
|
|
if (yellow_threshold == yellow_up){
|
|
|
|
yellow_inverse = false;
|
|
|
|
}
|
2018-02-27 16:28:00 +01:00
|
|
|
|
|
|
|
if (red_threshold == red_up){
|
2018-02-19 09:31:45 +01:00
|
|
|
red_inverse = false;
|
|
|
|
}
|
2018-02-16 13:41:31 +01:00
|
|
|
|
|
|
|
//Array with points to be painted
|
|
|
|
var threshold_data = new Array();
|
|
|
|
//Array with some interesting points
|
|
|
|
var extremes = new Array ();
|
2018-02-19 09:31:45 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
var yellow_only_min = ((yellow_up == 0) && (yellow_threshold != 0));
|
2018-02-19 09:31:45 +01:00
|
|
|
var red_only_min = ((red_up == 0) && (red_threshold != 0));
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-19 09:31:45 +01:00
|
|
|
//color
|
2018-02-23 14:31:00 +01:00
|
|
|
var normalw = '#efe';
|
|
|
|
var warningw = '#ffe';
|
2018-02-16 13:41:31 +01:00
|
|
|
var criticalw = '#fee';
|
2018-02-23 14:31:00 +01:00
|
|
|
var normal = '#0f0';
|
2018-05-10 08:43:09 +02:00
|
|
|
var warning = 'yellow';
|
|
|
|
var critical = 'red';
|
2018-02-16 13:41:31 +01:00
|
|
|
|
|
|
|
if (threshold) {
|
|
|
|
// Warning interval. Change extremes depends on critical interval
|
|
|
|
if (yellow_inverse && red_inverse) {
|
|
|
|
if (red_only_min && yellow_only_min) {
|
|
|
|
// C: |-------- |
|
|
|
|
// W: |········==== |
|
|
|
|
if (yellow_threshold > red_threshold) {
|
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal_fdown',
|
|
|
|
data: [[max_x, red_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {
|
|
|
|
show: true,
|
|
|
|
align: "left",
|
|
|
|
barWidth: yellow_threshold - red_threshold,
|
|
|
|
lineWidth: 0,
|
|
|
|
horizontal: true,
|
|
|
|
fillColor: {
|
|
|
|
colors: [
|
|
|
|
{
|
|
|
|
opacity: 0.1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
opacity: 0.1
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
extremes['warning_normal_fdown_1'] = red_threshold;
|
|
|
|
extremes['warning_normal_fdown_2'] = yellow_threshold;
|
|
|
|
}
|
|
|
|
} else if (!red_only_min && yellow_only_min) {
|
|
|
|
// C: |-------- ------|
|
|
|
|
// W: |········===· |
|
|
|
|
if (yellow_threshold > red_up) {
|
|
|
|
yellow_threshold = red_up;
|
|
|
|
}
|
|
|
|
if (yellow_threshold > red_threshold) {
|
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal_fdown',
|
|
|
|
data: [[max_x, red_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: yellow_threshold - red_threshold, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_fdown_1'] = red_threshold;
|
|
|
|
extremes['warning_normal_fdown_2'] = yellow_threshold;
|
|
|
|
}
|
|
|
|
} else if (red_only_min && !yellow_only_min) {
|
|
|
|
// C: |------- |
|
|
|
|
// W: |·······==== ===|
|
|
|
|
if (red_threshold < yellow_threshold) {
|
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal_fdown',
|
|
|
|
data: [[max_x, red_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: yellow_threshold - red_threshold, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_fdown_1'] = red_threshold;
|
|
|
|
extremes['warning_normal_fdown_2'] = yellow_threshold;
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
if (yellow_up < red_threshold) {
|
|
|
|
yellow_up = red_threshold;
|
|
|
|
}
|
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'warning_up',
|
|
|
|
data: [[max_x, yellow_up]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_up'] = yellow_up;
|
|
|
|
} else {
|
|
|
|
if (yellow_threshold > red_threshold) {
|
|
|
|
// C: |-------- ------|
|
|
|
|
// W: |········===· ···|
|
|
|
|
if (yellow_threshold > red_up) {
|
|
|
|
yellow_threshold = red_up;
|
|
|
|
}
|
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal_fdown',
|
|
|
|
data: [[max_x, red_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: yellow_threshold - red_threshold, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_fdown_1'] = red_threshold;
|
|
|
|
extremes['warning_normal_fdown_2'] = yellow_threshold;
|
|
|
|
}
|
|
|
|
if (yellow_up < red_up) {
|
|
|
|
// C: |-------- ---|
|
|
|
|
// W: |····· ·======···|
|
|
|
|
if (yellow_up < red_threshold) {
|
|
|
|
yellow_up = red_up;
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
threshold_data.push({
|
2018-02-16 13:41:31 +01:00
|
|
|
id: 'warning_normal_fup',
|
|
|
|
data: [[max_x, yellow_up]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: red_up - yellow_up, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_fup_1'] = red_up;
|
|
|
|
extremes['warning_normal_fup_2'] = yellow_up;
|
|
|
|
}
|
|
|
|
// If warning is under critical completely do not paint anything yellow
|
|
|
|
// C: |-------- -----|
|
|
|
|
// W: |···· ···|
|
|
|
|
}
|
|
|
|
} else if (yellow_inverse && !red_inverse) {
|
|
|
|
if (red_only_min && yellow_only_min) {
|
|
|
|
// C: | -----|
|
|
|
|
// W: |============··· |
|
|
|
|
if (yellow_threshold > red_threshold) {
|
|
|
|
yellow_threshold = red_threshold;
|
|
|
|
}
|
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'warning_down',
|
|
|
|
data: [[max_x, yellow_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_down'] = yellow_threshold;
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
} else if (!red_only_min && yellow_only_min) {
|
|
|
|
// C: | ---- |
|
|
|
|
// W: |======····=== |
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
if (yellow_threshold > red_up) {
|
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal_fdown',
|
|
|
|
data: [[max_x, red_up]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: yellow_threshold - red_up, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_fdown_1'] = red_up;
|
|
|
|
extremes['warning_normal_fdown_2'] = yellow_threshold;
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
if (yellow_threshold > red_threshold) {
|
|
|
|
yellow_threshold = red_threshold;
|
|
|
|
}
|
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'warning_down',
|
|
|
|
data: [[max_x, yellow_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_down'] = yellow_threshold;
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
} else if (red_only_min && !yellow_only_min) {
|
|
|
|
if (yellow_threshold < red_threshold) {
|
|
|
|
// C: | -----|
|
|
|
|
// W: |======= ===·····|
|
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'warning_down',
|
|
|
|
data: [[max_x, yellow_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_down'] = yellow_threshold;
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
if (red_threshold > yellow_up) {
|
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal_fup',
|
|
|
|
data: [[max_x, yellow_up]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: red_threshold - yellow_up, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_fup_1'] = yellow_up;
|
|
|
|
extremes['warning_normal_fup_2'] = red_threshold;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// C: | ------------|
|
|
|
|
// W: |=====·· ········|
|
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'warning_down',
|
|
|
|
data: [[max_x, red_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_down'] = red_threshold;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (yellow_threshold > red_up) {
|
|
|
|
// C: | ----- |
|
|
|
|
// W: |====·····=== ===|
|
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'warning_down',
|
|
|
|
data: [[max_x, red_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_down'] = red_threshold;
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal_fdown',
|
|
|
|
data: [[max_x, red_up]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: yellow_threshold - red_up, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_fdown_1'] = red_up;
|
|
|
|
extremes['warning_normal_fdown_2'] = yellow_threshold;
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'warning_up',
|
|
|
|
data: [[max_x, yellow_up]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_up'] = yellow_up;
|
|
|
|
} else if (red_threshold > yellow_up){
|
|
|
|
// C: | ----- |
|
|
|
|
// W: |=== ===·····==|
|
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'warning_down',
|
|
|
|
data: [[max_x, yellow_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_down'] = yellow_threshold;
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal_fup',
|
|
|
|
data: [[max_x, yellow_up]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: red_threshold - yellow_up, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_fup_1'] = yellow_up;
|
|
|
|
extremes['warning_normal_fup_2'] = red_threshold;
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'warning_up',
|
|
|
|
data: [[max_x, red_up]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_up'] = red_up;
|
|
|
|
} else {
|
|
|
|
// C: | -------- |
|
|
|
|
// W: |==· ···=======|
|
|
|
|
if (yellow_threshold > red_threshold) {
|
|
|
|
yellow_threshold = red_threshold;
|
|
|
|
}
|
|
|
|
if (yellow_up < red_up) {
|
|
|
|
yellow_up = red_up;
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'warning_down',
|
|
|
|
data: [[max_x, yellow_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_down'] = yellow_threshold;
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'warning_up',
|
|
|
|
data: [[max_x, yellow_up]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_up'] = yellow_up;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (!yellow_inverse && red_inverse) {
|
|
|
|
if (yellow_only_min && red_only_min) {
|
|
|
|
// C: |----- |
|
|
|
|
// W: | ··============|
|
|
|
|
if (yellow_threshold < red_threshold) {
|
|
|
|
yellow_threshold = red_threshold;
|
|
|
|
}
|
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'warning_up',
|
|
|
|
data: [[max_x, yellow_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_up'] = yellow_threshold;
|
|
|
|
} else if (!yellow_only_min && red_only_min) {
|
|
|
|
// C: |----- |
|
|
|
|
// W: | ··======== |
|
|
|
|
if (yellow_threshold < red_threshold) {
|
|
|
|
yellow_threshold = red_threshold;
|
|
|
|
}
|
|
|
|
if (yellow_up > red_threshold) {
|
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal',
|
|
|
|
data: [[max_x, yellow_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: (yellow_up - yellow_threshold), lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_1'] = yellow_threshold;
|
|
|
|
extremes['warning_normal_2'] = yellow_up;
|
|
|
|
}
|
|
|
|
} else if (yellow_only_min && !red_only_min) {
|
|
|
|
// C: |----- ------|
|
|
|
|
// W: | ··======······|
|
|
|
|
if (yellow_threshold < red_threshold) {
|
|
|
|
yellow_threshold = red_threshold;
|
|
|
|
}
|
|
|
|
if (yellow_threshold < red_up) {
|
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal',
|
|
|
|
data: [[max_x, yellow_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: (red_up - yellow_threshold), lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_1'] = yellow_threshold;
|
|
|
|
extremes['warning_normal_2'] = red_up;
|
|
|
|
}
|
|
|
|
// If warning is under critical completely do not paint anything yellow
|
|
|
|
// C: |-------- -----|
|
|
|
|
// W: | ···|
|
|
|
|
} else {
|
|
|
|
if (red_up > yellow_threshold && red_threshold < yellow_up) {
|
|
|
|
// C: |----- ------|
|
|
|
|
// W: | ··======· |
|
|
|
|
if (yellow_threshold < red_threshold) {
|
|
|
|
yellow_threshold = red_threshold;
|
|
|
|
}
|
|
|
|
if (yellow_up > red_up) {
|
|
|
|
yellow_up = red_up;
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal',
|
|
|
|
data: [[max_x, yellow_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: (yellow_up - yellow_threshold), lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_1'] = yellow_threshold;
|
|
|
|
extremes['warning_normal_2'] = yellow_up;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// If warning is under critical completely do not paint anything yellow
|
|
|
|
// C: |-------- -----| or // C: |-------- -----|
|
|
|
|
// W: | ···· | // W: | ·· |
|
|
|
|
else {
|
|
|
|
if (red_only_min && yellow_only_min) {
|
|
|
|
if (yellow_threshold < red_threshold) {
|
|
|
|
// C: | ---------|
|
|
|
|
// W: | =====·········|
|
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal',
|
|
|
|
data: [[max_x, yellow_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: (red_threshold - yellow_threshold), lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_1'] = yellow_threshold;
|
|
|
|
extremes['warning_normal_2'] = red_threshold;
|
|
|
|
}
|
|
|
|
} else if (red_only_min && !yellow_only_min) {
|
|
|
|
// C: | ---------|
|
|
|
|
// W: | =====··· |
|
|
|
|
if (yellow_up > red_threshold) {
|
|
|
|
yellow_up = red_threshold;
|
|
|
|
}
|
|
|
|
if (yellow_threshold < red_threshold) {
|
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal',
|
|
|
|
data: [[max_x, yellow_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: (yellow_up - yellow_threshold), lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_1'] = yellow_threshold;
|
|
|
|
extremes['warning_normal_2'] = yellow_up;
|
|
|
|
}
|
|
|
|
} else if (!red_only_min && yellow_only_min) {
|
|
|
|
// C: | ------- |
|
|
|
|
// W: | ==·······=====|
|
|
|
|
if (yellow_threshold < red_threshold) {
|
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal_fdown',
|
|
|
|
data: [[max_x, yellow_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: red_threshold - yellow_threshold, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_fdown_1'] = yellow_threshold;
|
|
|
|
extremes['warning_normal_fdown_2'] = red_threshold;
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
if (yellow_threshold < red_up) {
|
|
|
|
yellow_threshold = red_up;
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'warning_up',
|
|
|
|
data: [[max_x, yellow_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_up'] = yellow_threshold;
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
} else {
|
|
|
|
if (red_threshold > yellow_threshold && red_up < yellow_up ) {
|
|
|
|
// C: | ------ |
|
|
|
|
// W: | ==······==== |
|
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal_fdown',
|
|
|
|
data: [[max_x, yellow_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: red_threshold - yellow_threshold, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_fdown_1'] = yellow_threshold;
|
|
|
|
extremes['warning_normal_fdown_2'] = red_threshold;
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal_fup',
|
|
|
|
data: [[max_x, red_up]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: yellow_up - red_up, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_fup_1'] = red_up;
|
|
|
|
extremes['warning_normal_fup_2'] = yellow_up;
|
|
|
|
} else if (red_threshold < yellow_threshold && red_up > yellow_up) {
|
|
|
|
// If warning is under critical completely do not paint anything yellow
|
|
|
|
// C: | -------- |
|
|
|
|
// W: | ···· |
|
|
|
|
} else {
|
|
|
|
// C: | -------- | or // C: | ------ |
|
|
|
|
// W: | ==·· | // W: | ···==== |
|
|
|
|
if ((yellow_up > red_threshold) && (yellow_up < red_up)) {
|
|
|
|
yellow_up = red_threshold;
|
|
|
|
}
|
|
|
|
if ((yellow_threshold < red_up) && (yellow_threshold > red_threshold)) {
|
|
|
|
yellow_threshold = red_up;
|
|
|
|
}
|
|
|
|
threshold_data.push({
|
|
|
|
id: 'warning_normal',
|
|
|
|
data: [[max_x, yellow_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: warning,
|
|
|
|
bars: {show: true, align: "left", barWidth: (yellow_up - yellow_threshold), lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 255, 198, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
extremes['warning_normal_1'] = yellow_threshold;
|
|
|
|
extremes['warning_normal_2'] = yellow_up;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
// Critical interval
|
|
|
|
if (red_inverse) {
|
|
|
|
if (!red_only_min) {
|
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'critical_up',
|
|
|
|
data: [[max_x, red_up]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: critical,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 236, 234, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
2018-05-10 08:43:09 +02:00
|
|
|
extremes['critical_normal_1'] = red_threshold;
|
|
|
|
extremes['critical_normal_2'] = red_up;
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'critical_down',
|
|
|
|
data: [[max_x, red_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: critical,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 236, 234, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
2018-05-10 08:43:09 +02:00
|
|
|
extremes['critical_normal_3'] = red_threshold;
|
|
|
|
extremes['critical_normal_4'] = red_threshold;
|
2018-02-16 13:41:31 +01:00
|
|
|
} else {
|
|
|
|
if (red_up == 0 && red_threshold != 0) {
|
|
|
|
threshold_data.push({ // barWidth will be correct on draw time
|
|
|
|
id: 'critical_up',
|
|
|
|
data: [[max_x, red_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: critical,
|
|
|
|
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 236, 234, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
2018-05-10 08:43:09 +02:00
|
|
|
extremes['critical_normal_1'] = red_threshold;
|
|
|
|
extremes['critical_normal_2'] = red_up;
|
2018-02-16 13:41:31 +01:00
|
|
|
} else {
|
|
|
|
threshold_data.push({
|
|
|
|
id: 'critical_normal',
|
|
|
|
data: [[max_x, red_threshold]],
|
|
|
|
label: null,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: critical,
|
|
|
|
bars: {show: true, align: "left", barWidth: (red_up - red_threshold), lineWidth: 0, horizontal: true, fillColor: { colors: [ { opacity: 0.1 }, { opacity: 0.1 } ] }},
|
|
|
|
highlightColor: 'rgba(254, 236, 234, 0)'
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
2018-05-10 08:43:09 +02:00
|
|
|
extremes['critical_normal_1'] = red_threshold;
|
|
|
|
extremes['critical_normal_2'] = red_up;
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-08 14:30:15 +02:00
|
|
|
|
2018-05-10 08:43:09 +02:00
|
|
|
switch (type) {
|
|
|
|
case 'line':
|
|
|
|
case 2:
|
|
|
|
stacked = null;
|
|
|
|
filled_s = false;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
stacked = 'stack';
|
|
|
|
filled_s = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case 'area':
|
|
|
|
case 0:
|
|
|
|
stacked = null;
|
|
|
|
filled_s = 0.3;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
stacked = 'stack';
|
|
|
|
filled_s = 0.3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
var datas = new Array();
|
|
|
|
var data_base = new Array();
|
|
|
|
var lineWidth = $('#hidden-line_width_graph').val() || 1;
|
|
|
|
|
|
|
|
i=0;
|
|
|
|
$.each(values, function (index, value) {
|
2018-06-08 14:30:15 +02:00
|
|
|
|
2018-05-10 08:43:09 +02:00
|
|
|
if (typeof value.data !== "undefined") {
|
|
|
|
if(index.search("alert") >= 0){
|
|
|
|
fill_color = '#ff7f00';
|
|
|
|
}
|
|
|
|
else if(index.search("event") >= 0){
|
|
|
|
fill_color = '#ff0000';
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
fill_color = 'green';
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (series_type[index]) {
|
|
|
|
case 'area':
|
|
|
|
line_show = true;
|
|
|
|
points_show = false; // XXX - false
|
|
|
|
filled = filled_s;
|
|
|
|
steps_chart = false;
|
|
|
|
radius = false;
|
|
|
|
fill_points = fill_color;
|
|
|
|
break;
|
|
|
|
case 'percentil':
|
|
|
|
case 'line':
|
|
|
|
default:
|
|
|
|
line_show = true;
|
|
|
|
points_show = false;
|
|
|
|
filled = false;
|
|
|
|
steps_chart = false;
|
|
|
|
radius = false;
|
|
|
|
fill_points = fill_color;
|
|
|
|
break;
|
|
|
|
case 'points':
|
|
|
|
line_show = false;
|
|
|
|
points_show = true;
|
|
|
|
filled = false;
|
|
|
|
steps_chart = false;
|
|
|
|
radius = 1.5;
|
|
|
|
fill_points = fill_color;
|
|
|
|
break;
|
|
|
|
case 'unknown':
|
|
|
|
case 'boolean':
|
|
|
|
line_show = true;
|
|
|
|
points_show = false;
|
|
|
|
filled = filled_s;
|
|
|
|
steps_chart = true;
|
|
|
|
radius = false;
|
|
|
|
fill_points = fill_color;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-05-18 14:22:39 +02:00
|
|
|
//in graph stacked unset percentil
|
|
|
|
if( ! ( (type == 1) && ( /percentil/.test(index) ) == true ) &&
|
|
|
|
! ( (type == 3) && ( /percentil/.test(index) ) == true ) ){
|
2018-06-08 14:30:15 +02:00
|
|
|
data_base.push({
|
2018-05-18 14:22:39 +02:00
|
|
|
id: 'serie_' + i,
|
|
|
|
data: value.data,
|
2018-06-06 11:18:39 +02:00
|
|
|
label: index,
|
2018-06-08 14:30:15 +02:00
|
|
|
color: color[index]['color'],
|
2018-05-18 14:22:39 +02:00
|
|
|
lines: {
|
|
|
|
show: line_show,
|
|
|
|
fill: filled,
|
|
|
|
lineWidth: lineWidth,
|
|
|
|
steps: steps_chart
|
|
|
|
},
|
|
|
|
points: {
|
|
|
|
show: points_show,
|
|
|
|
radius: 3,
|
|
|
|
fillColor: fill_points
|
2018-05-21 17:25:09 +02:00
|
|
|
},
|
|
|
|
legend: legend.index
|
2018-05-18 14:22:39 +02:00
|
|
|
});
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
}
|
2018-05-18 14:22:39 +02:00
|
|
|
i++;
|
2018-05-10 08:43:09 +02:00
|
|
|
});
|
2018-06-06 11:18:39 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
// The first execution, the graph data is the base data
|
|
|
|
datas = data_base;
|
2018-04-24 13:19:24 +02:00
|
|
|
font_size = 8;
|
2018-02-16 13:41:31 +01:00
|
|
|
// minTickSize
|
|
|
|
var count_data = datas[0].data.length;
|
2018-06-06 11:18:39 +02:00
|
|
|
var min_tick = datas[0].data[0][0];
|
|
|
|
var max_tick = datas[0].data[count_data - 1][0];
|
|
|
|
|
|
|
|
var number_ticks = 8;
|
|
|
|
if(vconsole){
|
|
|
|
number_ticks = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
var maxticks = date_array['period'] / 3600 / number_ticks;
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
var options = {
|
|
|
|
series: {
|
|
|
|
stack: stacked,
|
|
|
|
shadowSize: 0.1
|
|
|
|
},
|
2018-02-27 16:28:00 +01:00
|
|
|
crosshair: {
|
2018-05-10 08:43:09 +02:00
|
|
|
mode: 'xy',
|
|
|
|
color: 'grey'
|
2018-02-23 14:31:00 +01:00
|
|
|
},
|
2018-02-27 16:28:00 +01:00
|
|
|
selection: {
|
2018-04-24 13:19:24 +02:00
|
|
|
mode: 'xy',
|
2018-02-27 16:28:00 +01:00
|
|
|
color: '#777'
|
2018-02-23 14:31:00 +01:00
|
|
|
},
|
2018-02-16 13:41:31 +01:00
|
|
|
export: {
|
|
|
|
export_data: true,
|
2018-05-21 17:25:09 +02:00
|
|
|
labels_long: legend,
|
2018-02-16 13:41:31 +01:00
|
|
|
homeurl: homeurl
|
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
hoverable: true,
|
|
|
|
clickable: true,
|
|
|
|
borderWidth:1,
|
|
|
|
borderColor: '#C1C1C1',
|
|
|
|
tickColor: background_color,
|
2018-05-10 08:43:09 +02:00
|
|
|
color: legend_color,
|
|
|
|
autoHighlight: true
|
2018-02-16 13:41:31 +01:00
|
|
|
},
|
|
|
|
xaxes: [{
|
|
|
|
axisLabelFontSizePixels: font_size,
|
|
|
|
mode: "time",
|
2018-06-06 11:18:39 +02:00
|
|
|
//tickFormatter: xFormatter,
|
|
|
|
tickSize: [maxticks, 'hour']
|
2018-02-16 13:41:31 +01:00
|
|
|
}],
|
|
|
|
yaxes: [{
|
|
|
|
tickFormatter: yFormatter,
|
|
|
|
color: '',
|
|
|
|
alignTicksWithAxis: 1,
|
|
|
|
labelWidth: 30,
|
|
|
|
position: 'left',
|
|
|
|
font: font,
|
2018-06-06 11:18:39 +02:00
|
|
|
reserveSpace: true
|
2018-02-16 13:41:31 +01:00
|
|
|
}],
|
|
|
|
legend: {
|
|
|
|
position: 'se',
|
|
|
|
container: $('#legend_' + graph_id),
|
|
|
|
labelFormatter: lFormatter
|
|
|
|
}
|
|
|
|
};
|
2018-06-06 11:18:39 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
if (vconsole) {
|
|
|
|
options.grid['hoverable'] = false;
|
|
|
|
options.grid['clickable'] = false;
|
|
|
|
options.crosshair = false;
|
|
|
|
options.selection = false;
|
|
|
|
}
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-23 14:31:00 +01:00
|
|
|
var stack = 0,
|
|
|
|
bars = true,
|
|
|
|
lines = false,
|
|
|
|
steps = false;
|
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
var plot = $.plot($('#' + graph_id), datas, options);
|
2018-02-19 09:31:45 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
// Re-calculate the graph height with the legend height
|
|
|
|
if (dashboard || vconsole) {
|
|
|
|
var hDiff = $('#'+graph_id).height() - $('#legend_'+graph_id).height();
|
|
|
|
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ){
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#'+graph_id).css('height', hDiff);
|
|
|
|
}
|
|
|
|
}
|
2018-06-08 14:30:15 +02:00
|
|
|
|
2018-06-06 11:18:39 +02:00
|
|
|
/*
|
|
|
|
if (vconsole) {
|
2018-02-16 13:41:31 +01:00
|
|
|
var myCanvas = plot.getCanvas();
|
|
|
|
plot.setupGrid(); // redraw plot to new size
|
|
|
|
plot.draw();
|
|
|
|
var image = myCanvas.toDataURL("image/png");
|
|
|
|
return;
|
|
|
|
}
|
2018-06-06 11:18:39 +02:00
|
|
|
*/
|
2018-02-16 13:41:31 +01:00
|
|
|
// Adjust the overview plot to the width and position of the main plot
|
|
|
|
adjust_left_width_canvas(graph_id, 'overview_'+graph_id);
|
2018-02-27 16:28:00 +01:00
|
|
|
update_left_width_canvas(graph_id);
|
2018-02-16 13:41:31 +01:00
|
|
|
|
|
|
|
// Adjust overview when main chart is resized
|
|
|
|
$('#'+graph_id).resize(function(){
|
|
|
|
update_left_width_canvas(graph_id);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Adjust linked graph to the width and position of the main plot
|
|
|
|
|
|
|
|
// Miniplot
|
|
|
|
if (!vconsole) {
|
|
|
|
var overview = $.plot($('#overview_'+graph_id),datas, {
|
|
|
|
series: {
|
|
|
|
stack: stacked,
|
2018-04-24 13:19:24 +02:00
|
|
|
shadowSize: 0.1
|
|
|
|
},
|
|
|
|
crosshair: {
|
|
|
|
mode: 'xy'
|
|
|
|
},
|
|
|
|
selection: {
|
|
|
|
mode: 'xy',
|
|
|
|
color: '#777'
|
|
|
|
},
|
|
|
|
export: {
|
|
|
|
export_data: true,
|
2018-05-21 17:25:09 +02:00
|
|
|
labels_long: legend,
|
2018-04-24 13:19:24 +02:00
|
|
|
homeurl: homeurl
|
2018-02-16 13:41:31 +01:00
|
|
|
},
|
2018-02-23 14:31:00 +01:00
|
|
|
grid: {
|
|
|
|
hoverable: true,
|
2018-04-24 13:19:24 +02:00
|
|
|
clickable: true,
|
|
|
|
borderWidth:1,
|
|
|
|
borderColor: '#C1C1C1',
|
|
|
|
tickColor: background_color,
|
|
|
|
color: legend_color
|
2018-02-23 14:31:00 +01:00
|
|
|
},
|
2018-04-24 13:19:24 +02:00
|
|
|
xaxes: [{
|
2018-02-23 14:31:00 +01:00
|
|
|
axisLabelFontSizePixels: font_size,
|
|
|
|
mode: "time",
|
2018-06-06 11:18:39 +02:00
|
|
|
//tickFormatter: xFormatter,
|
2018-02-23 14:31:00 +01:00
|
|
|
tickSize: [maxticks, 'hour'],
|
2018-04-24 13:19:24 +02:00
|
|
|
}],
|
|
|
|
yaxes: [{
|
|
|
|
tickFormatter: yFormatter,
|
|
|
|
color: '',
|
|
|
|
alignTicksWithAxis: 1,
|
|
|
|
labelWidth: 30,
|
|
|
|
position: 'left',
|
|
|
|
font: font,
|
|
|
|
reserveSpace: true,
|
|
|
|
}],
|
2018-02-23 14:31:00 +01:00
|
|
|
legend: {
|
2018-04-24 13:19:24 +02:00
|
|
|
position: 'se',
|
|
|
|
container: $('#legend_' + graph_id),
|
|
|
|
labelFormatter: lFormatter
|
2018-02-23 14:31:00 +01:00
|
|
|
}
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
// Connection between plot and miniplot
|
|
|
|
|
|
|
|
$('#' + graph_id).bind('plotselected', function (event, ranges) {
|
|
|
|
// do the zooming if exist menu to undo it
|
|
|
|
if (menu == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2018-02-19 09:31:45 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
dataInSelection = ranges.xaxis.to - ranges.xaxis.from;
|
|
|
|
|
2018-02-21 11:54:24 +01:00
|
|
|
var maxticks_zoom = dataInSelection / 3600000 / 6;
|
2018-02-23 14:31:00 +01:00
|
|
|
if(maxticks_zoom < 0.001){
|
2018-02-21 11:54:24 +01:00
|
|
|
maxticks_zoom = dataInSelection / 60000 / 6;
|
2018-02-23 14:31:00 +01:00
|
|
|
if(maxticks_zoom < 0.001){
|
|
|
|
maxticks_zoom = 0;
|
2018-02-21 11:54:24 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-23 14:31:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
if (thresholded) {
|
2018-05-10 08:43:09 +02:00
|
|
|
data_base_treshold = add_threshold (
|
|
|
|
data_base,
|
|
|
|
threshold_data,
|
|
|
|
ranges.yaxis.from,
|
|
|
|
ranges.yaxis.to,
|
|
|
|
red_threshold,
|
|
|
|
extremes,
|
|
|
|
red_up,
|
|
|
|
markins_graph
|
|
|
|
);
|
|
|
|
|
|
|
|
plot = $.plot($('#' + graph_id), data_base_treshold,
|
|
|
|
$.extend(true, {}, options, {
|
|
|
|
grid: {
|
|
|
|
borderWidth: 1,
|
|
|
|
hoverable: true,
|
|
|
|
autoHighlight: true
|
|
|
|
},
|
|
|
|
xaxis: {
|
|
|
|
min: ranges.xaxis.from,
|
|
|
|
max: ranges.xaxis.to
|
|
|
|
},
|
|
|
|
xaxes: [{
|
|
|
|
mode: "time",
|
2018-06-06 11:18:39 +02:00
|
|
|
//tickFormatter: xFormatter,
|
2018-05-10 08:43:09 +02:00
|
|
|
tickSize: [maxticks_zoom, 'hour']
|
|
|
|
}],
|
|
|
|
yaxis:{
|
|
|
|
min: ranges.yaxis.from,
|
|
|
|
max: ranges.yaxis.to
|
|
|
|
},
|
|
|
|
yaxes: [{
|
|
|
|
tickFormatter: yFormatter,
|
|
|
|
color: '',
|
|
|
|
alignTicksWithAxis: 1,
|
|
|
|
labelWidth: 30,
|
|
|
|
position: 'left',
|
|
|
|
font: font,
|
|
|
|
reserveSpace: true,
|
|
|
|
}],
|
|
|
|
legend: {
|
|
|
|
show: true
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
else{
|
2018-02-16 13:41:31 +01:00
|
|
|
plot = $.plot($('#' + graph_id), data_base,
|
2018-05-10 08:43:09 +02:00
|
|
|
$.extend(true, {}, options, {
|
|
|
|
grid: {
|
|
|
|
borderWidth: 1,
|
|
|
|
hoverable: true,
|
|
|
|
autoHighlight: true
|
|
|
|
},
|
|
|
|
xaxis: {
|
|
|
|
min: ranges.xaxis.from,
|
|
|
|
max: ranges.xaxis.to
|
|
|
|
},
|
|
|
|
xaxes: [{
|
|
|
|
mode: "time",
|
2018-06-06 11:18:39 +02:00
|
|
|
//tickFormatter: xFormatter,
|
2018-05-10 08:43:09 +02:00
|
|
|
tickSize: [maxticks_zoom, 'hour']
|
|
|
|
}],
|
|
|
|
yaxis:{
|
|
|
|
min: ranges.yaxis.from,
|
|
|
|
max: ranges.yaxis.to
|
|
|
|
},
|
|
|
|
yaxes: [{
|
|
|
|
tickFormatter: yFormatter,
|
|
|
|
color: '',
|
|
|
|
alignTicksWithAxis: 1,
|
|
|
|
labelWidth: 30,
|
|
|
|
position: 'left',
|
|
|
|
font: font,
|
|
|
|
reserveSpace: true,
|
|
|
|
}],
|
|
|
|
legend: {
|
|
|
|
show: true
|
|
|
|
}
|
2018-02-16 13:41:31 +01:00
|
|
|
}));
|
|
|
|
}
|
2018-06-06 17:23:32 +02:00
|
|
|
|
2018-06-06 11:18:39 +02:00
|
|
|
$('#menu_cancelzoom_' + graph_id).attr('src', homeurl + '/images/zoom_cross_grey.png');
|
2018-02-16 13:41:31 +01:00
|
|
|
|
2018-05-10 08:43:09 +02:00
|
|
|
// currentRanges = ranges;
|
2018-02-16 13:41:31 +01:00
|
|
|
// don't fire event on the overview to prevent eternal loop
|
|
|
|
overview.setSelection(ranges, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#overview_' + graph_id)
|
|
|
|
.bind('plotselected', function (event, ranges) {
|
|
|
|
plot.setSelection(ranges);
|
|
|
|
});
|
|
|
|
|
|
|
|
var updateLegendTimeout = null;
|
2018-02-23 14:31:00 +01:00
|
|
|
var latestPosition = null;
|
|
|
|
var currentPlot = null;
|
|
|
|
var currentRanges = null;
|
2018-02-16 13:41:31 +01:00
|
|
|
|
|
|
|
// Update legend with the data of the plot in the mouse position
|
|
|
|
function updateLegend() {
|
|
|
|
updateLegendTimeout = null;
|
|
|
|
var pos = latestPosition;
|
|
|
|
var axes = currentPlot.getAxes();
|
|
|
|
if (pos.x < axes.xaxis.min || pos.x > axes.xaxis.max ||
|
|
|
|
pos.y < axes.yaxis.min || pos.y > axes.yaxis.max) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-23 14:31:00 +01:00
|
|
|
$('#timestamp_'+graph_id).show();
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-23 14:31:00 +01:00
|
|
|
var d = new Date(pos.x);
|
2018-02-27 16:28:00 +01:00
|
|
|
var monthNames = [
|
2018-02-23 14:31:00 +01:00
|
|
|
"Jan", "Feb", "Mar",
|
|
|
|
"Apr", "May", "Jun",
|
|
|
|
"Jul", "Aug", "Sep",
|
|
|
|
"Oct", "Nov", "Dec"
|
|
|
|
];
|
2018-02-27 16:28:00 +01:00
|
|
|
|
|
|
|
date_format = (d.getDate() <10?'0':'') + d.getDate() + " " +
|
2018-02-23 14:31:00 +01:00
|
|
|
monthNames[d.getMonth()] + " " +
|
2018-02-27 16:28:00 +01:00
|
|
|
d.getFullYear() + "\n" +
|
|
|
|
(d.getHours()<10?'0':'') + d.getHours() + ":" +
|
|
|
|
(d.getMinutes()<10?'0':'') + d.getMinutes() + ":" +
|
2018-02-23 14:31:00 +01:00
|
|
|
(d.getSeconds()<10?'0':'') + d.getSeconds();
|
2018-02-16 13:41:31 +01:00
|
|
|
|
2018-02-23 14:31:00 +01:00
|
|
|
$('#timestamp_'+graph_id).text(date_format);
|
2018-02-16 13:41:31 +01:00
|
|
|
|
2018-02-23 14:31:00 +01:00
|
|
|
var timesize = $('#timestamp_'+graph_id).width();
|
|
|
|
|
|
|
|
dataset = currentPlot.getData();
|
2018-02-16 13:41:31 +01:00
|
|
|
|
2018-02-23 14:31:00 +01:00
|
|
|
var timenewpos = dataset[0].xaxis.p2c(pos.x)+$('.yAxis>div').eq(0).width();
|
|
|
|
var canvaslimit = $('#'+graph_id).width();
|
2018-02-27 16:28:00 +01:00
|
|
|
|
|
|
|
$('#timestamp_'+graph_id)
|
|
|
|
.css('top', currentPlot.getPlotOffset().top -
|
|
|
|
$('#timestamp_'+graph_id).height() +
|
|
|
|
$('#legend_' + graph_id).height());
|
2018-02-23 14:31:00 +01:00
|
|
|
|
|
|
|
if (timesize+timenewpos > canvaslimit) {
|
|
|
|
$('#timestamp_'+graph_id).css('left', timenewpos - timesize);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#timestamp_'+graph_id).css('left', timenewpos);
|
|
|
|
}
|
|
|
|
|
|
|
|
var dataset = currentPlot.getData();
|
|
|
|
var i = 0;
|
|
|
|
for (k = 0; k < dataset.length; k++) {
|
2018-02-16 13:41:31 +01:00
|
|
|
// k is the real series counter
|
|
|
|
// i is the series counter without thresholds
|
|
|
|
var series = dataset[k];
|
|
|
|
if (series.label == null) {
|
|
|
|
continue;
|
|
|
|
}
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
// find the nearest points, x-wise
|
2018-02-23 14:31:00 +01:00
|
|
|
for (j = 0; j < series.data.length; ++j){
|
2018-02-16 13:41:31 +01:00
|
|
|
if (series.data[j][0] > pos.x) {
|
|
|
|
break;
|
|
|
|
}
|
2018-02-23 14:31:00 +01:00
|
|
|
|
|
|
|
if(series.data[j]){
|
|
|
|
var y = series.data[j][1];
|
|
|
|
}
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var how_bigger = "";
|
|
|
|
if (y > 1000000) {
|
|
|
|
how_bigger = "M";
|
|
|
|
y = y / 1000000;
|
|
|
|
}
|
|
|
|
else if (y > 1000) {
|
|
|
|
how_bigger = "K";
|
|
|
|
y = y / 1000;
|
|
|
|
}
|
|
|
|
else if(y < -1000000) {
|
|
|
|
how_bigger = "M";
|
|
|
|
y = y / 1000000;
|
|
|
|
}
|
|
|
|
else if (y < -1000) {
|
|
|
|
how_bigger = "K";
|
2018-02-27 16:28:00 +01:00
|
|
|
y = y / 1000;
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
|
|
|
|
2018-06-06 11:18:39 +02:00
|
|
|
var label_aux = legend[series.label];
|
2018-02-16 13:41:31 +01:00
|
|
|
|
|
|
|
// The graphs of points type and unknown graphs will dont be updated
|
2018-02-27 16:28:00 +01:00
|
|
|
if (series_type[dataset[k]["label"]] != 'points' &&
|
2018-02-23 14:31:00 +01:00
|
|
|
series_type[dataset[k]["label"]] != 'unknown' &&
|
|
|
|
series_type[dataset[k]["label"]] != 'percentil'
|
|
|
|
) {
|
2018-02-16 13:41:31 +01:00
|
|
|
$('#legend_' + graph_id + ' .legendLabel')
|
2018-02-27 16:28:00 +01:00
|
|
|
.eq(i).html(label_aux + ' value = ' +
|
2018-03-01 10:13:55 +01:00
|
|
|
(short_data ? number_format(y, 0, "", short_data) : parseFloat(y)) +
|
2018-02-23 14:31:00 +01:00
|
|
|
how_bigger + ' ' + unit
|
|
|
|
);
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$('#legend_' + graph_id + ' .legendLabel')
|
|
|
|
.eq(i).css('font-size',font_size+'pt');
|
|
|
|
|
|
|
|
$('#legend_' + graph_id + ' .legendLabel')
|
|
|
|
.eq(i).css('color','');
|
|
|
|
|
|
|
|
$('#legend_' + graph_id + ' .legendLabel')
|
|
|
|
.eq(i).css('font-family',font+'Font');
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Events
|
2018-02-23 14:31:00 +01:00
|
|
|
$('#overview_' + graph_id).bind('plothover', function (event, pos, item) {
|
|
|
|
plot.setCrosshair({ x: pos.x, y: 0 });
|
|
|
|
currentPlot = plot;
|
|
|
|
latestPosition = pos;
|
|
|
|
if (!updateLegendTimeout) {
|
|
|
|
updateLegendTimeout = setTimeout(updateLegend, 50);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
$('#' + graph_id).bind('plothover', function (event, pos, item) {
|
|
|
|
overview.setCrosshair({ x: pos.x, y: 0 });
|
|
|
|
currentPlot = plot;
|
|
|
|
latestPosition = pos;
|
|
|
|
if (!updateLegendTimeout) {
|
|
|
|
updateLegendTimeout = setTimeout(updateLegend, 50);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#' + graph_id).bind("plotclick", function (event, pos, item) {
|
|
|
|
plot.unhighlight();
|
2018-05-10 08:43:09 +02:00
|
|
|
if(item && item.series.label != '' && item.series.label != null &&
|
2018-03-01 09:46:52 +01:00
|
|
|
( (item.series.label.search("alert") >= 0) ||
|
|
|
|
(item.series.label.search("event") >= 0) )
|
|
|
|
){
|
2018-02-16 13:41:31 +01:00
|
|
|
plot.unhighlight();
|
|
|
|
|
2018-03-01 09:46:52 +01:00
|
|
|
$('#extra_'+graph_id).css('width', '170px');
|
|
|
|
$('#extra_'+graph_id).css('height', '60px');
|
|
|
|
|
|
|
|
var dataset = plot.getData();
|
|
|
|
var extra_info = '<i>No info to show</i>';
|
|
|
|
var extra_show = false;
|
|
|
|
var extra_height = $('#extra_'+graph_id).height();
|
|
|
|
var extra_width = parseInt($('#extra_'+graph_id)
|
|
|
|
.css('width')
|
|
|
|
.split('px')[0]);
|
|
|
|
var events_data = new Array();
|
|
|
|
var offset_graph = plot.getPlotOffset();
|
|
|
|
var offset_relative = plot.offset();
|
|
|
|
var width_graph = plot.width();
|
|
|
|
var height_legend = $('#legend_' + graph_id).height();
|
|
|
|
var coord_x = pos.pageX - offset_relative.left + offset_graph.left;
|
|
|
|
var coord_y = offset_graph.top + height_legend + extra_height;
|
|
|
|
|
|
|
|
if(coord_x + extra_width > width_graph){
|
|
|
|
coord_x = coord_x - extra_width;
|
|
|
|
}
|
2018-02-16 13:41:31 +01:00
|
|
|
|
2018-03-01 09:46:52 +01:00
|
|
|
var coord_y = offset_graph.top + height_legend + extra_height;
|
2018-02-16 13:41:31 +01:00
|
|
|
|
|
|
|
$('#extra_'+graph_id).css('left',coord_x);
|
2018-03-01 09:46:52 +01:00
|
|
|
$('#extra_'+graph_id).css('top', coord_y );
|
|
|
|
|
|
|
|
if( (item.series.label.search("alert") >= 0) ||
|
|
|
|
(item.series.label.search("event") >= 0) ){
|
|
|
|
|
|
|
|
$.each(events_array, function (i, v) {
|
|
|
|
$.each(v, function (index, value) {
|
2018-05-10 08:43:09 +02:00
|
|
|
if(value.utimestamp == item.datapoint[0]/1000 ||
|
|
|
|
value.utimestamp == (item.datapoint[0]/1000) - 1){
|
2018-03-01 09:46:52 +01:00
|
|
|
events_data = value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
if(events_data.event_type.search("alert") >= 0){
|
|
|
|
$extra_color = '#FFA631';
|
|
|
|
}
|
|
|
|
else if(events_data.event_type.search("critical") >= 0){
|
|
|
|
$extra_color = '#FC4444';
|
|
|
|
}
|
|
|
|
else if(events_data.event_type.search("warning") >= 0){
|
|
|
|
$extra_color = '#FAD403';
|
|
|
|
}
|
|
|
|
else if(events_data.event_type.search("unknown") >= 0){
|
|
|
|
$extra_color = '#3BA0FF';
|
|
|
|
}
|
|
|
|
else if(events_data.event_type.search("normal") >= 0){
|
|
|
|
$extra_color = '#80BA27';
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$extra_color = '#ffffff';
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#extra_'+graph_id).css('background-color',$extra_color);
|
|
|
|
|
|
|
|
extra_info = '<b>'+events_data.evento+':';
|
|
|
|
extra_info += '<br><br><span style="font-weight: normal;">Time: '+events_data.timestamp;
|
|
|
|
extra_show = true;
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (extra_show) {
|
|
|
|
$('#extra_'+graph_id).html(extra_info);
|
|
|
|
$('#extra_'+graph_id).css('display','');
|
|
|
|
}
|
|
|
|
plot.highlight(item.series, item.datapoint);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#extra_'+graph_id).html('');
|
|
|
|
$('#extra_'+graph_id).css('display','none');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-06 11:18:39 +02:00
|
|
|
$('#'+graph_id).bind('mouseout',resetInteractivity(vconsole));
|
|
|
|
|
|
|
|
if(!vconsole){
|
|
|
|
$('#overview_'+graph_id).bind('mouseout',resetInteractivity);
|
|
|
|
}
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-06-06 17:23:32 +02:00
|
|
|
if(image_treshold){
|
|
|
|
if(!thresholded){
|
|
|
|
// Recalculate the y axis
|
|
|
|
var y_recal = axis_thresholded(
|
|
|
|
threshold_data,
|
|
|
|
plot.getAxes().yaxis.min,
|
|
|
|
plot.getAxes().yaxis.max,
|
|
|
|
red_threshold, extremes,
|
|
|
|
red_up
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
var y_recal = plot.getAxes().yaxis.max
|
|
|
|
}
|
|
|
|
|
|
|
|
datas_treshold = add_threshold (
|
|
|
|
data_base,
|
|
|
|
threshold_data,
|
|
|
|
plot.getAxes().yaxis.min,
|
|
|
|
plot.getAxes().yaxis.max,
|
|
|
|
red_threshold,
|
|
|
|
extremes,
|
|
|
|
red_up,
|
|
|
|
markins_graph
|
|
|
|
);
|
|
|
|
|
|
|
|
plot = $.plot($('#' + graph_id), datas_treshold,
|
|
|
|
$.extend(true, {}, options, {
|
|
|
|
yaxis: {
|
|
|
|
max: y_recal.max,
|
|
|
|
},
|
|
|
|
xaxis: {
|
|
|
|
min: plot.getAxes().xaxis.min,
|
|
|
|
max: plot.getAxes().xaxis.max
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
|
|
|
thresholded = true;
|
|
|
|
}
|
|
|
|
|
2018-02-23 14:31:00 +01:00
|
|
|
// Reset interactivity styles
|
2018-06-06 11:18:39 +02:00
|
|
|
function resetInteractivity(vconsole) {
|
2018-02-16 13:41:31 +01:00
|
|
|
$('#timestamp_'+graph_id).hide();
|
|
|
|
dataset = plot.getData();
|
|
|
|
for (i = 0; i < dataset.length; ++i) {
|
|
|
|
var series = dataset[i];
|
2018-06-06 11:18:39 +02:00
|
|
|
var label_aux = legend[series.label];
|
2018-02-16 13:41:31 +01:00
|
|
|
$('#legend_' + graph_id + ' .legendLabel')
|
|
|
|
.eq(i).html(label_aux);
|
|
|
|
}
|
|
|
|
plot.clearCrosshair();
|
2018-06-06 11:18:39 +02:00
|
|
|
if(!vconsole){
|
|
|
|
overview.clearCrosshair();
|
|
|
|
}
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Format functions
|
|
|
|
function xFormatter(v, axis) {
|
|
|
|
var d = new Date(v);
|
|
|
|
var result_date_format = 0;
|
2018-02-23 14:31:00 +01:00
|
|
|
|
2018-02-27 16:28:00 +01:00
|
|
|
var monthNames = [
|
2018-02-23 14:31:00 +01:00
|
|
|
"Jan", "Feb", "Mar",
|
|
|
|
"Apr", "May", "Jun",
|
|
|
|
"Jul", "Aug", "Sep",
|
|
|
|
"Oct", "Nov", "Dec"
|
|
|
|
];
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-23 14:31:00 +01:00
|
|
|
result_date_format = (d.getDate() <10?'0':'') + d.getDate() + " " +
|
|
|
|
monthNames[d.getMonth()] + " " +
|
2018-02-27 16:28:00 +01:00
|
|
|
d.getFullYear() + "\n" +
|
|
|
|
(d.getHours()<10?'0':'') + d.getHours() + ":" +
|
|
|
|
(d.getMinutes()<10?'0':'') + d.getMinutes() + ":" +
|
2018-02-23 14:31:00 +01:00
|
|
|
(d.getSeconds()<10?'0':'') + d.getSeconds();
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-21 11:54:24 +01:00
|
|
|
return '<div class='+font+' style="font-size:'+font_size+'pt; margin-top:15px;">'+result_date_format+'</div>';
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function yFormatter(v, axis) {
|
|
|
|
axis.datamin = 0;
|
|
|
|
if (short_data) {
|
2018-02-28 14:33:22 +01:00
|
|
|
var formatted = number_format(v, force_integer, "", short_data);
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
|
|
|
else {
|
2018-03-09 10:18:02 +01:00
|
|
|
// It is an integer
|
|
|
|
if(v - Math.floor(v) == 0){
|
|
|
|
var formatted = number_format(v, force_integer, "", 2);
|
|
|
|
} else {
|
|
|
|
var formatted = v;
|
|
|
|
}
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
2016-05-26 08:57:33 +02:00
|
|
|
|
2018-04-17 11:54:52 +02:00
|
|
|
// Get only two decimals
|
2018-06-06 11:18:39 +02:00
|
|
|
formatted = round_with_decimals(formatted, 100);
|
2018-02-16 13:41:31 +01:00
|
|
|
return '<div class='+font+' style="font-size:'+font_size+'pt;">'+formatted+'</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
function lFormatter(v, item) {
|
2018-02-23 14:31:00 +01:00
|
|
|
return '<div style="font-size:'+font_size+'pt;">'+legend[v]+'</div>';
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
if (menu) {
|
|
|
|
var parent_height;
|
|
|
|
$('#menu_overview_' + graph_id).click(function() {
|
2018-04-26 10:24:37 +02:00
|
|
|
$('#overview_' + graph_id).toggle();
|
|
|
|
/*
|
2018-04-24 13:19:24 +02:00
|
|
|
if($('#overview_' + graph_id).css('visibility') == 'visible'){
|
|
|
|
$('#overview_' + graph_id).css('visibility', 'hidden');
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$('#overview_' + graph_id).css('visibility', 'visible');
|
|
|
|
}
|
2018-04-26 10:24:37 +02:00
|
|
|
*/
|
2018-02-16 13:41:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$("#menu_export_csv_"+graph_id)
|
|
|
|
.click(function (event) {
|
|
|
|
event.preventDefault();
|
|
|
|
plot.exportDataCSV();
|
|
|
|
});
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
$('#menu_threshold_' + graph_id).click(function() {
|
|
|
|
datas = new Array();
|
|
|
|
|
|
|
|
if (thresholded) {
|
|
|
|
$.each(data_base, function() {
|
|
|
|
datas.push(this);
|
|
|
|
});
|
2018-05-10 08:43:09 +02:00
|
|
|
|
|
|
|
delete data_base[0].threshold;
|
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
plot = $.plot($('#' + graph_id), data_base,
|
|
|
|
$.extend(true, {}, options, {
|
2018-05-10 08:43:09 +02:00
|
|
|
yaxis: {
|
|
|
|
max: max_draw
|
|
|
|
},
|
2018-02-16 13:41:31 +01:00
|
|
|
xaxis: {
|
|
|
|
min: plot.getAxes().xaxis.min,
|
|
|
|
max: plot.getAxes().xaxis.max
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
thresholded = false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var max_draw = plot.getAxes().yaxis.datamax;
|
|
|
|
|
2018-05-10 08:43:09 +02:00
|
|
|
if(!thresholded){
|
|
|
|
// Recalculate the y axis
|
|
|
|
var y_recal = axis_thresholded(
|
|
|
|
threshold_data,
|
|
|
|
plot.getAxes().yaxis.min,
|
|
|
|
plot.getAxes().yaxis.max,
|
|
|
|
red_threshold, extremes,
|
|
|
|
red_up
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
var y_recal = plot.getAxes().yaxis.max
|
|
|
|
}
|
|
|
|
|
|
|
|
datas_treshold = add_threshold (
|
|
|
|
data_base,
|
|
|
|
threshold_data,
|
|
|
|
plot.getAxes().yaxis.min,
|
|
|
|
plot.getAxes().yaxis.max,
|
|
|
|
red_threshold,
|
|
|
|
extremes,
|
|
|
|
red_up,
|
|
|
|
markins_graph
|
|
|
|
);
|
|
|
|
|
|
|
|
plot = $.plot($('#' + graph_id), datas_treshold,
|
2018-02-21 11:54:24 +01:00
|
|
|
$.extend(true, {}, options, {
|
|
|
|
yaxis: {
|
|
|
|
max: y_recal.max,
|
|
|
|
},
|
|
|
|
xaxis: {
|
2018-05-10 08:43:09 +02:00
|
|
|
min: plot.getAxes().xaxis.min,
|
|
|
|
max: plot.getAxes().xaxis.max
|
2018-02-21 11:54:24 +01:00
|
|
|
}
|
|
|
|
}));
|
2018-02-16 13:41:31 +01:00
|
|
|
|
|
|
|
thresholded = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#menu_cancelzoom_' + graph_id).click(function() {
|
|
|
|
// cancel the zooming
|
2018-05-10 08:43:09 +02:00
|
|
|
delete data_base[0].threshold;
|
2018-02-16 13:41:31 +01:00
|
|
|
plot = $.plot($('#' + graph_id), data_base,
|
|
|
|
$.extend(true, {}, options, {
|
2018-02-19 09:31:45 +01:00
|
|
|
legend: { show: true }
|
2018-02-16 13:41:31 +01:00
|
|
|
}));
|
|
|
|
$('#menu_cancelzoom_' + graph_id)
|
|
|
|
.attr('src', homeurl + '/images/zoom_cross.disabled.png');
|
|
|
|
overview.clearSelection();
|
|
|
|
currentRanges = null;
|
|
|
|
thresholded = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Adjust the menu image on top of the plot
|
|
|
|
// If there is no legend we increase top-padding to make space to the menu
|
|
|
|
if (legend.length == 0) {
|
|
|
|
$('#menu_' + graph_id).parent().css('padding-top',
|
|
|
|
$('#menu_' + graph_id).css('height'));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add bottom margin in the legend
|
|
|
|
// Estimated height of 24 (works fine with this data in all browsers)
|
|
|
|
menu_height = 24;
|
|
|
|
var legend_margin_bottom = parseInt(
|
2018-02-23 14:31:00 +01:00
|
|
|
$('#legend_'+graph_id).css('margin-bottom').split('px')[0]);
|
2018-02-16 13:41:31 +01:00
|
|
|
$('#legend_'+graph_id).css('margin-bottom', '10px');
|
2018-02-23 14:31:00 +01:00
|
|
|
parent_height = parseInt($('#menu_'+graph_id).parent().css('height').split('px')[0]);
|
2018-06-06 11:18:39 +02:00
|
|
|
adjust_menu(graph_id, plot, parent_height, width, show_legend);
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
if (!dashboard) {
|
2018-06-07 09:15:45 +02:00
|
|
|
if (water_mark){
|
2018-02-16 13:41:31 +01:00
|
|
|
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
2018-06-07 09:15:45 +02:00
|
|
|
}
|
|
|
|
//adjust_menu(graph_id, plot, parent_height, width, show_legend);
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
|
2018-06-06 11:18:39 +02:00
|
|
|
function adjust_menu(graph_id, plot, parent_height, width, show_legend) {
|
2016-05-26 08:57:33 +02:00
|
|
|
if ($('#'+graph_id+' .xAxis .tickLabel').eq(0).css('width') != undefined) {
|
|
|
|
left_ticks_width = $('#'+graph_id+' .xAxis .tickLabel').eq(0).css('width').split('px')[0];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
left_ticks_width = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
var parent_height_new = 0;
|
|
|
|
|
2018-06-06 11:18:39 +02:00
|
|
|
if(show_legend){
|
|
|
|
var legend_height = parseInt($('#legend_'+graph_id).css('height').split('px')[0]) + parseInt($('#legend_'+graph_id).css('margin-top').split('px')[0]);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
var legend_height = 0;
|
|
|
|
}
|
2016-05-26 08:57:33 +02:00
|
|
|
|
|
|
|
var menu_height = '25';
|
|
|
|
|
|
|
|
if ($('#menu_'+graph_id).height() != undefined && $('#menu_'+graph_id).height() > 20) {
|
|
|
|
menu_height = $('#menu_'+graph_id).height();
|
|
|
|
}
|
|
|
|
|
2017-03-17 13:30:11 +01:00
|
|
|
offset = $('#' + graph_id)[0].offsetTop;
|
2016-05-26 08:57:33 +02:00
|
|
|
|
2018-04-24 13:19:24 +02:00
|
|
|
$('#menu_' + graph_id).css('top', ((offset) + 'px'));
|
2016-05-26 08:57:33 +02:00
|
|
|
|
|
|
|
$('#menu_' + graph_id).show();
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_watermark(graph_id, plot, watermark_src) {
|
|
|
|
var img = new Image();
|
2018-06-07 09:15:45 +02:00
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
img.src = watermark_src;
|
|
|
|
var context = plot.getCanvas().getContext('2d');
|
|
|
|
|
|
|
|
// Once it's loaded draw the image on the canvas.
|
|
|
|
img.addEventListener('load', function () {
|
2018-06-07 09:15:45 +02:00
|
|
|
// Now resize the image: x, y, w, h.
|
2016-05-26 08:57:33 +02:00
|
|
|
var down_ticks_height = 0;
|
|
|
|
if ($('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height') != undefined) {
|
|
|
|
down_ticks_height = $('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height').split('px')[0];
|
|
|
|
}
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2018-06-07 09:15:45 +02:00
|
|
|
var left_pos = parseInt(context.canvas.width) - $('#watermark_image_'+graph_id)[0].width - 30;
|
|
|
|
var top_pos = 7;
|
2017-02-20 11:13:47 +01:00
|
|
|
//var top_pos = parseInt(context.canvas.height - down_ticks_height - 10) - $('#watermark_image_'+graph_id)[0].height;
|
|
|
|
//var left_pos = 380;
|
2016-05-26 08:57:33 +02:00
|
|
|
context.drawImage(this, left_pos, top_pos);
|
|
|
|
|
|
|
|
}, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_event_details (event_ids) {
|
|
|
|
table = '';
|
|
|
|
if (typeof(event_ids) != "undefined") {
|
|
|
|
var inputs = [];
|
|
|
|
var table;
|
|
|
|
inputs.push ("get_events_details=1");
|
|
|
|
inputs.push ("event_ids="+event_ids);
|
|
|
|
inputs.push ("page=include/ajax/events");
|
|
|
|
|
|
|
|
// Autologin
|
|
|
|
if ($('#hidden-loginhash').val() != undefined) {
|
|
|
|
inputs.push ("loginhash=" + $('#hidden-loginhash').val());
|
|
|
|
inputs.push ("loginhash_data=" + $('#hidden-loginhash_data').val());
|
|
|
|
inputs.push ("loginhash_user=" + $('#hidden-loginhash_user').val());
|
|
|
|
}
|
|
|
|
|
|
|
|
jQuery.ajax ({
|
|
|
|
data: inputs.join ("&"),
|
|
|
|
type: 'GET',
|
|
|
|
url: action="../../ajax.php",
|
|
|
|
timeout: 10000,
|
|
|
|
dataType: 'html',
|
|
|
|
async: false,
|
|
|
|
success: function (data) {
|
|
|
|
table = data;
|
|
|
|
//forced_title_callback();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
|
2018-04-26 10:24:37 +02:00
|
|
|
//Ajusta la grafica pequenña con el desplazamiento del eje y
|
2016-05-26 08:57:33 +02:00
|
|
|
function adjust_left_width_canvas(adapter_id, adapted_id) {
|
2016-06-06 17:01:34 +02:00
|
|
|
var adapter_left_margin = $('#'+adapter_id+' .yAxis .tickLabel').width();
|
|
|
|
var adapted_pix = $('#'+adapted_id).width();
|
|
|
|
var new_adapted_width = adapted_pix - adapter_left_margin;
|
|
|
|
$('#'+adapted_id).width(new_adapted_width);
|
|
|
|
$('#'+adapted_id).css('margin-left', adapter_left_margin);
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 10:24:37 +02:00
|
|
|
//Ajusta el ancho de la grafica pequeña con respecto a la grande
|
2017-11-14 18:44:29 +01:00
|
|
|
function update_left_width_canvas(graph_id) {
|
2018-04-24 13:19:24 +02:00
|
|
|
$('#overview_'+graph_id).width($('#'+graph_id).width());
|
2017-11-14 18:44:29 +01:00
|
|
|
$('#overview_'+graph_id).css('margin-left', $('#'+graph_id+' .yAxis .tickLabel').width());
|
|
|
|
}
|
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
function check_adaptions(graph_id) {
|
|
|
|
var classes = $('#'+graph_id).attr('class').split(' ');
|
|
|
|
|
|
|
|
$.each(classes, function(i,v) {
|
|
|
|
// If has a class starting with adapted, we adapt it
|
|
|
|
if (v.split('_')[0] == 'adapted') {
|
|
|
|
var adapter_id = $('.adapter_'+v.split('_')[1]).attr('id');
|
|
|
|
adjust_left_width_canvas(adapter_id, graph_id);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-02-28 14:33:22 +01:00
|
|
|
function number_format(number, force_integer, unit, short_data) {
|
2016-05-26 08:57:33 +02:00
|
|
|
if (force_integer) {
|
|
|
|
if (Math.round(number) != number) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2018-02-28 14:33:22 +01:00
|
|
|
short_data ++;
|
|
|
|
decimals = pad(1, short_data, 0);
|
|
|
|
number = Math.round(number * decimals) / decimals;
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var shorts = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"];
|
|
|
|
var pos = 0;
|
|
|
|
while (1) {
|
|
|
|
if (number >= 1000) { //as long as the number can be divided by 1000
|
|
|
|
pos++; //Position in array starting with 0
|
|
|
|
number = number / 1000;
|
|
|
|
}
|
2017-08-29 09:28:05 +02:00
|
|
|
else if (number <= -1000) {
|
|
|
|
pos++;
|
|
|
|
number = number / 1000;
|
|
|
|
}
|
2016-05-26 08:57:33 +02:00
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
return number + ' ' + shorts[pos] + unit;
|
|
|
|
}
|
2018-02-28 14:33:22 +01:00
|
|
|
|
2018-05-10 08:43:09 +02:00
|
|
|
function pad(input, length, padding) {
|
2018-02-28 14:33:22 +01:00
|
|
|
var str = input + "";
|
|
|
|
return (length <= str.length) ? str : pad(str+padding, length, padding);
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2017-03-22 11:30:41 +01:00
|
|
|
// Recalculate the threshold data depends on warning and critical
|
|
|
|
function axis_thresholded (threshold_data, y_min, y_max, red_threshold, extremes, red_up) {
|
|
|
|
var y = {
|
|
|
|
min: 0,
|
|
|
|
max: 0
|
|
|
|
};
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2017-03-22 11:30:41 +01:00
|
|
|
// Default values
|
|
|
|
var yaxis_resize = {
|
|
|
|
up: null,
|
|
|
|
normal_up: 0,
|
|
|
|
normal_down: 0,
|
|
|
|
down: null
|
|
|
|
};
|
|
|
|
// Resize the y axis to display all intervals
|
|
|
|
$.each(threshold_data, function() {
|
|
|
|
if (/_up/.test(this.id)){
|
|
|
|
yaxis_resize['up'] = this.data[0][1];
|
|
|
|
}
|
|
|
|
if (/_down/.test(this.id)){
|
|
|
|
if (/critical/.test(this.id)) {
|
|
|
|
yaxis_resize['down'] = red_threshold;
|
|
|
|
} else {
|
|
|
|
yaxis_resize['down'] = extremes[this.id];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (/_normal/.test(this.id)){
|
|
|
|
var end;
|
|
|
|
if (/critical/.test(this.id)) {
|
|
|
|
end = red_up;
|
|
|
|
} else {
|
|
|
|
end = extremes[this.id + '_2'];
|
|
|
|
}
|
|
|
|
if (yaxis_resize['normal_up'] < end) yaxis_resize['normal_up'] = end;
|
|
|
|
if (yaxis_resize['normal_down'] > this.data[0][1]) yaxis_resize['normal_down'] = this.data[0][1];
|
|
|
|
}
|
|
|
|
});
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2017-03-22 11:30:41 +01:00
|
|
|
// If you need to display a up or a down bar, display 10% of data height
|
|
|
|
var margin_up_or_down = (y_max - y_min)*0.10;
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2017-03-22 11:30:41 +01:00
|
|
|
// Calculate the new axis
|
|
|
|
y['max'] = yaxis_resize['normal_up'] > y_max ? yaxis_resize['normal_up'] : y_max;
|
|
|
|
y['min'] = yaxis_resize['normal_down'] > y_min ? yaxis_resize['normal_down'] : y_min;
|
|
|
|
if (yaxis_resize['up'] !== null) {
|
|
|
|
y['max'] = (yaxis_resize['up'] + margin_up_or_down) < y_max
|
|
|
|
? y_max
|
|
|
|
: yaxis_resize['up'] + margin_up_or_down;
|
|
|
|
}
|
|
|
|
if (yaxis_resize['down'] !== null) {
|
|
|
|
y['min'] = (yaxis_resize['down'] - margin_up_or_down) < y_min
|
|
|
|
? yaxis_resize['up'] + margin_up_or_down
|
|
|
|
: y_min;
|
|
|
|
}
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2017-03-22 11:30:41 +01:00
|
|
|
return y;
|
|
|
|
}
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2018-05-10 08:43:09 +02:00
|
|
|
//add treshold
|
2017-03-22 11:30:41 +01:00
|
|
|
function add_threshold (data_base, threshold_data, y_min, y_max,
|
2018-05-10 08:43:09 +02:00
|
|
|
red_threshold, extremes, red_up, markins_graph) {
|
2016-05-26 08:57:33 +02:00
|
|
|
var datas = new Array ();
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
$.each(data_base, function() {
|
2018-05-10 08:43:09 +02:00
|
|
|
datas.push(this);
|
2016-05-26 08:57:33 +02:00
|
|
|
});
|
|
|
|
|
2018-05-10 08:43:09 +02:00
|
|
|
var threshold_array = [];
|
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
// Resize the threshold data
|
2018-05-10 08:43:09 +02:00
|
|
|
$.each(threshold_data, function(index, value) {
|
|
|
|
threshold_array[index] = [];
|
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
if (/_up/.test(this.id)){
|
|
|
|
this.bars.barWidth = y_max - this.data[0][1];
|
2018-05-10 08:43:09 +02:00
|
|
|
|
|
|
|
if (/critical/.test(this.id)){
|
|
|
|
threshold_array[index]['min'] = this.data[0][1];
|
|
|
|
threshold_array[index]['max'] = y_max;
|
|
|
|
threshold_array[index]['color'] = "red";
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
threshold_array[index]['min'] = this.data[0][1];
|
|
|
|
threshold_array[index]['max'] = y_max;
|
|
|
|
threshold_array[index]['color'] = "yellow";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(y_min > this.data[0][1]){
|
|
|
|
this.bars.barWidth = this.bars.barWidth - (y_min - this.data[0][1]);
|
|
|
|
this.data[0][1] = y_min;
|
|
|
|
}
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
if (/_down/.test(this.id)){
|
|
|
|
var end;
|
|
|
|
if (/critical/.test(this.id)) {
|
2018-04-27 13:51:13 +02:00
|
|
|
end = red_threshold;
|
2016-05-26 08:57:33 +02:00
|
|
|
} else {
|
|
|
|
end = extremes[this.id];
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
this.bars.barWidth = end - y_min;
|
|
|
|
this.data[0][1] = y_min;
|
2018-05-10 08:43:09 +02:00
|
|
|
|
|
|
|
if (/critical/.test(this.id)){
|
|
|
|
threshold_array[index]['min'] = this.data[0][1];
|
|
|
|
threshold_array[index]['max'] = this.bars.barWidth;
|
|
|
|
threshold_array[index]['color'] = "red";
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
threshold_array[index]['min'] = this.data[0][1];
|
|
|
|
threshold_array[index]['max'] = this.bars.barWidth;
|
|
|
|
threshold_array[index]['color'] = "yellow";
|
|
|
|
}
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
if (/_normal/.test(this.id)){
|
|
|
|
var end;
|
|
|
|
if (/critical/.test(this.id)) {
|
|
|
|
end = red_up;
|
2018-05-10 08:43:09 +02:00
|
|
|
threshold_array[index]['min'] = this.data[0][1];
|
|
|
|
threshold_array[index]['max'] = end;
|
|
|
|
threshold_array[index]['color'] = "red";
|
2016-05-26 08:57:33 +02:00
|
|
|
} else {
|
2018-06-06 17:23:32 +02:00
|
|
|
var first = extremes[this.id + '_1'];
|
|
|
|
var second = extremes[this.id + '_2'];
|
|
|
|
if(first > second){
|
|
|
|
end = first;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
end = second;
|
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
threshold_array[index]['min'] = this.data[0][1];
|
|
|
|
threshold_array[index]['max'] = end;
|
|
|
|
threshold_array[index]['color'] = "yellow";
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
if (this.data[0][1] < y_min) {
|
|
|
|
this.bars.barWidth = end - y_min;
|
|
|
|
this.data[0][1] = y_min;
|
|
|
|
end = this.bars.barWidth + this.data[0][1];
|
2018-05-10 08:43:09 +02:00
|
|
|
|
|
|
|
if (/critical/.test(this.id)){
|
|
|
|
threshold_array[index]['min'] = this.data[0][1];
|
|
|
|
threshold_array[index]['max'] = this.data[0][1] + this.bars.barWidth;
|
|
|
|
threshold_array[index]['color'] = "red";
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
threshold_array[index]['min'] = this.data[0][1];
|
|
|
|
threshold_array[index]['max'] = this.data[0][1] + this.bars.barWidth;
|
|
|
|
threshold_array[index]['color'] = "yellow";
|
|
|
|
}
|
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
if (end > y_max) {
|
|
|
|
this.bars.barWidth = y_max - this.data[0][1];
|
2018-05-10 08:43:09 +02:00
|
|
|
|
|
|
|
if (/critical/.test(this.id)){
|
|
|
|
threshold_array[index]['min'] = this.data[0][1];
|
|
|
|
threshold_array[index]['max'] = this.data[0][1] + this.bars.barWidth;
|
|
|
|
threshold_array[index]['color'] = "red";
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
threshold_array[index]['min'] = this.data[0][1];
|
|
|
|
threshold_array[index]['max'] = this.data[0][1] + this.bars.barWidth;
|
|
|
|
threshold_array[index]['color'] = "yellow";
|
|
|
|
}
|
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
}
|
2018-04-27 13:51:13 +02:00
|
|
|
}
|
2018-05-10 08:43:09 +02:00
|
|
|
|
|
|
|
if(markins_graph && this.bars.barWidth > 0){
|
|
|
|
datas.push(this);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var extreme_treshold_array = [];
|
|
|
|
var i = 0;
|
|
|
|
var flag = true;
|
2018-06-06 17:23:32 +02:00
|
|
|
|
2018-05-10 08:43:09 +02:00
|
|
|
$.each(threshold_array, function(index, value) {
|
|
|
|
flag = true;
|
|
|
|
extreme_treshold_array[i] = {
|
|
|
|
'below': value['max'],
|
|
|
|
'color': value['color'],
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
$.each(threshold_array, function(i, v) {
|
|
|
|
if(value['min'] == v['max']){
|
|
|
|
return flag = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if(flag){
|
|
|
|
extreme_treshold_array[i] = {
|
|
|
|
'below': value['min'],
|
|
|
|
'color': datas[0].color,
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2016-05-26 08:57:33 +02:00
|
|
|
});
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2018-05-10 08:43:09 +02:00
|
|
|
datas[0].threshold = extreme_treshold_array;
|
|
|
|
|
2016-05-26 08:57:33 +02:00
|
|
|
return datas;
|
|
|
|
}
|
2016-06-13 17:17:54 +02:00
|
|
|
|
|
|
|
function reduceText (text, maxLength) {
|
2018-03-21 13:40:15 +01:00
|
|
|
if(!text) return text;
|
2016-06-13 17:17:54 +02:00
|
|
|
if (text.length <= maxLength) return text
|
2018-03-21 13:40:15 +01:00
|
|
|
var firstSlideEnd = parseInt((maxLength - 3)/1.6);
|
2017-03-27 17:06:55 +02:00
|
|
|
var str_cut = text.substr(0, firstSlideEnd);
|
2018-03-21 13:40:15 +01:00
|
|
|
return str_cut + '...<br>' + text.substr(-firstSlideEnd - 3);
|
2016-06-13 17:17:54 +02:00
|
|
|
}
|