Now the boolean charts is showed as digital signal charts (only with dinamic flot charts engine)
(cherry picked from commit 3d014c6ab5
)
Conflicts:
pandora_console/include/graphs/flot/pandora.flot.js
pandora_console/include/graphs/functions_flot.php
This commit is contained in:
parent
4a30988146
commit
1577621b5b
|
@ -3223,6 +3223,8 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
|
|||
$series_type['unknown'.$series_suffix] = 'area';
|
||||
}
|
||||
|
||||
$series_type['sum' . $series_suffix] = 'boolean';
|
||||
|
||||
//Boolean graph doesn't have min!!!
|
||||
/*if (!$avg_only) {
|
||||
$chart[$timestamp]['min'.$series_suffix] = 0;
|
||||
|
@ -3380,6 +3382,7 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
|
||||
$unit_name, $show_alerts, $avg_only, $date, '', '', $show_unknown);
|
||||
|
||||
|
@ -3398,8 +3401,10 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
|
|||
$flash_chart = false;
|
||||
}
|
||||
|
||||
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
|
||||
'url' => ui_get_full_url("/images/logo_vertical_water.png", false, false, false));
|
||||
$water_mark = array(
|
||||
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
|
||||
'url' => ui_get_full_url("/images/logo_vertical_water.png",
|
||||
false, false, false));
|
||||
|
||||
if ($config['type_module_charts'] === 'area') {
|
||||
if ($compare === 'separated') {
|
||||
|
|
|
@ -611,16 +611,26 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
|
|||
line_show = true;
|
||||
points_show = false;
|
||||
filled = true;
|
||||
steps_chart = false;
|
||||
break;
|
||||
case 'line':
|
||||
default:
|
||||
line_show = true;
|
||||
points_show = false;
|
||||
filled = false;
|
||||
steps_chart = false;
|
||||
break;
|
||||
case 'points':
|
||||
line_show = false;
|
||||
points_show = true;
|
||||
filled = false;
|
||||
steps_chart = false
|
||||
break;
|
||||
case 'boolean':
|
||||
line_show = true;
|
||||
points_show = false;
|
||||
filled = false;
|
||||
steps_chart = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -667,13 +677,15 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
|
|||
label: legend[i],
|
||||
color: serie_color,
|
||||
//threshold: [{ below: 80, color: "rgb(200, 20, 30)" } , { below: 65, color: "rgb(30, 200, 30)" }, { below: 50, color: "rgb(30, 200, 30)" }],
|
||||
lines: { show: line_show,
|
||||
lines: {
|
||||
show: line_show,
|
||||
fill: filled,
|
||||
fillColor: {
|
||||
colors: [ { opacity: 0.9 }, { opacity: 0.9 } ]
|
||||
},
|
||||
lineWidth: WidhtLine,
|
||||
steps: false },
|
||||
steps: steps_chart
|
||||
},
|
||||
points: { show: points_show }
|
||||
});
|
||||
|
||||
|
@ -1023,183 +1035,6 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
|
|||
//return '<div style=color:#000;font-size:'+font_size+'pt><input type="checkbox" id="' + graph_id + '_' + item.id +'" checked="checked" class="check_serie_'+graph_id+'">'+v+'</div>';
|
||||
}
|
||||
|
||||
// Used to export the graph data to a file.
|
||||
// Uses plot, labels and labels_long as scope variables.
|
||||
function exportData (options) {
|
||||
options = options || {};
|
||||
|
||||
// Options
|
||||
var type = options.type || 'csv';
|
||||
type = type.toLowerCase().trim();
|
||||
|
||||
var graphData,
|
||||
dataObject,
|
||||
dataObjects = plot.getData(),
|
||||
result = [];
|
||||
|
||||
// Throw errors
|
||||
var retrieveDataOject = function (dataObjects) {
|
||||
var result;
|
||||
|
||||
if (typeof dataObjects === 'undefined')
|
||||
throw new Error('Empty parameter');
|
||||
|
||||
// Try to retrieve the avg set (not 100% reliable, I know)
|
||||
if (dataObjects.length == 1) {
|
||||
result = dataObjects.shift();
|
||||
}
|
||||
if (dataObjects.length > 1) {
|
||||
dataObjects.forEach(function (element) {
|
||||
if (/^Avg.:/i.test(element.label))
|
||||
result = element;
|
||||
});
|
||||
|
||||
// If the avg set is missing, retrieve the first set
|
||||
if (typeof result === 'undefined')
|
||||
result = dataObjects.shift();
|
||||
}
|
||||
|
||||
if (typeof result === 'undefined')
|
||||
throw new Error('Empty result');
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Throw errors
|
||||
var processDataObject = function (dataObject) {
|
||||
var result;
|
||||
|
||||
if (typeof dataObject === 'undefined')
|
||||
throw new Error('Empty parameter');
|
||||
|
||||
if (typeof dataObject.data === 'undefined'
|
||||
|| !(dataObject.data instanceof Array))
|
||||
throw new Error('Object malformed');
|
||||
|
||||
/* {
|
||||
* head: [<column>,<column>,...,<column>],
|
||||
* data: [
|
||||
* [<data>,<data>,...,<data>],
|
||||
* [<data>,<data>,...,<data>],
|
||||
* ...,
|
||||
* [<data>,<data>,...,<data>],
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
if (type === 'csv') {
|
||||
result = {
|
||||
head: ['date', 'value'],
|
||||
data: []
|
||||
};
|
||||
|
||||
dataObject.data.forEach(function (item, index) {
|
||||
var date = '', value = item[1];
|
||||
|
||||
// Long labels are preferred
|
||||
if (typeof labels_long[index] !== 'undefined')
|
||||
date = labels_long[index];
|
||||
else if (typeof labels[index] !== 'undefined')
|
||||
date = labels[index];
|
||||
|
||||
result.data.push([date, value]);
|
||||
});
|
||||
}
|
||||
/* [
|
||||
* {
|
||||
* 'date': <date>,
|
||||
* 'value': <value>
|
||||
* }
|
||||
* ],
|
||||
* [
|
||||
* {
|
||||
* 'date': <date>,
|
||||
* 'value': <value>
|
||||
* }
|
||||
* ],
|
||||
* ...,
|
||||
* [
|
||||
* {
|
||||
* 'date': <date>,
|
||||
* 'value': <value>
|
||||
* }
|
||||
* ]
|
||||
*/
|
||||
else if (type === 'json') {
|
||||
result = [];
|
||||
|
||||
dataObject.data.forEach(function (item, index) {
|
||||
var date = '', value = item[1];
|
||||
|
||||
// Long labels are preferred
|
||||
if (typeof labels_long[index] !== 'undefined')
|
||||
date = labels_long[index];
|
||||
else if (typeof labels[index] !== 'undefined')
|
||||
date = labels[index];
|
||||
|
||||
result.push({
|
||||
'date': date,
|
||||
'value': value
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof result === 'undefined')
|
||||
throw new Error('Empty result');
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
dataObject = retrieveDataOject(dataObjects);
|
||||
graphData = processDataObject(dataObject);
|
||||
|
||||
// Transform the object data into a string
|
||||
// cause PHP has limitations in the number
|
||||
// of POST params received.
|
||||
var graphDataStr = JSON.stringify(graphData);
|
||||
|
||||
// Build form
|
||||
var $form = $('<form></form>'),
|
||||
$dataInput = $('<input>'),
|
||||
$typeInput = $('<input>'),
|
||||
$separatorInput = $('<input>'),
|
||||
$excelInput = $('<input>');
|
||||
|
||||
$dataInput
|
||||
.prop('name', 'data')
|
||||
.prop('type', 'text')
|
||||
.prop('value', graphDataStr);
|
||||
|
||||
$typeInput
|
||||
.prop('name', 'type')
|
||||
.prop('type', 'text')
|
||||
.prop('value', type);
|
||||
|
||||
$separatorInput
|
||||
.prop('name', 'separator')
|
||||
.prop('type', 'text')
|
||||
.prop('value', ';');
|
||||
|
||||
$excelInput
|
||||
.prop('name', 'excel_encoding')
|
||||
.prop('type', 'text')
|
||||
.prop('value', false);
|
||||
|
||||
$form
|
||||
.prop('method', 'POST')
|
||||
.prop('action', homeurl + '/include/graphs/export_data.php')
|
||||
.append($dataInput, $typeInput, $separatorInput, $excelInput)
|
||||
.hide()
|
||||
// Firefox made me write into the DOM for this :(
|
||||
.appendTo('body')
|
||||
.submit();
|
||||
}
|
||||
catch (e) {
|
||||
alert('There was an error exporting the data');
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
// Prepared to turn series with a checkbox
|
||||
//~ $('.check_serie_'+graph_id).click(function() {
|
||||
//~ // Format of the id is graph_3905jf93f03_serie_id
|
||||
|
@ -1217,14 +1052,6 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
|
|||
$('#overview_' + graph_id).css('visibility','hidden');
|
||||
});
|
||||
|
||||
$('#menu_export_csv_' + graph_id).click(function() {
|
||||
exportData({ type: 'csv' });
|
||||
});
|
||||
|
||||
$('#menu_export_json_' + graph_id).click(function() {
|
||||
exportData({ type: 'json' });
|
||||
});
|
||||
|
||||
$('#menu_threshold_' + graph_id).click(function() {
|
||||
datas = new Array();
|
||||
|
||||
|
@ -1259,7 +1086,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
|
|||
}));
|
||||
|
||||
$('#menu_cancelzoom_' + graph_id)
|
||||
.attr('src', homeurl + '/images/zoom_cross_grey.disabled.png');
|
||||
.attr('src', homeurl + '/images/zoom_cross.disabled.png');
|
||||
overview.clearSelection();
|
||||
currentRanges = null;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue