From 5a612bcfbe442270f0d04cc643896eadb781c4dd Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 20 Jun 2013 11:17:14 +0000 Subject: [PATCH] 2013-06-20 Miguel de Dios * include/graphs/fgraph.php, include/graphs/functions_pchart.php: merged the changes from the branch 4. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8365 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 +++++ pandora_console/include/graphs/fgraph.php | 3 ++- .../include/graphs/functions_pchart.php | 20 ++++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 7d51b9df53..59565beb0a 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2013-06-20 Miguel de Dios + + * include/graphs/fgraph.php, include/graphs/functions_pchart.php: + merged the changes from the branch 4. + 2013-06-20 Miguel de Dios * godmode/agentes/modificar_agente.php: fixed the filter of the diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index bd2cb2d5ac..17eedef2e8 100755 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -270,6 +270,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend, $id_graph = serialize_in_temp($graph, null, $ttl); + return ""; } } @@ -463,7 +464,7 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height, setup_watermark($water_mark, $water_mark_file, $water_mark_url); // This library allows only 8 colors - $max_values = 8; + $max_values = 5; //Remove the html_entities $temp = array(); diff --git a/pandora_console/include/graphs/functions_pchart.php b/pandora_console/include/graphs/functions_pchart.php index 805cf4d94f..49c8bf4ac6 100755 --- a/pandora_console/include/graphs/functions_pchart.php +++ b/pandora_console/include/graphs/functions_pchart.php @@ -241,7 +241,7 @@ if (empty($colors)) { $colors = array(); } -foreach($colors as $i => $color) { +foreach ($colors as $i => $color) { $rgb['border'] = html_html2rgb($color['border']); $rgb_color[$i]['border']['R'] = $rgb['border'][0]; $rgb_color[$i]['border']['G'] = $rgb['border'][1]; @@ -392,7 +392,7 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width, $myPicture = new pImage($width,$height,$MyData,TRUE); /* Set the default font properties */ - $myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size,"R"=>80,"G"=>80,"B"=>80)); + $myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size,"R"=>80,"G"=>80,"B"=>80)); $water_mark_height = 0; $water_mark_width = 0; @@ -428,9 +428,11 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width, /* Write down the legend next to the 2nd chart*/ //Calculate the bottom margin from the size of string in each index $max_chars = graph_get_max_index($legend_values); - $legend_with_aprox = 32 + (7 * $max_chars); if ($legend_position != 'hidden') { + // This is a hardcore adjustment to match most of the graphs, please don't alter + $legend_with_aprox = 32 + (4.5 * $max_chars); + $PieChart->drawPieLegend($width - $legend_with_aprox, 5, array("R"=>255,"G"=>255,"B"=>255, "BoxSize"=>10)); } @@ -613,6 +615,7 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font, function pch_vertical_graph ($graph_type, $index, $data, $width, $height, $rgb_color = false, $xaxisname = "", $yaxisname = "", $show_values = false, $legend = array(), $font, $antialiasing, $water_mark = '', $font_size) { + /* CAT:Vertical Charts */ if (!is_array($legend) || empty($legend)) { unset($legend); @@ -757,12 +760,19 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, $chart_size = ($digits_left * $font_size) + 20; + $max_data = max(max($data)); + + $default_chart_size = 40; + $rest_chars = strlen($max_data) - 6; + $default_chart_size += $rest_chars * 5; + + /* Area depends on yaxisname */ if ($yaxisname != '') { - $chart_size += 40; + $chart_size += $default_chart_size; } else { - $chart_size = 40; + $chart_size = $default_chart_size; } if (isset($size['Height'])) {