From 34f33c76edfd309a8dc158658bdd2dffc1942254 Mon Sep 17 00:00:00 2001 From: Reinhard Scheck Date: Sun, 4 Nov 2007 13:46:45 +0000 Subject: [PATCH] Fixed extra spaces in GPRINT. See http://bugs.cacti.net/view.php?id=1067 Copy of r4295 for branches/0.8.7 git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/cacti/branches/0.8.7@4306 860744bd-22fc-0310-8c96-e9fe5004b5ca --- docs/CHANGELOG | 1 + lib/rrd.php | 28 ++++++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 9c7712ea0..3119c4c62 100644 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -1,6 +1,7 @@ Cacti CHANGELOG 0.8.7a +-bug#0001067: Fixed extra spaces in GPRINT. Better Alignment for Autopadding -bug#0001038: Data sources in RRAs have random order, messing up predefined CDEFs -bug#0001043: Graph Templates drop down populates with duplicates -bug#0001046: Upgrade from 0.8.6j to 0.8.7 defaults to Authentication Method NONE diff --git a/lib/rrd.php b/lib/rrd.php index 3d3a89934..5a7e6b82b 100644 --- a/lib/rrd.php +++ b/lib/rrd.php @@ -874,12 +874,12 @@ function rrdtool_function_graph($local_graph_id, $rra_id, $graph_data_array, $rr of course it can be used in other situations, however may not work as intended. If you have any additions to this small peice of code, feel free to send them to me. */ if ($graph["auto_padding"] == "on") { - /* only applies to AREA and STACK */ + /* only applies to AREA, STACK and LINEs */ if (ereg("(AREA|STACK|LINE[123])", $graph_item_types{$graph_item["graph_type_id"]})) { - $text_format_lengths{$graph_item["data_template_rrd_id"]} = strlen($graph_variables["text_format"][$graph_item_id]); + $text_format_length = strlen($graph_variables["text_format"][$graph_item_id]); - if ((strlen($graph_variables["text_format"][$graph_item_id]) > $greatest_text_format) && ($graph_item_types{$graph_item["graph_type_id"]} != "COMMENT")) { - $greatest_text_format = strlen($graph_variables["text_format"][$graph_item_id]); + if ($text_format_length > $greatest_text_format) { + $greatest_text_format = $text_format_length; } } } @@ -1001,17 +1001,21 @@ function rrdtool_function_graph($local_graph_id, $rra_id, $graph_data_array, $rr /* if we are not displaying a legend there is no point in us even processing the auto padding, text format stuff. */ - if ((!isset($graph_data_array["graph_nolegend"])) && ($graph["auto_padding"] == "on") && (isset($text_format_lengths{$graph_item["data_template_rrd_id"]}))) { - /* we are basing how much to pad on area and stack text format, - not gprint. but of course the padding has to be displayed in gprint, - how fun! */ + if ((!isset($graph_data_array["graph_nolegend"])) && ($graph["auto_padding"] == "on")) { + /* only applies to AREA, STACK and LINEs */ + if (ereg("(AREA|STACK|LINE[123])", $graph_item_types{$graph_item["graph_type_id"]})) { + $text_format_length = strlen($graph_variables["text_format"][$graph_item_id]); - $pad_number = ($greatest_text_format - $text_format_lengths{$graph_item["data_template_rrd_id"]}); - //cacti_log("MAX: $greatest_text_format, CURR: $text_format_lengths[$item_dsid], DSID: $item_dsid"); - $text_padding = str_pad("", $pad_number); + /* we are basing how much to pad on area and stack text format, + not gprint. but of course the padding has to be displayed in gprint, + how fun! */ + + $pad_number = ($greatest_text_format - $text_format_length); + //cacti_log("MAX: $greatest_text_format, CURR: $text_format_lengths[$item_dsid], DSID: $item_dsid"); + $text_padding = str_pad("", $pad_number); /* two GPRINT's in a row screws up the padding, lets not do that */ - if (($graph_item_types{$graph_item["graph_type_id"]} == "GPRINT") && ($last_graph_type == "GPRINT")) { + } else if (($graph_item_types{$graph_item["graph_type_id"]} == "GPRINT") && ($last_graph_type == "GPRINT")) { $text_padding = ""; }