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 bf94c6b443
commit 8c3fb8d18f
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>
* include/functions_config.php,

View File

@ -89,7 +89,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$previous_data['utimestamp'] = $datelimit;
array_unshift ($data, $previous_data);
}
// Get next data
$nextData = modules_get_next_data ($agent_module_id, $date);
if ($nextData !== false) {
@ -145,9 +145,11 @@ 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
for ($i = 0; $i < $resolution; $i++) {
$timestamp = $datelimit + ($interval * $i);
@ -223,8 +225,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$chart[$timestamp]['sum'] = $total;
}
else {
$chart[$timestamp]['utimestamp'] = $timestamp;
$chart[$timestamp]['datos'] = $total;
//$chart[$timestamp]['utimestamp'] = $timestamp;
//$chart[$timestamp]['datos'] = $total;
$chart[$timestamp]['sum'] = $total;
$chart[$timestamp]['min'] = $interval_min;
$chart[$timestamp]['max'] = $interval_max;
@ -272,12 +274,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$chart[$timestamp]['baseline'] = 0;
}
}
if (!empty($units)) {
$chart[$timestamp]['unit'] = 0;
}
}
// Return chart data and don't draw
if ($return_data == 1) {
return $chart;
@ -302,12 +300,13 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
// Only show caption if graph is not small
if ($width > MIN_WIDTH_CAPTION && $height > MIN_HEIGHT)
//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
$caption = array();
///////
$color = array();
// Color commented not to restrict serie colors
/*$color = array();
$color['sum'] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50);
if($show_events) {
$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['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50);
$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['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['min'] = __('Min') . ' (' . format_for_graph($min_value) . ')';
$legend['baseline'] = __('Baseline');
$legend['unit'] = __('Units'). ' (' . $units . ')';
$flash_chart = $config['flash_charts'];
if ($only_image) {
@ -341,8 +339,9 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
if ($flash_chart) {
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,
$config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size'], $unit, $ttl);

View File

@ -622,7 +622,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
else {
$point_id = $i;
}
$MyData->addPoints($values,$point_id);
if (!empty($rgb_color)) {
$MyData->setPalette($point_id,
@ -650,7 +650,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
}
$MyData->setPalette($point_id, $palette_color);*/
}
}
$MyData->setSerieWeight($point_id, 0);
}
@ -700,15 +700,24 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
$myPicture->drawFromPNG(($width - $water_mark_width),
($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'])) {
/* 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 {
/* 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 */