From ee963b0ae06fb1fcf113be6709ca73dd254aa5e2 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 6 Apr 2011 14:42:31 +0000 Subject: [PATCH] 2011-04-06 Miguel de Dios * include/functions_graph.php: wip in the function "graphic_combined_module2". * include/graphs/functions_fsgraph.php: fixed when "fs_area_graph" when send a graph without the colours or and legend. * include/graphs/fgraph.php: erased lost session instructions in the function "area_graph". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4175 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 10 +++++ pandora_console/include/functions_graph.php | 42 +++++++++++++++--- pandora_console/include/graphs/fgraph.php | 1 - .../include/graphs/functions_fsgraph.php | 43 +++++++++++++++---- 4 files changed, 79 insertions(+), 17 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 2c537ef2c2..f20ffc6f5d 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2011-04-06 Miguel de Dios + * include/functions_graph.php: wip in the function + "graphic_combined_module2". + + * include/graphs/functions_fsgraph.php: fixed when "fs_area_graph" when + send a graph without the colours or and legend. + + * include/graphs/fgraph.php: erased lost session instructions in the + function "area_graph". + 2011-04-06 Javier Lanz * include/functions_reporting.php: Added case to display 'agent_module' diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 062da7a8a1..16b8792b3f 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -425,7 +425,10 @@ function graphic_combined_module2 ($module_list, $weight_list, $period, $width, $k = 0; // Set initial conditions - $graph_values[$i] = array(); + + //$graph_values[$i] = array(); + $temp_graph_values = array(); + if ($data[0]['utimestamp'] == $datelimit) { $previous_data = $data[0]['datos']; $j++; @@ -474,23 +477,48 @@ function graphic_combined_module2 ($module_list, $weight_list, $period, $width, // Data if ($count > 0) { - $graph_values[$i][$timestamp] = $total * $weight_list[$i]; + //$graph_values[$i][$timestamp] = $total * $weight_list[$i]; + $temp_graph_values[$timestamp] = $total * $weight_list[$i]; + $previous_data = $total; // Compressed data } else { if ($uncompressed_module || ($timestamp > time ())) { - $graph_values[$i][$timestamp] = 0; - } else { - $graph_values[$i][$timestamp] = $previous_data * $weight_list[$i]; + //$graph_values[$i][$timestamp] = 0; + $temp_graph_values[$timestamp] = 0; + } + else { + //$graph_values[$i][$timestamp] = $previous_data * $weight_list[$i]; + $temp_graph_values[$timestamp] = $previous_data * $weight_list[$i]; } } + + $graph_values[$i] = $temp_graph_values; + } + + if ($weight_list[$i] != 1) { + $module_name_list[$i] .= " (x". format_numeric ($weight_list[$i], 1).")"; + } + + $graph_values[$module_name_list[$i]] = $graph_values[$i]; + unset($graph_values[$i]); + } + + $temp = array(); //debugPrint($graph_values); + foreach ($graph_values as $graph_group => $point) { + foreach ($point as $timestamp_point => $point_value) { + $temp[$timestamp_point][$graph_group] = $point_value; } } + $graph_values = $temp; + /* for ($i = 0; $i < $module_number; $i++) { - if ($weight_list[$i] != 1) + if ($weight_list[$i] != 1) { $module_name_list[$i] .= " (x". format_numeric ($weight_list[$i], 1).")"; + } } + */ if ($period <= 3600) { $title_period = __('Last hour'); @@ -512,7 +540,7 @@ function graphic_combined_module2 ($module_list, $weight_list, $period, $width, switch ($stacked) { case 0: return area_graph($config['flash_charts'], $graph_values, $width, $height, - $color, $legend, $long_index); + array(), $module_name_list, array()); return; break; default: diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 39b5446023..30579cc344 100755 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -58,7 +58,6 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color,$legend, $graph['legend'] = $legend; serialize_in_temp($graph, $id_graph); - session_write_close(); return ""; } diff --git a/pandora_console/include/graphs/functions_fsgraph.php b/pandora_console/include/graphs/functions_fsgraph.php index 8561d1c02d..85fc4f84ef 100755 --- a/pandora_console/include/graphs/functions_fsgraph.php +++ b/pandora_console/include/graphs/functions_fsgraph.php @@ -70,9 +70,11 @@ function fs_area_graph($chart_data, $width, $height, $color, $legend, $long_inde $show_name = '1'; } - $chart->addCategory($i, //''); - 'hoverText=' . $long_index[$i] . - ';showName=' . $show_name); + if (isset($long_index[$i])) { + $chart->addCategory($i, //''); + 'hoverText=' . $long_index[$i] . + ';showName=' . $show_name); + } $c = 0; foreach($values as $i2 => $value) { @@ -90,15 +92,38 @@ function fs_area_graph($chart_data, $width, $height, $color, $legend, $long_inde $empty = 1; foreach ($data as $i => $value) { - $showAreaBorder = 0; - if (!is_null($color[$i]['border'])) { - $showAreaBorder = 1; + + $legend = ''; + if (isset($legend[$i])) { + $legend = $legend[$i]; } - $chart->addDataSet($legend[$i], 'alpha=' . $color[$i]['alpha'] . ';' . + $alpha = ''; + $areaBorderColor = ''; + $color = ''; + $showAreaBorder = 0; + if (isset($color[$i])) { + if (!isset($color[$i]['border'])) { + $showAreaBorder = 1; + } + + if (isset($color[$i]['alpha'])) { + $alpha = 'alpha=' . $color[$i]['alpha'] . ';'; + } + + if (isset($color[$i]['border'])) { + $areaBorderColor = 'areaBorderColor=' . $color[$i]['border'] . ';'; + } + + if (isset($color[$i]['color'])) { + $color = 'color=#' . $color[$i]['color']; + } + } + + $chart->addDataSet($legend, $alpha . 'showAreaBorder=' . $showAreaBorder . ';' . - 'areaBorderColor=' . $color[$i]['border'] . ';' . - 'color=#' . $color[$i]['color']); + $areaBorderColor . + $color); $count = 0; $step = 10;