2012-01-24 Juan Manuel Ramon <juanmanuel.ramon@artica.es>

* include/functions_graph.php
	 include/graphs/functions_pchart.php: Added units in Y axis and 
	 fixed min, max and avg values. Also fixed colors fo min, max and
	 avg series.
	 
	Pending task: #3153343



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5419 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
juanmanuelr 2012-01-24 18:53:18 +00:00
parent 74aedbda44
commit 81c9d86bb6
3 changed files with 40 additions and 22 deletions

View File

@ -1,3 +1,13 @@
2012-01-24 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/functions_graph.php
include/graphs/functions_pchart.php: Added units in Y axis and
fixed min, max and avg values. Also fixed colors fo min, max and
avg series.
Pending task: #3153343
2012-01-24 Ramon Novoa <rnovoa@artica.es> 2012-01-24 Ramon Novoa <rnovoa@artica.es>
* include/functions_config.php, * include/functions_config.php,

View File

@ -146,7 +146,9 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
} }
} }
$units = modules_get_unit($agent_module_id); if (empty($unit)){
$unit = modules_get_unit($agent_module_id);
}
// Calculate chart data // Calculate chart data
for ($i = 0; $i < $resolution; $i++) { for ($i = 0; $i < $resolution; $i++) {
@ -223,8 +225,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$chart[$timestamp]['sum'] = $total; $chart[$timestamp]['sum'] = $total;
} }
else { else {
$chart[$timestamp]['utimestamp'] = $timestamp; //$chart[$timestamp]['utimestamp'] = $timestamp;
$chart[$timestamp]['datos'] = $total; //$chart[$timestamp]['datos'] = $total;
$chart[$timestamp]['sum'] = $total; $chart[$timestamp]['sum'] = $total;
$chart[$timestamp]['min'] = $interval_min; $chart[$timestamp]['min'] = $interval_min;
$chart[$timestamp]['max'] = $interval_max; $chart[$timestamp]['max'] = $interval_max;
@ -272,10 +274,6 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$chart[$timestamp]['baseline'] = 0; $chart[$timestamp]['baseline'] = 0;
} }
} }
if (!empty($units)) {
$chart[$timestamp]['unit'] = 0;
}
} }
// Return chart data and don't draw // Return chart data and don't draw
@ -302,12 +300,13 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
// Only show caption if graph is not small // Only show caption if graph is not small
if ($width > MIN_WIDTH_CAPTION && $height > MIN_HEIGHT) if ($width > MIN_WIDTH_CAPTION && $height > MIN_HEIGHT)
//Flash chart //Flash chart
$caption = __('Max. Value') . ': ' . $max_value . ' ' . __('Avg. Value') . ': ' . $avg_value . ' ' . __('Min. Value') . ': ' . $min_value . ' ' . __('Units. Value') . ': ' . $units; $caption = __('Max. Value') . ': ' . $max_value . ' ' . __('Avg. Value') . ': ' . $avg_value . ' ' . __('Min. Value') . ': ' . $min_value . ' ' . __('Units. Value') . ': ' . $unit;
else else
$caption = array(); $caption = array();
/////// ///////
$color = array(); // Color commented not to restrict serie colors
/*$color = array();
$color['sum'] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50); $color['sum'] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50);
if($show_events) { if($show_events) {
$color['event'] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50); $color['event'] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
@ -318,7 +317,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$color['max'] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50); $color['max'] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50);
$color['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50); $color['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50);
$color['baseline'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10); $color['baseline'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10);
$color['unit'] = array('border' => null, 'color' => '#0097BC', 'alpha' => 10); $color['unit'] = array('border' => null, 'color' => '#0097BC', 'alpha' => 10); */
$legend = array(); $legend = array();
$legend['sum'] = __('Avg') . ' (' . $avg_value . ')'; $legend['sum'] = __('Avg') . ' (' . $avg_value . ')';
@ -331,7 +330,6 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$legend['max'] = __('Max') . ' (' .format_for_graph($max_value) . ')'; $legend['max'] = __('Max') . ' (' .format_for_graph($max_value) . ')';
$legend['min'] = __('Min') . ' (' . format_for_graph($min_value) . ')'; $legend['min'] = __('Min') . ' (' . format_for_graph($min_value) . ')';
$legend['baseline'] = __('Baseline'); $legend['baseline'] = __('Baseline');
$legend['unit'] = __('Units'). ' (' . $units . ')';
$flash_chart = $config['flash_charts']; $flash_chart = $config['flash_charts'];
if ($only_image) { if ($only_image) {
@ -342,7 +340,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
include_flash_chart_script($homeurl); include_flash_chart_script($homeurl);
} }
return area_graph($flash_chart, $chart, $width, $height, $color,$legend, // Color commented not to restrict serie colors
return area_graph($flash_chart, $chart, $width, $height, '' /*$color*/ ,$legend,
$long_index, "images/image_problem.opaque.png", "", "", $homeurl, $long_index, "images/image_problem.opaque.png", "", "", $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png", $config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size'], $unit, $ttl); $config['fontpath'], $config['font_size'], $unit, $ttl);

View File

@ -701,14 +701,23 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
($height - $water_mark_height) - $margin_bottom, $water_mark); ($height - $water_mark_height) - $margin_bottom, $water_mark);
} }
/* Area depends on yaxisname */
if ($yaxisname != ''){
$chart_size = 80;
}
else{
$chart_size = 40;
}
if (isset($size['Height'])) { if (isset($size['Height'])) {
/* Define the chart area */ /* Define the chart area */
$myPicture->setGraphArea(40,$size['Height'],$width - $water_mark_width,$height - $margin_bottom); //if ($yaxisname != ''){
//}
$myPicture->setGraphArea($chart_size,$size['Height'],$width - $water_mark_width,$height - $margin_bottom);
} }
else { else {
/* Define the chart area */ /* Define the chart area */
$myPicture->setGraphArea(40, 5,$width - $water_mark_width,$height - $margin_bottom); $myPicture->setGraphArea($chart_size, 5,$width - $water_mark_width,$height - $margin_bottom);
} }
/* Draw the scale */ /* Draw the scale */