--- lib/graph_variables.php	2006-01-03 21:08:30.000000000 -0600
+++ lib/graph_variables.php	2006-01-06 22:40:31.032460462 -0600
@@ -302,27 +302,34 @@
 
 	/* format the output according to args passed to the variable */
 	if ($regexp_match_array[4] == "current") {
+		if (! empty($nth_cache{$graph_item["local_data_id"]}{$graph_item["data_source_name"]})) {
 		$nth = $nth_cache{$graph_item["local_data_id"]}{$graph_item["data_source_name"]};
 		$nth = ($regexp_match_array[2] == "bits") ? $nth * 8 : $nth;
 		$nth /= pow(10,intval($regexp_match_array[3]));
+		}
 	}elseif ($regexp_match_array[4] == "total") {
 		for ($t=0;($t<count($graph_items));$t++) {
 			if ((ereg("(AREA|STACK|LINE[123])", $graph_item_types{$graph_items[$t]["graph_type_id"]})) && (!empty($graph_items[$t]["data_template_rrd_id"]))) {
+				if (! empty($nth_cache{$graph_items[$t]["local_data_id"]}{$graph_items[$t]["data_source_name"]})) {
 				$local_nth = $nth_cache{$graph_items[$t]["local_data_id"]}{$graph_items[$t]["data_source_name"]};
 				$local_nth = ($regexp_match_array[2] == "bits") ? $local_nth * 8 : $local_nth;
 				$local_nth /= pow(10,intval($regexp_match_array[3]));
 
 				$nth += $local_nth;
+				}
 
 			}
 		}
 	}elseif ($regexp_match_array[4] == "max") {
+		if (! empty($nth_cache{$graph_item["local_data_id"]}["nth_percentile_maximum"])) {
 		$nth = $nth_cache{$graph_item["local_data_id"]}["nth_percentile_maximum"];
 		$nth = ($regexp_match_array[2] == "bits") ? $nth * 8 : $nth;
 		$nth /= pow(10,intval($regexp_match_array[3]));
+		}
 	}elseif ($regexp_match_array[4] == "total_peak") {
 		for ($t=0;($t<count($graph_items));$t++) {
 			if ((ereg("(AREA|STACK|LINE[123])", $graph_item_types{$graph_items[$t]["graph_type_id"]})) && (!empty($graph_items[$t]["data_template_rrd_id"]))) {
+				if (! empty($nth_cache{$graph_items[$t]["local_data_id"]}["nth_percentile_maximum"])) {
 				$local_nth = $nth_cache{$graph_items[$t]["local_data_id"]}["nth_percentile_maximum"];
 				$local_nth = ($regexp_match_array[2] == "bits") ? $local_nth * 8 : $local_nth;
 				$local_nth /= pow(10,intval($regexp_match_array[3]));
@@ -330,9 +337,11 @@
 				$nth += $local_nth;
 			}
 		}
+		}
 	}elseif ($regexp_match_array[4] == "all_max_current") {
 		for ($t=0;($t<count($graph_items));$t++) {
 			if ((ereg("(AREA|STACK|LINE[123])", $graph_item_types{$graph_items[$t]["graph_type_id"]})) && (!empty($graph_items[$t]["data_template_rrd_id"]))) {
+				if (! empty($ninety_fifth_cache{$graph_items[$t]["local_data_id"]}{$graph_items[$t]["data_source_name"]})) {
 				$local_nth = $ninety_fifth_cache{$graph_items[$t]["local_data_id"]}{$graph_items[$t]["data_source_name"]};
 				$local_nth = ($regexp_match_array[2] == "bits") ? $local_nth * 8 : $local_nth;
 				$local_nth /= pow(10,intval($regexp_match_array[3]));
@@ -342,9 +351,11 @@
 				}
 			}
 		}
+		}
 	}elseif ($regexp_match_array[4] == "all_max_peak") {
 		for ($t=0;($t<count($graph_items));$t++) {
 			if ((ereg("(AREA|STACK|LINE[123])", $graph_item_types{$graph_items[$t]["graph_type_id"]})) && (!empty($graph_items[$t]["data_template_rrd_id"]))) {
+				if (! empty($nth_cache{$graph_items[$t]["local_data_id"]}["nth_percentile_maximum"])) {
 				$local_nth = $nth_cache{$graph_items[$t]["local_data_id"]}["nth_percentile_maximum"];
 				$local_nth = ($regexp_match_array[2] == "bits") ? $local_nth * 8 : $local_nth;
 				$local_nth /= pow(10,intval($regexp_match_array[3]));
@@ -354,28 +365,23 @@
 				}
 			}
 		}
+		}
 	}elseif ($regexp_match_array[4] == "aggregate") {
-		if (empty($nth_cache{0}["nth_percentile_aggregate_total"])) {
-			$nth = 0;
-		}else{
+		if (! empty($nth_cache{0}["nth_percentile_aggregate_total"])) {
 			$local_nth = $nth_cache{0}["nth_percentile_aggregate_total"];
 			$local_nth = ($regexp_match_array[2] == "bits") ? $local_nth * 8 : $local_nth;
 			$local_nth /= pow(10,intval($regexp_match_array[3]));
 			$nth = $local_nth;
 		}
 	}elseif ($regexp_match_array[4] == "aggregate_max") {
-		if (empty($nth_cache{0}["nth_percentile_aggregate_max"])) {
-			$nth = 0;
-		}else{
+		if (! empty($nth_cache{0}["nth_percentile_aggregate_max"])) {
 			$local_nth = $nth_cache{0}["nth_percentile_aggregate_max"];
 			$local_nth = ($regexp_match_array[2] == "bits") ? $local_nth * 8 : $local_nth;
 			$local_nth /= pow(10,intval($regexp_match_array[3]));
 			$nth = $local_nth;
 		}
 	}elseif ($regexp_match_array[4] == "aggregate_sum") {
-		if (empty($nth_cache{0}["nth_percentile_aggregate_sum"])) {
-			$nth = 0;
-		}else{
+		if (! empty($nth_cache{0}["nth_percentile_aggregate_sum"])) {
 			$local_nth = $nth_cache{0}["nth_percentile_aggregate_sum"];
 			$local_nth = ($regexp_match_array[2] == "bits") ? $local_nth * 8 : $local_nth;
 			$local_nth /= pow(10,intval($regexp_match_array[3]));
