Improved critical and warning superposition in module graphs TICKETS #3515

This commit is contained in:
fermin831 2016-04-04 18:41:37 +02:00
parent d46b8a92ea
commit e71402e399

View File

@ -954,35 +954,155 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
// showed[i] = true; // showed[i] = true;
} }
//Array with points to be painted
var threshold_data = new Array(); var threshold_data = new Array();
//Array with some interesting points
var extremes = new Array ();
yellow_threshold = parseFloat (yellow_threshold);
yellow_up = parseFloat (yellow_up);
red_threshold = parseFloat (red_threshold);
red_up = parseFloat (red_up);
if (threshold) { if (threshold) {
// Warning interval // Warning interval. Change extremes depends on critical interval
if (yellow_inverse) { if (yellow_inverse && red_inverse) {
threshold_data.push({ // barWidth will be correct on draw time if (yellow_threshold > red_threshold) {
id: 'warning_up', // C: |-------- ------|
data: [[max_x, yellow_up]], // W: |········===· ···|
label: null, if (yellow_threshold > red_up) {
color: warning, yellow_threshold = red_up;
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true} }
}); threshold_data.push({
threshold_data.push({ // barWidth will be correct on draw time id: 'warning_normal_fdown',
id: 'warning_down', data: [[max_x, red_threshold]],
data: [[max_x, 0]], label: null,
label: null, color: warning,
color: warning, bars: {show: true, align: "left", barWidth: yellow_threshold - red_threshold, lineWidth: 0, horizontal: true}
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true} });
}); extremes['warning_normal_fdown_1'] = red_threshold;
} else { extremes['warning_normal_fdown_2'] = yellow_threshold;
if (yellow_up == 0) { }
if (yellow_up < red_up) {
// C: |-------- ---|
// W: |····· ·======···|
if (yellow_up < red_threshold) {
yellow_up = red_up;
}
threshold_data.push({
id: 'warning_normal_fup',
data: [[max_x, yellow_up]],
label: null,
color: warning,
bars: {show: true, align: "left", barWidth: red_up - yellow_up, lineWidth: 0, horizontal: true}
});
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 (yellow_threshold > red_up) {
// C: | ----- |
// W: |====·····=== ===|
threshold_data.push({ // barWidth will be correct on draw time threshold_data.push({ // barWidth will be correct on draw time
id: 'warning_up', id: 'warning_down',
data: [[max_x, yellow_threshold]], data: [[max_x, 0]],
label: null, label: null,
color: warning, color: warning,
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true} bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true}
}); });
extremes['warning_down'] = red_threshold;
threshold_data.push({
id: 'warning_normal_fdown',
data: [[max_x, red_up]],
label: null,
color: warning,
bars: {show: true, align: "left", barWidth: yellow_threshold - red_up, lineWidth: 0, horizontal: true}
});
extremes['warning_normal_fdown_1'] = red_up;
extremes['warning_normal_fdown_2'] = yellow_threshold;
threshold_data.push({ // barWidth will be correct on draw time
id: 'warning_up',
data: [[max_x, yellow_up]],
label: null,
color: warning,
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true}
});
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, 0]],
label: null,
color: warning,
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true}
});
extremes['warning_down'] = yellow_threshold;
threshold_data.push({
id: 'warning_normal_fup',
data: [[max_x, yellow_up]],
label: null,
color: warning,
bars: {show: true, align: "left", barWidth: yellow_up - red_threshold, lineWidth: 0, horizontal: true}
});
extremes['warning_normal_fup_1'] = yellow_up;
extremes['warning_normal_fup_2'] = red_threshold;
threshold_data.push({ // barWidth will be correct on draw time
id: 'warning_up',
data: [[max_x, yellow_up]],
label: null,
color: warning,
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true}
});
extremes['warning_up'] = yellow_up;
} else { } else {
// C: | -------- |
// W: |==· ···=======|
if (yellow_threshold > red_threshold) {
yellow_threshold = red_threshold;
}
if (yellow_up < red_up) {
yellow_up = red_up;
}
threshold_data.push({ // barWidth will be correct on draw time
id: 'warning_down',
data: [[max_x, 0]],
label: null,
color: warning,
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true}
});
extremes['warning_down'] = yellow_threshold;
threshold_data.push({ // barWidth will be correct on draw time
id: 'warning_up',
data: [[max_x, yellow_up]],
label: null,
color: warning,
bars: {show: true, align: "left", barWidth: 1, lineWidth: 0, horizontal: true}
});
extremes['warning_up'] = yellow_up;
}
} else if (!yellow_inverse && red_inverse) {
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;
}
threshold_data.push({ threshold_data.push({
id: 'warning_normal', id: 'warning_normal',
data: [[max_x, yellow_threshold]], data: [[max_x, yellow_threshold]],
@ -990,6 +1110,58 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
color: warning, color: warning,
bars: {show: true, align: "left", barWidth: (yellow_up - yellow_threshold), lineWidth: 0, horizontal: true} bars: {show: true, align: "left", barWidth: (yellow_up - yellow_threshold), lineWidth: 0, horizontal: true}
}); });
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_threshold > yellow_threshold && red_up < yellow_up ) {
// C: | ------ |
// W: | ==······==== |
threshold_data.push({
id: 'warning_normal_fdown',
data: [[max_x, yellow_threshold]],
label: null,
color: warning,
bars: {show: true, align: "left", barWidth: red_threshold - yellow_threshold, lineWidth: 0, horizontal: true}
});
extremes['warning_normal_fdown_1'] = yellow_threshold;
extremes['warning_normal_fdown_2'] = red_threshold;
threshold_data.push({
id: 'warning_normal_fup',
data: [[max_x, red_up]],
label: null,
color: warning,
bars: {show: true, align: "left", barWidth: yellow_up - red_up, lineWidth: 0, horizontal: true}
});
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,
color: warning,
bars: {show: true, align: "left", barWidth: (yellow_up - yellow_threshold), lineWidth: 0, horizontal: true}
});
extremes['warning_normal_1'] = yellow_threshold;
extremes['warning_normal_2'] = yellow_up;
} }
} }
// Critical interval // Critical interval
@ -1148,7 +1320,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
var zoom_data_threshold = new Array (); var zoom_data_threshold = new Array ();
zoom_data_threshold = add_threshold (data_base, threshold_data, plot.getAxes().yaxis.min, plot.getAxes().yaxis.max, zoom_data_threshold = add_threshold (data_base, threshold_data, plot.getAxes().yaxis.min, plot.getAxes().yaxis.max,
yellow_threshold, red_threshold, yellow_up, red_up); yellow_threshold, red_threshold, extremes, red_up);
plot.setData(zoom_data_threshold); plot.setData(zoom_data_threshold);
plot.draw(); plot.draw();
} }
@ -1604,9 +1776,8 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
}); });
thresholded = false; thresholded = false;
} else { } else {
//pocoyo
datas = add_threshold (data_base, threshold_data, plot.getAxes().yaxis.min, plot.getAxes().yaxis.max, datas = add_threshold (data_base, threshold_data, plot.getAxes().yaxis.min, plot.getAxes().yaxis.max,
yellow_threshold, red_threshold, yellow_up, red_up); yellow_threshold, red_threshold, extremes, red_up);
thresholded = true; thresholded = true;
} }
@ -1798,7 +1969,7 @@ function number_format(number, force_integer, unit) {
return number + ' ' + shorts[pos] + unit; return number + ' ' + shorts[pos] + unit;
} }
function add_threshold (data_base, threshold_data, y_min, y_max, yellow_threshold, function add_threshold (data_base, threshold_data, y_min, y_max, yellow_threshold,
red_threshold, yellow_up, red_up) { red_threshold, extremes, red_up) {
var datas = new Array (); var datas = new Array ();
@ -1809,7 +1980,7 @@ function add_threshold (data_base, threshold_data, y_min, y_max, yellow_threshol
//} //}
}); });
// Resize the warning and critical interval // Resize the threshold data
$.each(threshold_data, function() { $.each(threshold_data, function() {
if (/_up/.test(this.id)){ if (/_up/.test(this.id)){
this.bars.barWidth = y_max - this.data[0][1]; this.bars.barWidth = y_max - this.data[0][1];
@ -1819,7 +1990,7 @@ function add_threshold (data_base, threshold_data, y_min, y_max, yellow_threshol
if (/critical/.test(this.id)) { if (/critical/.test(this.id)) {
end = red_threshold; end = red_threshold;
} else { } else {
end = yellow_threshold; end = extremes[this.id];
} }
this.bars.barWidth = end - y_min; this.bars.barWidth = end - y_min;
this.data[0][1] = y_min; this.data[0][1] = y_min;
@ -1829,7 +2000,7 @@ function add_threshold (data_base, threshold_data, y_min, y_max, yellow_threshol
if (/critical/.test(this.id)) { if (/critical/.test(this.id)) {
end = red_up; end = red_up;
} else { } else {
end = yellow_up; end = extremes[this.id + '_2'];
} }
if (this.data[0][1] < y_min) { if (this.data[0][1] < y_min) {
this.bars.barWidth = end - y_min; this.bars.barWidth = end - y_min;