From c9d3188e3520fd57b573c42f5e435fbd7d40dfbd Mon Sep 17 00:00:00 2001 From: slerena Date: Mon, 30 Aug 2010 11:52:13 +0000 Subject: [PATCH] 2010-08-29 Sancho Lerena * include/pchart_graph.php, include/fgraph.php, include/functions_fsgraph.php: Minor (but important) changes on graphs: combined wired mode available on flash, improved legends on both types, and improved flash wired modes. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3189 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 8 ++ pandora_console/include/fgraph.php | 2 +- pandora_console/include/functions_fsgraph.php | 68 ++++++++++++---- pandora_console/include/pchart_graph.php | 77 +++++++++++++------ 4 files changed, 118 insertions(+), 37 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 50b6d756b1..00c1122675 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2010-08-29 Sancho Lerena + + * include/pchart_graph.php, + include/fgraph.php, + include/functions_fsgraph.php: Minor (but important) changes on + graphs: combined wired mode available on flash, improved legends + on both types, and improved flash wired modes. + 2010-08-29 Raúl Mateos * godmode/agentes/fields_manager.php: Added code to show text if no diff --git a/pandora_console/include/fgraph.php b/pandora_console/include/fgraph.php index d94f9f1feb..4d863010a1 100644 --- a/pandora_console/include/fgraph.php +++ b/pandora_console/include/fgraph.php @@ -158,7 +158,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $ $agent_name = get_agentmodule_agent_name ($agent_module_id); $agent_id = get_agent_id ($agent_name); $module_name = get_agentmodule_name ($agent_module_id); - $module_name_list[$i] = $agent_name." / ".substr ($module_name, 0, 20); + $module_name_list[$i] = $agent_name." / ".substr ($module_name, 0, 40); $id_module_type = get_agentmodule_type ($agent_module_id); $module_type = get_moduletype_name ($id_module_type); $uncompressed_module = is_module_uncompressed ($module_type); diff --git a/pandora_console/include/functions_fsgraph.php b/pandora_console/include/functions_fsgraph.php index 82d58902f2..64101e166c 100644 --- a/pandora_console/include/functions_fsgraph.php +++ b/pandora_console/include/functions_fsgraph.php @@ -134,17 +134,36 @@ function fs_2d_area_chart ($data, $width, $height, $step = 1, $params = '') { function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $time_format = 'G:i', $show_events = 0, $show_alerts = 0, $caption = '') { global $config; + $graph_type = "MSArea2D"; //MSLine is possible also + // Generate the XML - $chart = new FusionCharts('MSArea2D', $width, $height); + $chart = new FusionCharts($graph_type, $width, $height); $num_vlines = 0; $count = 0; + // NO caption needed (graph avg/max/min stats are in the legend now) + /* if ($caption != '') { $chart->setChartParam("caption", $caption); } + */ + + $total_max = 0; + $total_avg = 0; + $total_min = 0; // Create categories foreach ($data as $value) { + + $total_avg +=$value["sum"]; + + if ($avg_only != 1){ + if ($value["max"] > $total_max) + $total_max =$value["max"]; + if ($value["min"] < $total_min) + $total_min =$value["min"]; + } + if ($count++ % $step == 0) { $show_name = '1'; $num_vlines++; @@ -154,6 +173,14 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti $chart->addCategory(date($time_format, $value['timestamp_bottom']), 'hoverText=' . date ($config['date_format'], $value['timestamp_bottom']) . ';showName=' . $show_name); } + if ($count > 0) + $total_avg = format_for_graph($total_avg / $count); + else + $total_avg = 0; + + $total_min = format_for_graph ($total_min); + $total_max = format_for_graph ($total_max); + // Event chart if ($show_events == 1) { $chart->addDataSet(__('Events'), 'alpha=50;showAreaBorder=1;areaBorderColor=#ff7f00;color=#ff7f00'); @@ -172,7 +199,7 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti // Max chart if ($avg_only == 0) { - $chart->addDataSet(__('Max'), 'color=' . $config['graph_color3']); + $chart->addDataSet(__('Max')." ($total_max)", 'color=' . $config['graph_color3']); foreach ($data as $value) { $chart->addChartData($value['max']); } @@ -180,7 +207,7 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti // Avg chart $empty = 1; - $chart->addDataSet(__('Avg'), 'color=' . $config['graph_color2']); + $chart->addDataSet(__('Avg'). " ($total_avg)", 'color=' . $config['graph_color2']); foreach ($data as $value) { if ($value['sum'] > 0) { $empty = 0; @@ -190,13 +217,13 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti // Min chart if ($avg_only == 0) { - $chart->addDataSet(__('Min'), 'color=' . $config['graph_color1']); + $chart->addDataSet(__('Min'). " ($total_min)", 'color=' . $config['graph_color1']); foreach ($data as $value) { $chart->addChartData($value['min']); } } - $chart->setChartParams('animation=0;numVDivLines=' . $num_vlines . ';showAlternateVGridColor=1;showNames=1;rotateNames=1;showValues=0;baseFontSize=9;showLimits=0;showAreaBorder=1;areaBorderThickness=1;areaBorderColor=000000' . ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : '')); + $chart->setChartParams('animation=0;numVDivLines=' . $num_vlines . ';showShadow=0;showAlternateVGridColor=1;showNames=1;rotateNames=1;lineThickness=0.1;anchorRadius=0.5;showValues=0;baseFontSize=9;showLimits=0;showAreaBorder=1;areaBorderThickness=0.1;areaBorderColor=000000' . ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : '')); $random_number = rand (); $div_id = 'chart_div_' . $random_number; @@ -208,7 +235,7 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti $output .= '