2012-02-27 Juan Manuel Ramon <juanmanuel.ramon@artica.es>

* include/functions_graph.php: Added avg_only option to boolean 
	graphs, string graphs have more space between elements in legend,
	added units to all graphs.
	* include/graphs/functions_fsgraph.php: Added unit to flash chart
	of type 2D column.
	* include/graphs/fgraph.php: Added unit to static version.
	* include/functions_forecast.php: Fixed division by zero in 
	projection graphs when all data is zero.
	* operation/agentes/stat_win.php: Added avg_only option for boolean
	graph. 



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5653 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
juanmanuelr 2012-02-27 16:20:28 +00:00
parent 5a0a461bfa
commit cdbe314418
6 changed files with 48 additions and 15 deletions

View File

@ -1,3 +1,16 @@
2012-02-27 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/functions_graph.php: Added avg_only option to boolean
graphs, string graphs have more space between elements in legend,
added units to all graphs.
* include/graphs/functions_fsgraph.php: Added unit to flash chart
of type 2D column.
* include/graphs/fgraph.php: Added unit to static version.
* include/functions_forecast.php: Fixed division by zero in
projection graphs when all data is zero.
* operation/agentes/stat_win.php: Added avg_only option for boolean
graph.
2012-02-27 Vanessa Gil <vanessa.gil@artica.es>
* godmode/agentes/agent_template.php: Fixed bug: values 'max_warning',

View File

@ -105,7 +105,10 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
// Linear correlation coefficient:
$avg_x = $cont/$sum_xi;
$avg_y = $cont/$sum_yi;
if ($sum_yi != 0)
$avg_y = $cont/$sum_yi;
else
$avg_y = 0;
$covariance = $sum_xi_yi/$cont;
$dev_x = sqrt(($sum_xi2/$cont) - ($avg_x*$avg_x));
$dev_y = sqrt(($sum_yi2/$cont) - ($avg_y*$avg_y));
@ -189,7 +192,7 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
}
// Using this function for prediction_date
if ($prediction_period == false){
// This statements stop the prediction when interval is greater than 4 years
// These statements stop the prediction when interval is greater than 4 years
if ($current_ts - $last_timestamp >= 126144000){
return false;
}

View File

@ -363,7 +363,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
// 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", "", $unit, $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size'], $unit, $ttl);
}
@ -1855,6 +1855,11 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
}
graphic_error ();
}
if (empty($unit_name)){
$unit = modules_get_unit($agent_module_id);
}else
$unit = $unit_name;
// Data iterator
$j = 0;
@ -1934,8 +1939,12 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
// Data and zeroes (draw a step)
if ($zero == 1 && $count > 0) {
$chart[$timestamp]['sum'] = $total;
$chart[$timestamp + 1] = array ('sum' => 0,
if ($avg_only) {
$chart[$timestamp]['sum'] = $total;
}
else {
$chart[$timestamp]['sum'] = $total;
$chart[$timestamp + 1] = array ('sum' => 0,
//'count' => 0,
//'timestamp_bottom' => $timestamp,
//'timestamp_top' => $timestamp + $interval,
@ -1943,6 +1952,7 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
'max' => 0,
'event' => $event_value,
'alert' => $alert_value);
}
$previous_data = 0;
// Just zeros
} else if ($zero == 1) {
@ -1964,8 +1974,10 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
//$chart[$timestamp]['count'] = 0;
//$chart[$timestamp]['timestamp_bottom'] = $timestamp;
//$chart[$timestamp]['timestamp_top'] = $timestamp + $interval;
$chart[$timestamp]['min'] = 0;
$chart[$timestamp]['max'] = 0;
if (!$avg_only){
$chart[$timestamp]['min'] = 0;
$chart[$timestamp]['max'] = 0;
}
if($show_events) {
$chart[$timestamp]['event'] = $event_value;
}
@ -2057,9 +2069,9 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
}
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", "", $unit, $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size'], "");
$config['fontpath'], $config['font_size'], $unit);
}
@ -2415,6 +2427,11 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
}
}
if (empty($unit_name)){
$unit = modules_get_unit($agent_module_id);
}
else
$unit = $unit_name;
/////////////////////////////////////////////////////////////////////////////////////////
$color = array();
@ -2434,9 +2451,9 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
$legend = null;
return vbar_graph($flash_chart, $chart, $width, $height, $color,
$legend, "", "", $homeurl,
$legend, "", $unit, $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size'], '', true, 1, true);
$config['fontpath'], $config['font_size'], true, true, 1, true);
}
function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event,

View File

@ -159,7 +159,7 @@ function vbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
$water_mark = '', $font = '', $font_size = '', $force_steps = true, $ttl = 1, $reduce_data_columns = false) {
if($flash_chart) {
echo fs_2d_column_chart ($chart_data, $width, $height, $homedir, $reduce_data_columns);
echo fs_2d_column_chart ($chart_data, $width, $height, $homedir, $reduce_data_columns, $yaxisname);
}
else {
$graph = array();

View File

@ -522,7 +522,7 @@ function fs_2d_pie_chart ($data, $names, $width, $height, $background = "FFFFFF"
}
// Returns a 2D column chart
function fs_2d_column_chart ($data, $width, $height, $homeurl = '', $reduce_data_columns = false) {
function fs_2d_column_chart ($data, $width, $height, $homeurl = '', $reduce_data_columns = false, $yaxisname = '') {
if (sizeof ($data) == 0) {
return;
}
@ -596,7 +596,7 @@ function fs_2d_column_chart ($data, $width, $height, $homeurl = '', $reduce_data
}
}
$chart->setChartParams('decimalPrecision=0;showAlternateVGridColor=1; numVDivLines='.$num_vlines.';showNames=1;rotateNames=1;showValues=0;showPercentageValues=0;showLimits=0;baseFontSize=9;'
$chart->setChartParams('yAxisName=' . $yaxisname . ';decimalPrecision=0;showAlternateVGridColor=1; numVDivLines='.$num_vlines.';showNames=1;rotateNames=1;showValues=0;showPercentageValues=0;showLimits=0;baseFontSize=9;'
. ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
// Return the code

View File

@ -164,7 +164,7 @@ echo "<br>";
switch ($graph_type) {
case 'boolean':
echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height,
$label, null, $draw_alerts, 1, false, $date, false, $urlImage);
$label, null, $draw_alerts, $avg_only, false, $date, false, $urlImage);
echo '<br><br><br>';
if ($show_events_graph)
echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom);