From cca80873f5ed52f79f487044befca452eeebc5ae Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 14 Apr 2011 13:53:46 +0000 Subject: [PATCH] 2011-04-14 Miguel de Dios * include/graphs/functions_pchart.php: added method to force height or not, changed to show all columns name in the hgraph and vgraph, fixed the colors when passed the parameter "fine" to color. And in the function "pch_bar_graph" change to calculate left margin instead to fixed value. * include/graphs/fgraph.php: added new parameter in the function "hbar_graph" to force or unforce the graph height. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4221 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 10 ++++++ pandora_console/include/graphs/fgraph.php | 4 ++- .../include/graphs/functions_pchart.php | 32 ++++++++++++++++++- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index ec3ffe020f..57ab893a17 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2011-04-14 Miguel de Dios + + * include/graphs/functions_pchart.php: added method to force height or not, + changed to show all columns name in the hgraph and vgraph, fixed the colors + when passed the parameter "fine" to color. And in the function + "pch_bar_graph" change to calculate left margin instead to fixed value. + + * include/graphs/fgraph.php: added new parameter in the function + "hbar_graph" to force or unforce the graph height. + 2011-04-14 Miguel de Dios * include/graphs/functions_pchart.php: setted the xmargin to 0. diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 850f0b63d3..670364526b 100755 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -10,6 +10,7 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. + // If is called from index if(file_exists('include/functions.php')) { include_once('include/functions.php'); @@ -260,7 +261,7 @@ function polar_graph($flash_chart, $chart_data, $width, $height, $no_data_image) return kiviat_graph('polar', $flash_chart, $chart_data, $width, $height, $no_data_image); } -function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array(), $legend = array(), $xaxisname = "", $yaxisname = "") { +function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array(), $legend = array(), $xaxisname = "", $yaxisname = "", $force_height = true) { if($flash_chart) { echo fs_hbar_chart (array_values($chart_data), array_keys($chart_data), $width, $height); } @@ -273,6 +274,7 @@ function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array() $graph['legend'] = $legend; $graph['xaxisname'] = $xaxisname; $graph['yaxisname'] = $yaxisname; + $graph['force_height'] = $force_height; $id_graph = serialize_in_temp($graph); diff --git a/pandora_console/include/graphs/functions_pchart.php b/pandora_console/include/graphs/functions_pchart.php index a37b460c9b..2e311a82e3 100755 --- a/pandora_console/include/graphs/functions_pchart.php +++ b/pandora_console/include/graphs/functions_pchart.php @@ -72,6 +72,17 @@ if(isset($graph['font'])) { if(isset($graph['round_corner'])) { $round_corner = $graph['round_corner']; } +$force_height = true; +if(isset($graph['force_height'])) { + $force_height = $graph['force_height']; +} + +if (!$force_height) { + if ($height < (count($graph['data']) * 14)) { + $height = (count($graph['data']) * 14); + } +} + /* $colors = array(); @@ -92,6 +103,11 @@ else { } $step = round($ndata/$xdata_display); + +if(($graph_type == 'hbar') || ($graph_type == 'vbar')) { + $step = 1; +} + $c = 0; switch($graph_type) { @@ -127,6 +143,7 @@ switch($graph_type) { $fine_colors[$i]['B'] = $rgb_fine[2]; $fine_colors[$i]['Alpha'] = 100; } + $colors = array(); } break; @@ -456,7 +473,20 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $rgb_color break; case "hbar": $scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE, "Mode"=>SCALE_MODE_START0, "Pos"=>SCALE_POS_TOPBOTTOM); - $leftmargin = 100; + //$leftmargin = 100; + + //Calculate the bottom margin from the size of string in each index + $max_chars = 0; + foreach ($index as $string_index) { + if (empty($string_index)) continue; + + $len = strlen($string_index); + if ($len > $max_chars) { + $max_chars = $len; + } + } + $leftmargin = 5 * $max_chars; + break; }