diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index cd0902b634..f856d2dd1a 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2011-04-13 Sergio Martin + + * include/graphs/functions_pchart.php + include/functions_custom_graphs.php: Improved the + vertical graph legend to use in horizontal when + is possible. + Fixing a Miguel modification erased by me in the last + commit. + Fix a combined graph bug in the size + 2011-04-13 Sergio Martin * include/functions_graph.php diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php index 7164a58fc8..24551e1a64 100644 --- a/pandora_console/include/functions_custom_graphs.php +++ b/pandora_console/include/functions_custom_graphs.php @@ -28,6 +28,8 @@ if ($config['flash_charts']) { require_once ('include/fgraph.php'); } +require_once ($config["homedir"] . '/include/functions_graph.php'); + /** * Get all the custom graphs a user can see. * @@ -89,11 +91,10 @@ function get_user_custom_graphs ($id_user = 0, $only_names = false, $returnAllGr * @param $return Whether to return an output string or echo now (optional, echo by default). * @param $date Date to start printing the graph */ + function print_custom_graph ($id_graph, $height, $width, $period, $stacked, $return = false, $date = 0) { global $config; - - require_once ($config["homedir"] . '/include/functions_graph.php'); - + $sources = get_db_all_rows_field_filter ('tgraph_source', 'id_graph', $id_graph); $modules = array (); $weights = array (); diff --git a/pandora_console/include/graphs/functions_pchart.php b/pandora_console/include/graphs/functions_pchart.php index 0c82729d1e..5f72afbbf2 100755 --- a/pandora_console/include/graphs/functions_pchart.php +++ b/pandora_console/include/graphs/functions_pchart.php @@ -566,9 +566,16 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, $rgb_c $myPicture->setFontProperties(array("FontName"=>"../fonts/code.ttf","FontSize"=>10)); if(isset($legend)) { + /* Set horizontal legend if is posible */ + $legend_mode = LEGEND_HORIZONTAL; + $size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>$legend_mode)); + if($size['Width'] > ($width - 5)) { + $legend_mode = LEGEND_VERTICAL; + $size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>$legend_mode)); + } + /* Write the chart legend */ - $size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_VERTICAL)); - $myPicture->drawLegend($width-$size['Width'], 8,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_VERTICAL)); + $myPicture->drawLegend($width-$size['Width'], 8,array("Style"=>LEGEND_NOBORDER,"Mode"=>$legend_mode)); } //Calculate the bottom margin from the size of string in each index @@ -742,4 +749,4 @@ function pch_horizontal_graph ($graph_type, $index, $data, $width, $height, $xax /* Render the picture */ $myPicture->stroke(); } -?> +?> \ No newline at end of file