2012-03-01 17:41:02 +01:00
|
|
|
<?PHP
|
|
|
|
|
|
|
|
// Copyright (c) 2007-2008 Sancho Lerena, slerena@gmail.com
|
|
|
|
// Copyright (c) 2008 Esteban Sanchez, estebans@artica.es
|
|
|
|
// Copyright (c) 2007-2011 Artica, info@artica.es
|
|
|
|
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public License
|
|
|
|
// (LGPL) as published by the Free Software Foundation; version 2
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
//JQuery 1.6.1 library addition
|
|
|
|
|
|
|
|
global $config;
|
|
|
|
|
2012-03-05 20:25:02 +01:00
|
|
|
|
|
|
|
function include_javascript_dependencies_flot_graph($return = false) {
|
|
|
|
global $config;
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2012-03-05 20:25:02 +01:00
|
|
|
static $is_include_javascript = false;
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2012-03-05 20:25:02 +01:00
|
|
|
if (!$is_include_javascript) {
|
|
|
|
$is_include_javascript = true;
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2012-09-28 16:06:20 +02:00
|
|
|
$metaconsole_hack = '';
|
|
|
|
if (defined('METACONSOLE')) {
|
|
|
|
$metaconsole_hack = '../../';
|
|
|
|
}
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2012-03-05 20:25:02 +01:00
|
|
|
// NOTE: jquery.flot.threshold is not te original file. Is patched to allow multiple thresholds and filled area
|
|
|
|
$output = '
|
2013-04-11 18:35:07 +02:00
|
|
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="' . ui_get_full_url($metaconsole_hack . '/include/graphs/flot/excanvas.js') . '"></script><![endif]-->
|
2018-02-16 13:41:31 +01:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.js') .'"></script>
|
2012-09-28 16:06:20 +02:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.min.js') .'"></script>
|
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
2018-01-25 13:14:21 +01:00
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.time.js') .'"></script>
|
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
2013-02-19 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_api.php, include/functions_agents.php,
include/functions_config.php, include/ajax/reporting.ajax.php,
include/functions_snmp_browser.php,
operation/agentes/status_monitor.php: improved code style.
* include/functions_graph.php, include/graphs/fgraph.php,
include/graphs/flot/jquery.flot.pie.js,
include/graphs/flot/jquery.flot.pie.min.js,
include/graphs/flot/pandora.flot.js,
include/graphs/functions_flot.php: fixed the pie graphs, added the
expanded version of flot pie js file with some changes for the
last version of jQuery.
Fixes: #3604555
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7675 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-02-19 11:35:04 +01:00
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.pie.js') .'"></script>
|
2012-09-28 16:06:20 +02:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.crosshair.min.js') .'"></script>
|
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.stack.min.js') .'"></script>
|
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.selection.min.js') .'"></script>
|
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.resize.min.js') .'"></script>
|
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.threshold.js') .'"></script>
|
2018-05-10 08:43:09 +02:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.threshold.multiple.js') .'"></script>
|
2012-09-28 16:06:20 +02:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.symbol.min.js') .'"></script>
|
2016-09-07 13:21:27 +02:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.exportdata.pandora.js') .'"></script>
|
2012-09-28 16:06:20 +02:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
2016-09-12 16:22:58 +02:00
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/jquery.flot.axislabels.js') .'"></script>
|
2018-04-27 13:51:13 +02:00
|
|
|
<script language="javascript" type="text/javascript" src="'.
|
2013-03-15 15:35:52 +01:00
|
|
|
ui_get_full_url($metaconsole_hack . '/include/graphs/flot/pandora.flot.js') .'"></script>';
|
2012-03-05 20:25:02 +01:00
|
|
|
$output .= "
|
2013-03-15 15:35:52 +01:00
|
|
|
<script type='text/javascript'>
|
2016-10-18 17:02:13 +02:00
|
|
|
var precision_graph = " . $config['graph_precision'] . ";
|
2018-04-27 13:51:13 +02:00
|
|
|
function pieHover(event, pos, obj)
|
2013-03-15 15:35:52 +01:00
|
|
|
{
|
|
|
|
if (!obj)
|
|
|
|
return;
|
|
|
|
percent = parseFloat(obj.series.percent).toFixed(2);
|
|
|
|
$('#hover').html('<span style=\'font-weight: bold; color: '+obj.series.color+'\'>'+obj.series.label+' ('+percent+'%)</span>');
|
|
|
|
$('.legendLabel').each(function() {
|
2013-07-17 13:12:37 +02:00
|
|
|
if ($(this).html() == obj.series.label) {
|
2013-03-15 15:35:52 +01:00
|
|
|
$(this).css('font-weight','bold');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$(this).css('font-weight','');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2018-04-27 13:51:13 +02:00
|
|
|
|
|
|
|
function pieClick(event, pos, obj)
|
2013-03-15 15:35:52 +01:00
|
|
|
{
|
|
|
|
if (!obj)
|
|
|
|
return;
|
|
|
|
percent = parseFloat(obj.series.percent).toFixed(2);
|
2013-04-10 09:57:54 +02:00
|
|
|
alert(''+obj.series.label+': '+obj.series.data[0][1]+' ('+percent+'%)');
|
2013-03-15 15:35:52 +01:00
|
|
|
}
|
|
|
|
</script>";
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2012-03-05 20:25:02 +01:00
|
|
|
if (!$return)
|
|
|
|
echo $output;
|
2018-04-27 13:51:13 +02:00
|
|
|
|
2012-03-05 20:25:02 +01:00
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
}
|
2012-03-01 17:41:02 +01:00
|
|
|
|
|
|
|
///////////////////////////////
|
|
|
|
////////// AREA GRAPHS ////////
|
|
|
|
///////////////////////////////
|
2018-02-27 16:28:00 +01:00
|
|
|
function flot_area_graph (
|
2018-05-21 17:25:09 +02:00
|
|
|
$agent_module_id, $array_data,
|
2018-02-16 13:41:31 +01:00
|
|
|
$legend, $series_type, $date_array,
|
|
|
|
$data_module_graph, $show_elements_graph,
|
2018-02-28 08:46:51 +01:00
|
|
|
$format_graph, $water_mark, $series_suffix_str,
|
|
|
|
$array_events_alerts ) {
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
global $config;
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-04-18 10:30:24 +02:00
|
|
|
// include_javascript_dependencies_flot_graph();
|
2018-02-16 13:41:31 +01:00
|
|
|
|
|
|
|
// Get a unique identifier to graph
|
|
|
|
$graph_id = uniqid('graph_');
|
|
|
|
|
|
|
|
$background_style = '';
|
|
|
|
switch ($format_graph['background']) {
|
|
|
|
default:
|
|
|
|
case 'white':
|
|
|
|
$background_style = ' background: #fff; ';
|
|
|
|
break;
|
|
|
|
case 'black':
|
|
|
|
$background_style = ' background: #000; ';
|
|
|
|
break;
|
|
|
|
case 'transparent':
|
|
|
|
$background_style = '';
|
|
|
|
break;
|
|
|
|
}
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-04-27 10:03:05 +02:00
|
|
|
///XXXXXXX los px caca
|
2018-02-16 13:41:31 +01:00
|
|
|
// Parent layer
|
2018-05-10 08:43:09 +02:00
|
|
|
$return = "<div class='parent_graph' style='width: " . ($format_graph['width']) . "; " . $background_style . "'>";
|
2018-02-16 13:41:31 +01:00
|
|
|
// Set some containers to legend, graph, timestamp tooltip, etc.
|
|
|
|
$return .= "<p id='legend_$graph_id' class='legend_graph' style='font-size:" . $format_graph['font_size'] ."pt !important;'></p>";
|
2018-05-21 17:25:09 +02:00
|
|
|
if(!isset($show_elements_graph['combined']) || !$show_elements_graph['combined']){
|
|
|
|
$yellow_threshold = $data_module_graph['w_min'];
|
|
|
|
$red_threshold = $data_module_graph['c_min'];
|
|
|
|
// Get other required module datas to draw warning and critical
|
|
|
|
if ($agent_module_id == 0) {
|
|
|
|
$yellow_up = 0;
|
|
|
|
$red_up = 0;
|
|
|
|
$yellow_inverse = false;
|
|
|
|
$red_inverse = false;
|
|
|
|
} else {
|
|
|
|
$yellow_up = $data_module_graph['w_max'];
|
|
|
|
$red_up = $data_module_graph['c_max'];
|
|
|
|
$yellow_inverse = !($data_module_graph['w_inv'] == 0);
|
|
|
|
$red_inverse = !($data_module_graph['c_inv'] == 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif(isset($show_elements_graph['from_interface']) && $show_elements_graph['from_interface']){
|
|
|
|
if( isset($show_elements_graph['threshold_data']) && is_array($show_elements_graph['threshold_data'])){
|
|
|
|
$yellow_up = $show_elements_graph['threshold_data']['yellow_up'];
|
|
|
|
$red_up = $show_elements_graph['threshold_data']['red_up'];
|
|
|
|
$yellow_inverse = $show_elements_graph['threshold_data']['yellow_inverse'];
|
|
|
|
$red_inverse = $show_elements_graph['threshold_data']['red_inverse'];
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$yellow_up = 0;
|
|
|
|
$red_up = 0;
|
|
|
|
$yellow_inverse = false;
|
|
|
|
$red_inverse = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$yellow_up = 0;
|
|
|
|
$red_up = 0;
|
2018-02-27 16:28:00 +01:00
|
|
|
$yellow_inverse = false;
|
2018-05-21 17:25:09 +02:00
|
|
|
$red_inverse = false;
|
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 ($show_elements_graph['menu']) {
|
|
|
|
$return .= menu_graph(
|
2018-02-27 16:28:00 +01:00
|
|
|
$yellow_threshold, $red_threshold,
|
|
|
|
$yellow_up, $red_up, $yellow_inverse,
|
|
|
|
$red_inverse, $show_elements_graph['dashboard'],
|
|
|
|
$show_elements_graph['vconsole'],
|
|
|
|
$graph_id, $format_graph['width'],
|
2018-02-16 13:41:31 +01:00
|
|
|
$format_graph['homeurl']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$return .= html_print_input_hidden('line_width_graph', $config['custom_graph_width'], true);
|
2018-02-27 16:28:00 +01:00
|
|
|
$return .= "<div id='timestamp_$graph_id'
|
|
|
|
class='timestamp_graph'
|
2018-02-16 13:41:31 +01:00
|
|
|
style=' font-size:".$format_graph['font_size']."pt;
|
2018-02-27 16:28:00 +01:00
|
|
|
display:none; position:absolute;
|
|
|
|
background:#fff; border: solid 1px #aaa;
|
2018-02-16 13:41:31 +01:00
|
|
|
padding: 2px; z-index:1000;'></div>";
|
|
|
|
$return .= "<div id='$graph_id' class='";
|
|
|
|
|
|
|
|
if($format_graph['type'] == 'area_simple'){
|
|
|
|
$return .= "noresizevc ";
|
|
|
|
}
|
2018-04-26 10:24:37 +02:00
|
|
|
//XXXXXX height: ".$format_graph['height']."px;'
|
2018-02-27 16:28:00 +01:00
|
|
|
$return .= "graph" .$format_graph['adapt_key'] ."'
|
|
|
|
style=' width: ".$format_graph['width']."px;
|
2018-04-27 10:03:05 +02:00
|
|
|
height: ".$format_graph['height']."px;'></div>";
|
2018-02-16 13:41:31 +01:00
|
|
|
|
|
|
|
if ($show_elements_graph['menu']) {
|
|
|
|
$format_graph['height'] = 100;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$format_graph['height'] = 1;
|
|
|
|
}
|
2018-02-23 14:31:00 +01:00
|
|
|
|
|
|
|
if (!$vconsole){
|
2018-04-27 10:03:05 +02:00
|
|
|
$return .= "<div id='overview_$graph_id' class='overview_graph'
|
2018-04-26 10:24:37 +02:00
|
|
|
style='margin:0px; margin-top:30px; margin-bottom:50px; display:none; width: ".$format_graph['width']."; height: 200px;'></div>";
|
2018-02-23 14:31:00 +01:00
|
|
|
}
|
2018-04-24 13:19:24 +02:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
//XXXXTODO
|
|
|
|
$water_mark = '';
|
|
|
|
if ($water_mark != '') {
|
|
|
|
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='$water_mark'></div>";
|
|
|
|
$watermark = 'true';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$watermark = 'false';
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach($series_type as $k => $v){
|
2018-02-27 16:28:00 +01:00
|
|
|
$series_type_unique["data_" . $graph_id . "_" . $k] = $v;
|
|
|
|
}
|
2018-02-16 13:41:31 +01:00
|
|
|
|
|
|
|
// Store data series in javascript format
|
|
|
|
$extra_width = (int)($format_graph['width'] / 3);
|
2018-02-27 16:28:00 +01:00
|
|
|
$return .= "<div id='extra_$graph_id'
|
|
|
|
style='font-size: " . $format_graph['font_size'] . "pt;
|
|
|
|
display:none; position:absolute; overflow: auto;
|
|
|
|
max-height: ".($format_graph['height']+50)."px;
|
|
|
|
width: ".$extra_width."px;
|
|
|
|
background:#fff; padding: 2px 2px 2px 2px;
|
2018-02-16 13:41:31 +01:00
|
|
|
border: solid #000 1px;'></div>";
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
if(substr($background_style, -6, 4) == '#fff'){
|
|
|
|
$background_color = "#eee";
|
|
|
|
$legend_color = "#151515";
|
|
|
|
}
|
|
|
|
else if(substr($background_style, -6, 4) == '#000'){
|
|
|
|
$background_color = "#151515";
|
|
|
|
$legend_color = "#BDBDBD";
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$background_color = "#A4A4A4";
|
|
|
|
$legend_color = "#A4A4A4";
|
|
|
|
}
|
|
|
|
|
|
|
|
//XXXX force_integer TODO
|
|
|
|
$force_integer = 0;
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
// Trick to get translated string from javascript
|
|
|
|
$return .= html_print_input_hidden('unknown_text', __('Unknown'), true);
|
|
|
|
|
2018-03-01 10:13:55 +01:00
|
|
|
if (!isset($config["short_module_graph_data"])){
|
2018-02-28 14:33:22 +01:00
|
|
|
$config["short_module_graph_data"] = '';
|
2018-02-16 13:41:31 +01:00
|
|
|
}
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-28 14:33:22 +01:00
|
|
|
$short_data = $config["short_module_graph_data"];
|
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
$values = json_encode($array_data);
|
|
|
|
$legend = json_encode($legend);
|
|
|
|
$series_type = json_encode($series_type);
|
|
|
|
$date_array = json_encode($date_array);
|
2018-02-27 16:28:00 +01:00
|
|
|
$data_module_graph = json_encode($data_module_graph);
|
2018-02-16 13:41:31 +01:00
|
|
|
$show_elements_graph = json_encode($show_elements_graph);
|
|
|
|
$format_graph = json_encode($format_graph);
|
2018-02-28 08:46:51 +01:00
|
|
|
$array_events_alerts = json_encode($array_events_alerts);
|
2018-02-16 13:41:31 +01:00
|
|
|
|
|
|
|
// Javascript code
|
2018-05-03 13:02:17 +02:00
|
|
|
if ($font_size == '') $font_size = '\'\'';
|
2018-02-16 13:41:31 +01:00
|
|
|
$return .= "<script type='text/javascript'>";
|
|
|
|
$return .= "$(document).ready( function () {";
|
2018-02-27 16:28:00 +01:00
|
|
|
$return .= "pandoraFlotArea(" .
|
2018-02-16 13:41:31 +01:00
|
|
|
"'$graph_id', \n" .
|
|
|
|
"JSON.parse('$values'), \n" .
|
|
|
|
"JSON.parse('$legend'), \n" .
|
|
|
|
"'$agent_module_id', \n" .
|
|
|
|
"JSON.parse('$series_type'), \n" .
|
|
|
|
"'$watermark', \n" .
|
|
|
|
"JSON.parse('$date_array'), \n" .
|
|
|
|
"JSON.parse('$data_module_graph'), \n" .
|
|
|
|
"JSON.parse('$show_elements_graph'), \n" .
|
|
|
|
"JSON.parse('$format_graph'), \n" .
|
|
|
|
"$force_integer, \n" .
|
|
|
|
"'$series_suffix_str', \n" .
|
|
|
|
"'$background_color', \n" .
|
|
|
|
"'$legend_color', \n" .
|
2018-02-28 08:46:51 +01:00
|
|
|
"'$short_data', \n" .
|
|
|
|
"JSON.parse('$array_events_alerts')".
|
|
|
|
");";
|
2018-02-16 13:41:31 +01:00
|
|
|
$return .= "});";
|
|
|
|
$return .= "</script>";
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
// Parent layer
|
|
|
|
$return .= "</div>";
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
|
|
|
function menu_graph(
|
2018-02-27 16:28:00 +01:00
|
|
|
$yellow_threshold, $red_threshold,
|
|
|
|
$yellow_up, $red_up, $yellow_inverse,
|
|
|
|
$red_inverse, $dashboard, $vconsole,
|
2018-02-16 13:41:31 +01:00
|
|
|
$graph_id, $width, $homeurl
|
|
|
|
){
|
|
|
|
$return = '';
|
|
|
|
$threshold = false;
|
|
|
|
if ($yellow_threshold != $yellow_up || $red_threshold != $red_up) {
|
|
|
|
$threshold = true;
|
|
|
|
}
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
$nbuttons = 3;
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
if ($threshold) {
|
|
|
|
$nbuttons++;
|
|
|
|
}
|
|
|
|
$menu_width = 25 * $nbuttons + 15;
|
|
|
|
if ( $dashboard == false AND $vconsole == false) {
|
|
|
|
$return .= "<div id='geneal_menu_$graph_id' class='menu_graph' style='
|
|
|
|
width: 30px;
|
|
|
|
height: 250px;
|
2018-05-10 08:43:09 +02:00
|
|
|
left:100%;
|
2018-02-16 13:41:31 +01:00
|
|
|
position: absolute;
|
|
|
|
top: 0px;
|
|
|
|
background-color: white;'>";
|
|
|
|
$return .= "<div id='menu_$graph_id' " .
|
|
|
|
"style='display: none; " .
|
|
|
|
"text-align: center;" .
|
|
|
|
"position: relative;".
|
|
|
|
"border-bottom: 0px;'>
|
|
|
|
<a href='javascript:'><img id='menu_cancelzoom_$graph_id' src='".$homeurl."images/zoom_cross_grey.disabled.png' alt='".__('Cancel zoom')."' title='".__('Cancel zoom')."'></a>";
|
|
|
|
if ($threshold) {
|
|
|
|
$return .= " <a href='javascript:'><img id='menu_threshold_$graph_id' src='".$homeurl."images/chart_curve_threshold.png' alt='".__('Warning and Critical thresholds')."' title='".__('Warning and Critical thresholds')."'></a>";
|
|
|
|
}
|
|
|
|
$return .= " <a href='javascript:'>
|
|
|
|
<img id='menu_overview_$graph_id' class='menu_overview' src='" . $homeurl . "images/chart_curve_overview.png' alt='" . __('Overview graph') . "' title='".__('Overview graph')."'></a>";
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
// Export buttons
|
|
|
|
$return .= " <a href='javascript:'><img id='menu_export_csv_$graph_id' src='".$homeurl."images/csv_grey.png' alt='".__('Export to CSV')."' title='".__('Export to CSV')."'></a>";
|
|
|
|
// Button disabled. This feature works, but seems that is not useful enough to the final users.
|
|
|
|
//$return .= " <a href='javascript:'><img id='menu_export_json_$graph_id' src='".$homeurl."images/json.png' alt='".__('Export to JSON')."' title='".__('Export to JSON')."'></a>";
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
$return .= "</div>";
|
|
|
|
$return .= "</div>";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($dashboard) {
|
|
|
|
$return .= "<div id='geneal_menu_$graph_id' class='menu_graph' style='
|
|
|
|
width: 30px;
|
|
|
|
height: 250px;
|
|
|
|
left: " . $width . "px;
|
|
|
|
position: absolute;
|
|
|
|
top: 0px;
|
|
|
|
background-color: white;'>";
|
|
|
|
|
|
|
|
$return .= "<div id='menu_$graph_id' " .
|
|
|
|
"style='display: none; " .
|
|
|
|
"text-align: center;" .
|
|
|
|
"position: relative;".
|
|
|
|
"border-bottom: 0px;'>
|
|
|
|
<a href='javascript:'><img id='menu_cancelzoom_$graph_id' src='".$homeurl."images/zoom_cross_grey.disabled.png' alt='".__('Cancel zoom')."' title='".__('Cancel zoom')."'></a>";
|
2018-02-27 16:28:00 +01:00
|
|
|
|
2018-02-16 13:41:31 +01:00
|
|
|
$return .= "</div>";
|
|
|
|
$return .= "</div>";
|
|
|
|
}
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
///////////////////////////////
|
|
|
|
///////////////////////////////
|
|
|
|
///////////////////////////////
|
|
|
|
|
|
|
|
// Prints a FLOT pie chart
|
2013-01-30 17:29:49 +01:00
|
|
|
function flot_pie_chart ($values, $labels, $width, $height, $water_mark,
|
2016-05-26 13:47:45 +02:00
|
|
|
$font = '', $font_size = 8, $legend_position = '', $colors = '',
|
|
|
|
$hide_labels = false) {
|
2013-01-30 17:29:49 +01:00
|
|
|
|
2018-04-18 10:30:24 +02:00
|
|
|
// include_javascript_dependencies_flot_graph();
|
2012-03-05 20:25:02 +01:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$series = sizeof($values);
|
2012-03-05 20:25:02 +01:00
|
|
|
if (($series != sizeof ($labels)) || ($series == 0) ) {
|
2012-03-01 17:41:02 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$graph_id = uniqid('graph_');
|
|
|
|
|
2013-01-30 17:29:49 +01:00
|
|
|
switch ($legend_position) {
|
|
|
|
case 'bottom':
|
|
|
|
$height = $height + (count($values) * 24);
|
|
|
|
break;
|
|
|
|
case 'right':
|
|
|
|
default:
|
|
|
|
//TODO FOR TOP OR LEFT OR RIGHT
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-03-07 12:03:22 +01:00
|
|
|
$return = "<div id='$graph_id' class='graph' style='width: ".$width."px; height: ".$height."px;'></div>";
|
2012-03-01 17:41:02 +01:00
|
|
|
|
2013-07-17 13:12:37 +02:00
|
|
|
if ($water_mark != '') {
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='$water_mark'></div>";
|
|
|
|
$water_mark = 'true';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$water_mark = 'false';
|
|
|
|
}
|
|
|
|
|
|
|
|
$separator = ';;::;;';
|
|
|
|
|
2013-02-19 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_api.php, include/functions_agents.php,
include/functions_config.php, include/ajax/reporting.ajax.php,
include/functions_snmp_browser.php,
operation/agentes/status_monitor.php: improved code style.
* include/functions_graph.php, include/graphs/fgraph.php,
include/graphs/flot/jquery.flot.pie.js,
include/graphs/flot/jquery.flot.pie.min.js,
include/graphs/flot/pandora.flot.js,
include/graphs/functions_flot.php: fixed the pie graphs, added the
expanded version of flot pie js file with some changes for the
last version of jQuery.
Fixes: #3604555
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7675 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-02-19 11:35:04 +01:00
|
|
|
$labels = implode($separator, $labels);
|
|
|
|
$values = implode($separator, $values);
|
2013-07-17 13:12:37 +02:00
|
|
|
if (!empty($colors)) {
|
2013-02-20 18:15:38 +01:00
|
|
|
$colors = implode($separator, $colors);
|
|
|
|
}
|
2012-03-01 17:41:02 +01:00
|
|
|
|
|
|
|
$return .= "<script type='text/javascript'>";
|
2014-06-09 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_config.php, general/login_page.php: improved
the source code style.
* godmode/setup/os.builder.php: fixed the form.
* godmode/update_manager_xxx/*, godmode/menu.php,
include/functions_update_manager.php,
include/ajax/update_manager.ajax.php,
include/graphs/functions_gd.php, include/graphs/functions_flot.php,
include/config_process.php, include/javascript/update_manager.js,
include/javascript/jquery.knob.js,
include/javascript/jquery.iframe-transport.js,
include/javascript/jquery.fileupload.js, images/check-cross.png:
first version of new update manager.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10144 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2014-06-09 15:33:55 +02:00
|
|
|
|
2013-01-30 17:29:49 +01:00
|
|
|
$return .= "pandoraFlotPie('$graph_id', '$values', '$labels',
|
2016-05-26 13:47:45 +02:00
|
|
|
'$series', '$width', $font_size, $water_mark, '$separator',
|
|
|
|
'$legend_position', '$height', '$colors', " . json_encode($hide_labels) . ")";
|
2012-03-01 17:41:02 +01:00
|
|
|
|
|
|
|
$return .= "</script>";
|
2012-03-07 12:03:22 +01:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
2015-11-04 17:42:45 +01:00
|
|
|
// Prints a FLOT pie chart
|
|
|
|
function flot_custom_pie_chart ($flash_charts, $graph_values,
|
|
|
|
$width, $height, $colors, $module_name_list, $long_index,
|
|
|
|
$no_data,$xaxisname, $yaxisname, $water_mark, $fontpath, $font_size,
|
|
|
|
$unit, $ttl, $homeurl, $background_color, $legend_position) {
|
|
|
|
|
2016-10-18 10:32:10 +02:00
|
|
|
global $config;
|
2015-11-04 17:42:45 +01:00
|
|
|
///TODO
|
2018-04-18 10:30:24 +02:00
|
|
|
// include_javascript_dependencies_flot_graph();
|
2015-11-04 17:42:45 +01:00
|
|
|
|
|
|
|
$total_modules = $graph_values['total_modules'];
|
|
|
|
unset($graph_values['total_modules']);
|
|
|
|
|
|
|
|
foreach ($graph_values as $label => $value) {
|
2015-11-27 11:50:53 +01:00
|
|
|
if ($value['value']) {
|
|
|
|
if ($value['value'] > 1000000)
|
2016-10-20 10:47:12 +02:00
|
|
|
$legendvalue = sprintf("%sM", remove_right_zeros(number_format($value['value'] / 1000000, $config['graph_precision'])));
|
2015-11-27 11:50:53 +01:00
|
|
|
else if ($value['value'] > 1000)
|
2016-10-20 10:47:12 +02:00
|
|
|
$legendvalue = sprintf("%sK", remove_right_zeros(number_format($value['value'] / 1000, $config['graph_precision'])));
|
2015-11-27 11:50:53 +01:00
|
|
|
else
|
2016-10-20 10:47:12 +02:00
|
|
|
$legendvalue = remove_right_zeros(number_format($value['value'], $config['graph_precision']));
|
2015-11-27 11:50:53 +01:00
|
|
|
}
|
2015-11-25 14:25:19 +01:00
|
|
|
else
|
2015-11-27 11:50:53 +01:00
|
|
|
$legendvalue = __('No data');
|
2015-11-04 17:42:45 +01:00
|
|
|
$values[] = $value['value'];
|
|
|
|
$legend[] = $label .": " . $legendvalue . " " .$value['unit'];
|
|
|
|
$labels[] = $label;
|
|
|
|
}
|
|
|
|
|
|
|
|
$graph_id = uniqid('graph_');
|
|
|
|
|
2017-03-22 10:10:56 +01:00
|
|
|
$return = "<div id='$graph_id' class='graph noresizevc' style='width: ".$width."px; height: ".$height."px;'></div>";
|
2015-11-04 17:42:45 +01:00
|
|
|
|
|
|
|
if ($water_mark != '') {
|
|
|
|
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='".$water_mark["url"]."'></div>";
|
|
|
|
$water_mark = 'true';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$water_mark = 'false';
|
|
|
|
}
|
|
|
|
|
|
|
|
$separator = ';;::;;';
|
|
|
|
|
|
|
|
$labels = implode($separator, $labels);
|
|
|
|
$legend = implode($separator, $legend);
|
|
|
|
$values = implode($separator, $values);
|
|
|
|
if (!empty($colors)) {
|
|
|
|
foreach ($colors as $color) {
|
|
|
|
$temp_colors[] = $color['color'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$colors = implode($separator, $temp_colors);
|
|
|
|
|
|
|
|
$return .= "<script type='text/javascript'>";
|
|
|
|
|
|
|
|
$return .= "pandoraFlotPieCustom('$graph_id', '$values', '$labels',
|
2016-09-08 15:44:36 +02:00
|
|
|
'$width', $font_size, '$fontpath', $water_mark,
|
2017-10-09 12:03:19 +02:00
|
|
|
'$separator', '$legend_position', '$height', '$colors','$legend','$background_color')";
|
2015-11-04 17:42:45 +01:00
|
|
|
|
|
|
|
$return .= "</script>";
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Returns a 3D column chart
|
2017-11-14 10:49:15 +01:00
|
|
|
function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark, $font = '', $font_size = 7, $background_color = "white", $tick_color = "white", $val_min=null, $val_max=null) {
|
2012-03-01 17:41:02 +01:00
|
|
|
global $config;
|
|
|
|
|
2018-04-18 10:30:24 +02:00
|
|
|
// include_javascript_dependencies_flot_graph();
|
2012-03-05 20:25:02 +01:00
|
|
|
|
|
|
|
$return = '';
|
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$stacked_str = '';
|
|
|
|
$multicolor = true;
|
|
|
|
|
|
|
|
// Get a unique identifier to graph
|
|
|
|
$graph_id = uniqid('graph_');
|
|
|
|
$graph_id2 = uniqid('graph_');
|
|
|
|
|
|
|
|
// Set some containers to legend, graph, timestamp tooltip, etc.
|
2015-11-04 17:42:45 +01:00
|
|
|
$return .= "<div id='$graph_id' class='graph' style='width: ".$width."px; height: ".$height."px; padding-left: 20px;'></div>";
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "<div id='value_$graph_id' style='display:none; position:absolute; background:#fff; border: solid 1px #aaa; padding: 2px'></div>";
|
|
|
|
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
if ($water_mark != '') {
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='$water_mark'></div>";
|
|
|
|
$watermark = 'true';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$watermark = 'false';
|
|
|
|
}
|
|
|
|
|
2014-12-11 13:48:25 +01:00
|
|
|
// Set a weird separator to serialize and unserialize passing data
|
|
|
|
// from php to javascript
|
2012-03-01 17:41:02 +01:00
|
|
|
$separator = ';;::;;';
|
|
|
|
$separator2 = ':,:,,,:,:';
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Transform data from our format to library format
|
|
|
|
$labels = array();
|
|
|
|
$a = array();
|
|
|
|
$vars = array();
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2017-11-08 16:41:23 +01:00
|
|
|
$max = PHP_INT_MIN+1;
|
|
|
|
$min = PHP_INT_MAX-1;
|
2012-03-01 17:41:02 +01:00
|
|
|
$i = count($graph_data);
|
2014-07-24 Miguel de Dios <miguel.dedios@artica.es>
* operation/snmpconsole/snmp_view.php,
operation/events/events_list.php, operation/incidents/incident.php,
extensions/files_repo.php,
extensions/files_repo/sql/files_repo.postgreSQL.sql,
extensions/files_repo/functions_files_repo.php,
extensions/files_repo/files_repo_list.php,
godmode/agentes/modificar_agente.php,
godmode/snmpconsole/snmp_alert.php, godmode/db/db_info.php,
include/functions_graph.php, include/functions_db.php,
include/db/postgresql.php, include/db/oracle.php,
include/db/mysql.php, include/functions_update_manager.php,
include/functions_events.php, include/graphs/functions_flot.php,
include/graphs/fgraph.php: tiny fixes for the improve the support of
postgreSQL databases.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10354 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2014-07-24 18:02:06 +02:00
|
|
|
$data = array();
|
2015-10-08 16:26:27 +02:00
|
|
|
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
foreach ($graph_data as $label => $values) {
|
2018-03-21 13:40:15 +01:00
|
|
|
$labels[] = io_safe_output($label);
|
2012-03-01 17:41:02 +01:00
|
|
|
$i--;
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
|
|
|
foreach ($values as $key => $value) {
|
2014-12-11 13:48:25 +01:00
|
|
|
$jsvar = "data_" . $graph_id . "_" . $key;
|
2012-03-01 17:41:02 +01:00
|
|
|
|
2015-10-08 16:26:27 +02:00
|
|
|
$data[$jsvar][] = $value;
|
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
|
2013-07-17 13:12:37 +02:00
|
|
|
if ($value > $max) {
|
2012-03-01 17:41:02 +01:00
|
|
|
$max = $value;
|
|
|
|
}
|
2017-11-08 16:41:23 +01:00
|
|
|
|
|
|
|
if ($value < $min) {
|
|
|
|
$min = $value;
|
|
|
|
}
|
2012-03-01 17:41:02 +01:00
|
|
|
}
|
|
|
|
}
|
2015-10-08 16:26:27 +02:00
|
|
|
|
2017-11-08 16:41:23 +01:00
|
|
|
if (!is_numeric($val_min)) {
|
|
|
|
$val_min = $min;
|
|
|
|
}
|
|
|
|
if (!is_numeric($val_max)) {
|
|
|
|
$val_max = $max;
|
|
|
|
}
|
2012-03-01 17:41:02 +01:00
|
|
|
|
|
|
|
// Store serialized data to use it from javascript
|
|
|
|
$labels = implode($separator,$labels);
|
|
|
|
|
|
|
|
// Store data series in javascript format
|
|
|
|
$jsvars = '';
|
|
|
|
$jsseries = array();
|
|
|
|
|
|
|
|
$i = 0;
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$values2 = array();
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
|
|
|
foreach ($data as $jsvar => $values) {
|
2012-03-01 17:41:02 +01:00
|
|
|
$values2[] = implode($separator,$values);
|
|
|
|
}
|
|
|
|
|
|
|
|
$values = implode($separator2, $values2);
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$jsseries = implode(',', $jsseries);
|
|
|
|
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Javascript code
|
|
|
|
$return .= "<script type='text/javascript'>";
|
|
|
|
|
2014-12-11 13:48:25 +01:00
|
|
|
$return .= "pandoraFlotHBars('$graph_id', '$values', '$labels',
|
2017-11-14 10:49:15 +01:00
|
|
|
false, $max, '$water_mark', '$separator', '$separator2', '$font', $font_size, '$background_color', '$tick_color', $val_min, $val_max)";
|
2016-09-08 15:44:36 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "</script>";
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2013-03-12 17:20:53 +01:00
|
|
|
return $return;
|
2012-03-01 17:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns a 3D column chart
|
2017-11-08 09:55:36 +01:00
|
|
|
function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark, $homedir, $font, $font_size, $from_ux, $from_wux, $background_color = 'white', $tick_color = 'white') {
|
2012-03-01 17:41:02 +01:00
|
|
|
global $config;
|
2012-03-05 20:25:02 +01:00
|
|
|
|
2018-04-18 10:30:24 +02:00
|
|
|
// include_javascript_dependencies_flot_graph();
|
2012-03-05 20:25:02 +01:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$stacked_str = '';
|
|
|
|
$multicolor = false;
|
|
|
|
|
|
|
|
// Get a unique identifier to graph
|
|
|
|
$graph_id = uniqid('graph_');
|
|
|
|
$graph_id2 = uniqid('graph_');
|
2014-06-11 13:34:27 +02:00
|
|
|
|
|
|
|
if ($width != 'auto') {
|
|
|
|
$width = $width . "px";
|
|
|
|
}
|
2012-03-01 17:41:02 +01:00
|
|
|
|
|
|
|
// Set some containers to legend, graph, timestamp tooltip, etc.
|
2015-11-04 17:42:45 +01:00
|
|
|
$return .= "<div id='$graph_id' class='graph $adapt_key' style='width: ".$width."; height: ".$height."px; padding-left: 20px;'></div>";
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "<div id='value_$graph_id' style='display:none; position:absolute; background:#fff; border: solid 1px #aaa; padding: 2px'></div>";
|
|
|
|
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
if ($water_mark != '') {
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='$water_mark'></div>";
|
|
|
|
$watermark = 'true';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$watermark = 'false';
|
|
|
|
}
|
|
|
|
|
2016-06-08 15:48:47 +02:00
|
|
|
$colors = array_map(function ($elem) {
|
|
|
|
return $elem['color'] ? $elem['color'] : null;
|
|
|
|
}, $color);
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Set a weird separator to serialize and unserialize passing data from php to javascript
|
|
|
|
$separator = ';;::;;';
|
|
|
|
$separator2 = ':,:,,,:,:';
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Transform data from our format to library format
|
|
|
|
$labels = array();
|
|
|
|
$a = array();
|
|
|
|
$vars = array();
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$max = 0;
|
|
|
|
$i = count($graph_data);
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
foreach ($graph_data as $label => $values) {
|
2017-12-13 17:17:45 +01:00
|
|
|
$labels[] = $label;
|
2012-03-01 17:41:02 +01:00
|
|
|
$i--;
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
|
|
|
foreach ($values as $key => $value) {
|
2015-11-04 17:42:45 +01:00
|
|
|
$jsvar = "data_" . $graph_id . "_" . $key;
|
|
|
|
|
|
|
|
$data[$jsvar][] = $value;
|
2012-03-01 17:41:02 +01:00
|
|
|
|
|
|
|
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
if ($value > $max) {
|
2012-03-01 17:41:02 +01:00
|
|
|
$max = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store serialized data to use it from javascript
|
|
|
|
$labels = implode($separator,$labels);
|
2012-03-06 18:23:46 +01:00
|
|
|
$colors = implode($separator, $colors);
|
2017-01-23 17:55:27 +01:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Store data series in javascript format
|
|
|
|
$jsvars = '';
|
|
|
|
$jsseries = array();
|
|
|
|
|
|
|
|
$i = 0;
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$values2 = array();
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2013-03-12 17:20:53 +01:00
|
|
|
foreach ($data as $jsvar => $values) {
|
2012-03-01 17:41:02 +01:00
|
|
|
$values2[] = implode($separator,$values);
|
|
|
|
}
|
|
|
|
|
|
|
|
$values = implode($separator2, $values2);
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$jsseries = implode(',', $jsseries);
|
2012-03-07 12:03:22 +01:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Javascript code
|
|
|
|
$return .= "<script type='text/javascript'>";
|
2016-09-08 16:24:55 +02:00
|
|
|
|
2017-01-23 17:55:27 +01:00
|
|
|
if ($from_ux) {
|
2017-08-17 18:38:12 +02:00
|
|
|
if($from_wux){
|
2017-11-08 09:55:36 +01:00
|
|
|
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, true, '$background_color', '$tick_color')";
|
2017-08-17 18:38:12 +02:00
|
|
|
}
|
|
|
|
else{
|
2017-11-08 09:55:36 +01:00
|
|
|
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, false, '$background_color', '$tick_color')";
|
2017-08-17 18:38:12 +02:00
|
|
|
}
|
2017-01-23 17:55:27 +01:00
|
|
|
}
|
|
|
|
else {
|
2017-11-08 09:55:36 +01:00
|
|
|
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, false, false, '$background_color', '$tick_color')";
|
2017-01-23 17:55:27 +01:00
|
|
|
}
|
2016-09-08 16:24:55 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "</script>";
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
|
2013-03-12 17:20:53 +01:00
|
|
|
return $return;
|
2012-03-01 17:41:02 +01:00
|
|
|
}
|
|
|
|
|
2017-07-10 16:22:41 +02:00
|
|
|
function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $colors, $fontpath, $round_corner, $homeurl, $watermark = '', $adapt_key = '', $stat_win = false, $id_agent = 0, $full_legend_date = array()) {
|
2012-03-01 17:41:02 +01:00
|
|
|
global $config;
|
2014-09-23 13:02:49 +02:00
|
|
|
|
2018-04-18 10:30:24 +02:00
|
|
|
// include_javascript_dependencies_flot_graph();
|
2017-10-10 18:48:58 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$stacked_str = 'stack: stack,';
|
2012-03-05 20:25:02 +01:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Get a unique identifier to graph
|
|
|
|
$graph_id = uniqid('graph_');
|
|
|
|
|
|
|
|
// Set some containers to legend, graph, timestamp tooltip, etc.
|
2015-12-31 12:04:23 +01:00
|
|
|
if ($stat_win) {
|
2018-05-10 08:43:09 +02:00
|
|
|
$return = "<div id='$graph_id' class='noresizevc graph $adapt_key' style='width: ".$width."%; height: ".$height."px; display: inline-block;'></div>";
|
2015-12-31 12:04:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2018-05-10 08:43:09 +02:00
|
|
|
$return = "<div id='$graph_id' class='noresizevc graph $adapt_key' style='width: ".$width."%; height: ".$height."px;'></div>";
|
2015-12-31 12:04:23 +01:00
|
|
|
}
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "<div id='value_$graph_id' style='display:none; position:absolute; background:#fff; border: solid 1px #aaa; padding: 2px'></div>";
|
|
|
|
|
|
|
|
// Set a weird separator to serialize and unserialize passing data from php to javascript
|
|
|
|
$separator = ';;::;;';
|
|
|
|
$separator2 = ':,:,,,:,:';
|
2012-09-28 16:06:20 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Transform data from our format to library format
|
|
|
|
$labels = array();
|
|
|
|
$a = array();
|
|
|
|
$vars = array();
|
2012-09-28 16:06:20 +02:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$datacolor = array();
|
|
|
|
|
|
|
|
$max = 0;
|
|
|
|
|
|
|
|
$i = count($graph_data);
|
|
|
|
|
|
|
|
$intervaltick = $period / $i;
|
|
|
|
|
|
|
|
$leg_max_length = 0;
|
2013-03-12 17:20:53 +01:00
|
|
|
foreach ($legend as $l) {
|
|
|
|
if (strlen($l) > $leg_max_length) {
|
2012-03-01 17:41:02 +01:00
|
|
|
$leg_max_length = strlen($l);
|
|
|
|
}
|
|
|
|
}
|
2012-03-05 20:25:02 +01:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$fontsize = 7;
|
2012-09-28 16:06:20 +02:00
|
|
|
|
2012-03-08 13:32:59 +01:00
|
|
|
$extra_height = 15;
|
2015-03-30 10:17:35 +02:00
|
|
|
if (defined("METACONSOLE"))
|
|
|
|
$extra_height = 20;
|
2012-09-28 16:06:20 +02:00
|
|
|
|
2012-03-08 13:32:59 +01:00
|
|
|
$return .= "<div id='extra_$graph_id' style='font-size: ".$fontsize."pt; display:none; position:absolute; overflow: auto; height: ".$extra_height."px; background:#fff; padding: 2px 2px 2px 2px; border: solid #000 1px;'></div>";
|
2012-03-01 17:41:02 +01:00
|
|
|
|
|
|
|
$maxticks = (int) ($width / ($fontsize * $leg_max_length));
|
|
|
|
|
|
|
|
$i_aux = $i;
|
|
|
|
while(1) {
|
2013-07-17 13:12:37 +02:00
|
|
|
if ($i_aux <= $maxticks ) {
|
2012-03-01 17:41:02 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$intervaltick*= 2;
|
|
|
|
|
|
|
|
$i_aux /= 2;
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
}
|
2012-03-01 17:41:02 +01:00
|
|
|
|
|
|
|
$intervaltick = (int) $intervaltick;
|
|
|
|
$acumulate = 0;
|
|
|
|
$c = 0;
|
|
|
|
$acumulate_data = array();
|
2013-07-17 13:12:37 +02:00
|
|
|
foreach ($graph_data as $label => $values) {
|
2017-12-13 17:17:45 +01:00
|
|
|
$labels[] = $label;
|
2012-03-01 17:41:02 +01:00
|
|
|
$i--;
|
2012-03-05 20:25:02 +01:00
|
|
|
|
2013-07-17 13:12:37 +02:00
|
|
|
foreach ($values as $key => $value) {
|
2012-03-01 17:41:02 +01:00
|
|
|
$jsvar = "d_".$graph_id."_".$i;
|
2013-07-17 13:12:37 +02:00
|
|
|
if ($key == 'data') {
|
2012-03-01 17:41:02 +01:00
|
|
|
$datacolor[$jsvar] = $colors[$value];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$data[$jsvar][] = $value;
|
|
|
|
|
|
|
|
$acumulate_data[$c] = $acumulate;
|
|
|
|
$acumulate += $value;
|
|
|
|
$c++;
|
|
|
|
|
2013-07-17 13:12:37 +02:00
|
|
|
if ($value > $max) {
|
2012-03-01 17:41:02 +01:00
|
|
|
$max = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store serialized data to use it from javascript
|
|
|
|
$labels = implode($separator,$labels);
|
|
|
|
$datacolor = implode($separator,$datacolor);
|
|
|
|
$legend = io_safe_output(implode($separator,$legend));
|
2017-07-10 16:22:41 +02:00
|
|
|
if (!empty($full_legend_date)) {
|
|
|
|
$full_legend_date = io_safe_output(implode($separator,$full_legend_date));
|
|
|
|
}
|
2017-07-24 16:34:22 +02:00
|
|
|
else {
|
|
|
|
$full_legend_date = false;
|
|
|
|
}
|
2012-03-01 17:41:02 +01:00
|
|
|
$acumulate_data = io_safe_output(implode($separator,$acumulate_data));
|
2012-03-05 20:25:02 +01:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
// Store data series in javascript format
|
|
|
|
$jsvars = '';
|
|
|
|
$jsseries = array();
|
|
|
|
|
|
|
|
$date = get_system_time ();
|
|
|
|
$datelimit = ($date - $period) * 1000;
|
2012-03-05 20:25:02 +01:00
|
|
|
|
2012-03-01 17:41:02 +01:00
|
|
|
$i = 0;
|
|
|
|
|
|
|
|
$values2 = array();
|
2012-03-05 20:25:02 +01:00
|
|
|
|
2013-03-12 17:20:53 +01:00
|
|
|
foreach ($data as $jsvar => $values) {
|
2012-03-01 17:41:02 +01:00
|
|
|
$values2[] = implode($separator,$values);
|
|
|
|
$i ++;
|
|
|
|
}
|
2012-03-05 20:25:02 +01:00
|
|
|
|
2013-03-12 17:20:53 +01:00
|
|
|
$values = implode($separator2, $values2);
|
2012-03-01 17:41:02 +01:00
|
|
|
|
|
|
|
// Javascript code
|
|
|
|
$return .= "<script type='text/javascript'>";
|
2012-09-19 Miguel de Dios <miguel.dedios@artica.es>
* extensions/resource_registration.php, extensions/system_info.php,
extensions/update_manager/lib/libupdate_manager.php,
godmode/agentes/modificar_agente.php,
godmode/alerts/alert_actions.php,
godmode/alerts/alert_list.list.php,
godmode/massive/massive_add_profiles.php,
godmode/massive/massive_edit_modules.php,
godmode/servers/manage_recontask.php,
godmode/setup/setup_visuals.php, include/functions_api.php,
include/functions_graph.php, include/functions_messages.php,
include/graphs/functions_flot.php,
include/graphs/flot/pandora.flot.js, operation/tree.php,
operation/agentes/status_events.php,
operation/agentes/ver_agente.php, operation/events/events_list.php,
operation/events/events_marquee.php,
operation/events/events_rss.php: cleaned source code style.
* godmode/reporting/reporting_builder.item_editor.php,
include/functions_ui.php, include/ajax/agent.php: continue to change
to the new function "ui_print_agent_autocomplete_input" to make more
easy (and standar) the autocomplete agent input.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6988 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-09-19 16:45:59 +02:00
|
|
|
$return .= "//<![CDATA[\n";
|
2017-07-10 16:22:41 +02:00
|
|
|
$return .= "pandoraFlotSlicebar('$graph_id', '$values', '$datacolor', '$labels', '$legend', '$acumulate_data', $intervaltick, false, $max, '$separator', '$separator2', '', $id_agent, '$full_legend_date')";
|
2012-03-01 17:41:02 +01:00
|
|
|
$return .= "\n//]]>";
|
|
|
|
$return .= "</script>";
|
2012-03-05 20:25:02 +01:00
|
|
|
|
2013-03-12 17:20:53 +01:00
|
|
|
return $return;
|
2012-03-01 17:41:02 +01:00
|
|
|
}
|
2013-12-12 15:49:36 +01:00
|
|
|
?>
|