column of the global modules search

2011-12-22  Sergio Martin <sergio.martin@artica.es>

	* include/functions_graph.php: Fixed Date formats in graph
	axis to avoid loss data
	
	* include/functions_custom_graphs.php: Fixed number of hours of
	a week in the graphs combo




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5298 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2011-12-22 18:42:50 +00:00
parent 12afb58564
commit fb977dd4ce
5 changed files with 274 additions and 350 deletions

View File

@ -196,23 +196,18 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
// Set the title and time format
if ($period <= 21600) {
$title_period = __('Last hour');
$time_format = 'H:i:s';
}
elseif ($period < 86400) {
$title_period = __('Last day');
$time_format = 'H:i';
}
elseif ($period < 1296000) {
$title_period = __('Last week');
$time_format = 'M d H:i';
}
elseif ($period < 2592000) {
$title_period = __('Last month');
$time_format = 'M d H\h';
}
else {
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
$time_format = 'M d H\h';
}
@ -353,6 +348,22 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$config['fontpath'], $config['font_size'], $unit, $ttl);
}
function graph_get_formatted_date($timestamp, $format1, $format2) {
global $config;
if($config['flash_charts']) {
$date = date("$format1 $format2", $timestamp);
}
else {
$date = date($format1, $timestamp);
if($format2 != '') {
$date .= "\n".date($format2, $timestamp);
}
}
return $date;
}
/**
* Produces a combined/user defined graph
*
@ -378,27 +389,25 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
global $config;
global $graphic_type;
$time_format_2 = '';
// Set the title and time format
if ($period <= 21600) {
$title_period = __('Last hour');
$time_format = 'H:i:s';
}
elseif ($period < 86400) {
$title_period = __('Last day');
$time_format = 'H:i';
}
elseif ($period < 1296000) {
$title_period = __('Last week');
$time_format = 'M d H:i';
$time_format = 'M d';
$time_format_2 = 'H:i';
}
elseif ($period < 2592000) {
$title_period = __('Last month');
$time_format = 'M d H\h';
elseif ($period <= 2592000) {
$time_format = 'M d';
$time_format_2 = 'H\h';
}
else {
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
$time_format = 'M d H\h';
$time_format = 'M d';
}
// Set variables
@ -412,7 +421,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
$j = $datelimit;
$in_range = true;
while ($in_range){
$timestamp_f = date($time_format, $j);
$timestamp_f = graph_get_formatted_date($j, $time_format, $time_format_2);
//$timestamp_f = date('d M Y H:i:s', $j);
$before_projection[$timestamp_f] = 0;
@ -433,7 +443,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
// interval - This is the number of "rows" we are divided the time to fill data.
// more interval, more resolution, and slower.
// periodo - Gap of time, in seconds. This is now to (now-periodo) secs
// Init weights
for ($i = 0; $i < $module_number; $i++) {
if (! isset ($weight_list[$i])) {
@ -461,28 +471,6 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
}
$long_index = array();
// Set the title and time format
if ($period <= 21600) {
$title_period = __('Last hour');
$time_format = 'H:i:s';
}
elseif ($period < 86400) {
$title_period = __('Last day');
$time_format = 'H:i';
}
elseif ($period < 1296000) {
$title_period = __('Last week');
$time_format = 'M d H:i';
}
elseif ($period < 2592000) {
$title_period = __('Last month');
$time_format = 'M d H\h';
}
else {
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
$time_format = 'M d H\h';
}
$graph_values = array();
$module_name_list = array();
@ -603,7 +591,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
$countAvg ++;
$timestamp = $datelimit + ($interval * $l);
$timestamp_short = date($time_format, $timestamp);
$timestamp_short = graph_get_formatted_date($timestamp, $time_format, $time_format_2);
$long_index[$timestamp_short] = date(
html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp);
//$timestamp = $timestamp_short;
@ -725,28 +714,6 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
}
}
*/
// Set the title and time format
if ($period <= 21600) {
$title_period = __('Last hour');
$time_format = 'H:i:s';
}
elseif ($period < 86400) {
$title_period = __('Last day');
$time_format = 'H:i';
}
elseif ($period < 1296000) {
$title_period = __('Last week');
$time_format = 'M d H:i';
}
elseif ($period < 2592000) {
$title_period = __('Last month');
$time_format = 'M d H\h';
}
else {
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
$time_format = 'M d H\h';
}
$flash_charts = $config['flash_charts'];
@ -755,10 +722,6 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
}
if ($flash_charts){
include_flash_chart_script();
}
if ($flash_charts){
include_flash_chart_script();
}
@ -1808,23 +1771,18 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
// Set the title and time format
if ($period <= 21600) {
$title_period = __('Last hour');
$time_format = 'H:i:s';
}
elseif ($period < 86400) {
$title_period = __('Last day');
$time_format = 'H:i';
}
elseif ($period < 1296000) {
$title_period = __('Last week');
$time_format = 'M d H:i';
}
elseif ($period < 2592000) {
$title_period = __('Last month');
$time_format = 'M d H\h';
}
else {
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
$time_format = 'M d H\h';
}
@ -1907,23 +1865,18 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
///////////////////////////////////////////////////
// Set the title and time format
if ($period <= 21600) {
$title_period = __('Last hour');
$time_format = 'H:i:s';
}
elseif ($period < 86400) {
$title_period = __('Last day');
$time_format = 'H:i';
}
elseif ($period < 1296000) {
$title_period = __('Last week');
$time_format = 'M d H:i';
}
elseif ($period < 2592000) {
$title_period = __('Last month');
$time_format = 'M d H\h';
}
else {
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
$time_format = 'M d H\h';
}
@ -1989,23 +1942,18 @@ echo"<h4>Gráfica de área</h4>";
/////////////////////////////////////////////////////////////////
// Set the title and time format
if ($period <= 3600) {
$title_period = __('Last hour');
$time_format = 'G:i:s';
}
elseif ($period <= 86400) {
$title_period = __('Last day');
$time_format = 'G:i:s';
}
elseif ($period <= 604800) {
$title_period = __('Last week');
$time_format = 'M d H:i:s';
}
elseif ($period <= 2419200) {
$title_period = __('Last month');
$time_format = 'M d H\h';
}
else {
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
$time_format = 'M d H\h';
}
$timestamp_short = date($time_format, $date);
@ -2109,23 +2057,18 @@ function grafico_netflow_total_area ($data, $period,$width, $height , $title, $u
/////////////////////////////////////////////////////////////////
// Set the title and time format
if ($period <= 3600) {
$title_period = __('Last hour');
$time_format = 'G:i:s';
}
elseif ($period <= 86400) {
$title_period = __('Last day');
$time_format = 'G:i:s';
}
elseif ($period <= 604800) {
$title_period = __('Last week');
$time_format = 'M d H:i:s';
}
elseif ($period <= 2419200) {
$title_period = __('Last month');
$time_format = 'M d H\h';
}
else {
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
$time_format = 'M d H\h';
}
$timestamp_short = date($time_format, $date);
@ -2420,23 +2363,18 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
/////////////////////////////////////////////////////////////////
// Set the title and time format
if ($period <= 21600) {
$title_period = __('Last hour');
$time_format = 'H:i:s';
}
elseif ($period < 86400) {
$title_period = __('Last day');
$time_format = 'H:i';
}
elseif ($period < 1296000) {
$title_period = __('Last week');
$time_format = 'M d H:i';
}
elseif ($period < 2592000) {
$title_period = __('Last month');
$time_format = 'M d H\h';
}
else {
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
$time_format = 'M d H\h';
}
@ -2507,302 +2445,296 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event,
$width, $height , $title, $unit_name, $show_alert, $avg_only = 0, $pure=0,
$date = 0)
{
$date = 0) {
grafico_modulo_log4x_trace("<pre style='text-align:left;'>");
grafico_modulo_log4x_trace("<pre style='text-align:left;'>");
if ($date == "")
$now = time ();
else
$now = $date;
$now = $date;
$fechatope = $now - $periodo; // limit date
$fechatope = $now - $periodo; // limit date
$nombre_agente = modules_get_agentmodule_agent_name ($id_agente_modulo);
$nombre_modulo = modules_get_agentmodule_name ($id_agente_modulo);
$id_agente = agents_get_agent_id ($nombre_agente);
$one_second = 1;
$one_minute = 60 * $one_second;
$one_hour = 60 * $one_minute;
$one_day = 24 * $one_hour;
$one_week = 7 * $one_day;
$one_second = 1;
$one_minute = 60 * $one_second;
$one_hour = 60 * $one_minute;
$one_day = 24 * $one_hour;
$one_week = 7 * $one_day;
$adjust_time = $one_minute; // 60 secs
$adjust_time = $one_minute; // 60 secs
if ($periodo == 86400) // day
$adjust_time = $one_hour;
elseif ($periodo == 604800) // week
$adjust_time =$one_day;
elseif ($periodo == 3600) // hour
$adjust_time = 10 * $one_minute;
elseif ($periodo == 2419200) // month
$adjust_time = $one_week;
else
$adjust_time = $periodo / 12.0;
if ($periodo == 86400) // day
$adjust_time = $one_hour;
elseif ($periodo == 604800) // week
$adjust_time =$one_day;
elseif ($periodo == 3600) // hour
$adjust_time = 10 * $one_minute;
elseif ($periodo == 2419200) // month
$adjust_time = $one_week;
else
$adjust_time = $periodo / 12.0;
$num_slices = $periodo / $adjust_time;
$num_slices = $periodo / $adjust_time;
$fechatope_index = grafico_modulo_log4x_index($fechatope, $adjust_time);
$fechatope_index = grafico_modulo_log4x_index($fechatope, $adjust_time);
$sql1="SELECT utimestamp, SEVERITY " .
" FROM tagente_datos_log4x " .
" WHERE id_agente_modulo = $id_agente_modulo AND utimestamp > $fechatope and utimestamp < $now";
$sql1="SELECT utimestamp, SEVERITY " .
" FROM tagente_datos_log4x " .
" WHERE id_agente_modulo = $id_agente_modulo AND utimestamp > $fechatope and utimestamp < $now";
$valores = array();
$valores = array();
$max_count = -1;
$min_count = 9999999;
$max_count = -1;
$min_count = 9999999;
grafico_modulo_log4x_trace("$sql1");
grafico_modulo_log4x_trace("$sql1");
$rows = 0;
$first = true;
while ($row = get_db_all_row_by_steps_sql($first, $result, $sql1)){
$first = false;
$rows++;
$utimestamp = $row[0];
$severity = $row[1];
$severity_num = $row[2];
$rows = 0;
$first = true;
while ($row = get_db_all_row_by_steps_sql($first, $result, $sql1)){
$first = false;
$rows++;
$utimestamp = $row[0];
$severity = $row[1];
$severity_num = $row[2];
if (!isset($valores[$severity]))
$valores[$severity] = array();
if (!isset($valores[$severity]))
$valores[$severity] = array();
$dest = grafico_modulo_log4x_index($utimestamp, $adjust_time);
$dest = grafico_modulo_log4x_index($utimestamp, $adjust_time);
$index = (($dest - $fechatope_index) / $adjust_time) - 1;
$index = (($dest - $fechatope_index) / $adjust_time) - 1;
if (!isset($valores[$severity][$index])) {
$valores[$severity][$index] = array();
$valores[$severity][$index]['pivot'] = $dest;
$valores[$severity][$index]['count'] = 0;
$valores[$severity][$index]['alerts'] = 0;
}
if (!isset($valores[$severity][$index])) {
$valores[$severity][$index] = array();
$valores[$severity][$index]['pivot'] = $dest;
$valores[$severity][$index]['count'] = 0;
$valores[$severity][$index]['alerts'] = 0;
}
$valores[$severity][$index]['count']++;
$valores[$severity][$index]['count']++;
$max_count = max($max_count, $valores[$severity][$index]['count']);
$min_count = min($min_count, $valores[$severity][$index]['count']);
}
$max_count = max($max_count, $valores[$severity][$index]['count']);
$min_count = min($min_count, $valores[$severity][$index]['count']);
}
grafico_modulo_log4x_trace("$rows rows");
grafico_modulo_log4x_trace("$rows rows");
// Create graph
// *************
// Create graph
// *************
grafico_modulo_log4x_trace(__LINE__);
grafico_modulo_log4x_trace(__LINE__);
//set_error_handler("myErrorHandler");
grafico_modulo_log4x_trace(__LINE__);
grafico_modulo_log4x_trace(__LINE__);
set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . "/../../include");
require_once 'Image/Graph.php';
grafico_modulo_log4x_trace(__LINE__);
grafico_modulo_log4x_trace(__LINE__);
$Graph =& Image_Graph::factory('graph', array($width, $height));
grafico_modulo_log4x_trace(__LINE__);
$Graph =& Image_Graph::factory('graph', array($width, $height));
grafico_modulo_log4x_trace(__LINE__);
// add a TrueType font
$Font =& $Graph->addNew('font', $config['fontpath']); // C:\WINNT\Fonts\ARIAL.TTF
$Font->setSize(7);
$Graph->setFont($Font);
if ($periodo == 86400)
$title_period = $lang_label["last_day"];
elseif ($periodo == 604800)
$title_period = $lang_label["last_week"];
elseif ($periodo == 3600)
$title_period = $lang_label["last_hour"];
elseif ($periodo == 2419200)
$title_period = $lang_label["last_month"];
else {
$suffix = $lang_label["days"];
$graph_extension = $periodo / (3600*24); // in days
// add a TrueType font
$Font =& $Graph->addNew('font', $config['fontpath']); // C:\WINNT\Fonts\ARIAL.TTF
$Font->setSize(7);
if ($graph_extension < 1) {
$graph_extension = $periodo / (3600); // in hours
$suffix = $lang_label["hours"];
}
//$title_period = "Last ";
$title_period = format_numeric($graph_extension,2)." $suffix";
}
$Graph->setFont($Font);
$title_period = html_entity_decode($title_period);
if ($periodo == 86400)
$title_period = $lang_label["last_day"];
elseif ($periodo == 604800)
$title_period = $lang_label["last_week"];
elseif ($periodo == 3600)
$title_period = $lang_label["last_hour"];
elseif ($periodo == 2419200)
$title_period = $lang_label["last_month"];
else {
$suffix = $lang_label["days"];
$graph_extension = $periodo / (3600*24); // in days
grafico_modulo_log4x_trace(__LINE__);
if ($graph_extension < 1) {
$graph_extension = $periodo / (3600); // in hours
$suffix = $lang_label["hours"];
}
//$title_period = "Last ";
$title_period = format_numeric($graph_extension,2)." $suffix";
}
if ($pure == 0){
$Graph->add(
Image_Graph::horizontal(
Image_Graph::vertical(
Image_Graph::vertical(
$Title = Image_Graph::factory('title', array(' Pandora FMS Graph - '.strtoupper($nombre_agente)." - " .$title_period, 10)),
$Subtitle = Image_Graph::factory('title', array(' '.$title, 7)),
90
),
$Plotarea = Image_Graph::factory('plotarea', array('Image_Graph_Axis', 'Image_Graph_Axis')),
15 // If you change this, change the 0.85 below
),
Image_Graph::vertical(
$Legend = Image_Graph::factory('legend'),
$PlotareaMinMax = Image_Graph::factory('plotarea'),
65
),
85 // If you change this, change the 0.85 below
)
);
$title_period = html_entity_decode($title_period);
$Legend->setPlotarea($Plotarea);
$Title->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
$Subtitle->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
} else { // Pure, without title and legends
$Graph->add($Plotarea = Image_Graph::factory('plotarea', array('Image_Graph_Axis', 'Image_Graph_Axis')));
}
grafico_modulo_log4x_trace(__LINE__);
grafico_modulo_log4x_trace(__LINE__);
if ($pure == 0){
$Graph->add(
Image_Graph::horizontal(
Image_Graph::vertical(
Image_Graph::vertical(
$Title = Image_Graph::factory('title', array(' Pandora FMS Graph - '.strtoupper($nombre_agente)." - " .$title_period, 10)),
$Subtitle = Image_Graph::factory('title', array(' '.$title, 7)),
90
),
$Plotarea = Image_Graph::factory('plotarea', array('Image_Graph_Axis', 'Image_Graph_Axis')),
15 // If you change this, change the 0.85 below
),
Image_Graph::vertical(
$Legend = Image_Graph::factory('legend'),
$PlotareaMinMax = Image_Graph::factory('plotarea'),
65
),
85 // If you change this, change the 0.85 below
)
);
$dataset = array();
$Legend->setPlotarea($Plotarea);
$Title->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
$Subtitle->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
} else { // Pure, without title and legends
$Graph->add($Plotarea = Image_Graph::factory('plotarea', array('Image_Graph_Axis', 'Image_Graph_Axis')));
}
$severities = array("FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE");
$colors = array("black", "red", "orange", "yellow", "#3300ff", 'magenta');
grafico_modulo_log4x_trace(__LINE__);
$max_bubble_radius = $height * 0.6 / (count($severities) + 1); // this is the size for the max_count
$y = count($severities) - 1;
$i = 0;
$dataset = array();
foreach($severities as $severity) {
$dataset[$i] = Image_Graph::factory('dataset');
$dataset[$i]->setName($severity);
$severities = array("FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE");
$colors = array("black", "red", "orange", "yellow", "#3300ff", 'magenta');
if (isset($valores[$severity])){
$data =& $valores[$severity];
while (list($index, $data2) = each($data)) {
$count = $data2['count'];
$pivot = $data2['pivot'];
$max_bubble_radius = $height * 0.6 / (count($severities) + 1); // this is the size for the max_count
$y = count($severities) - 1;
$i = 0;
//$x = $scale * $index;
$x = 100.0 * ($pivot - $fechatope) / ($now - $fechatope);
if ($x > 100) $x = 100;
foreach($severities as $severity) {
$dataset[$i] = Image_Graph::factory('dataset');
$dataset[$i]->setName($severity);
$size = grafico_modulo_log4x_bubble_size($count, $max_count, $max_bubble_radius);
if (isset($valores[$severity])){
$data =& $valores[$severity];
while (list($index, $data2) = each($data)) {
$count = $data2['count'];
$pivot = $data2['pivot'];
// pivot is the value in the X axis
// y is the number of steps (from the bottom of the graphics) (zero based)
// x is the position of the bubble, in % from the left (0% = full left, 100% = full right)
// size is the radius of the bubble
// value is the value associated with the bubble (needed to calculate the leyend)
//
$dataset[$i]->addPoint($pivot, $y, array("x" => $x, "size" => $size, "value" => $count));
}
} else {
// There's a problem when we have no data ...
// This was the first try.. didnt work
//$dataset[$i]->addPoint($now, -1, array("x" => 0, "size" => 0));
}
//$x = $scale * $index;
$x = 100.0 * ($pivot - $fechatope) / ($now - $fechatope);
if ($x > 100) $x = 100;
$y--;
$i++;
}
$size = grafico_modulo_log4x_bubble_size($count, $max_count, $max_bubble_radius);
grafico_modulo_log4x_trace(__LINE__);
// pivot is the value in the X axis
// y is the number of steps (from the bottom of the graphics) (zero based)
// x is the position of the bubble, in % from the left (0% = full left, 100% = full right)
// size is the radius of the bubble
// value is the value associated with the bubble (needed to calculate the leyend)
//
$dataset[$i]->addPoint($pivot, $y, array("x" => $x, "size" => $size, "value" => $count));
}
} else {
// There's a problem when we have no data ...
// This was the first try.. didnt work
//$dataset[$i]->addPoint($now, -1, array("x" => 0, "size" => 0));
}
// create the 1st plot as smoothed area chart using the 1st dataset
$Plot =& $Plotarea->addNew('bubble', array(&$dataset));
$Plot->setFont($Font);
$y--;
$i++;
}
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
$AxisX->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'grafico_modulo_log4x_format_x_axis'));
$AxisX->forceMinimum($fechatope);
$AxisX->forceMaximum($now);
grafico_modulo_log4x_trace(__LINE__);
$minIntervalWidth = $Plot->getTextWidth("88/88/8888");
$interval_x = $adjust_time;
// create the 1st plot as smoothed area chart using the 1st dataset
$Plot =& $Plotarea->addNew('bubble', array(&$dataset));
$Plot->setFont($Font);
while (true) {
$intervalWidth = $width * 0.85 * $interval_x/ $periodo;
if ($intervalWidth >= $minIntervalWidth)
break;
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
$AxisX->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'grafico_modulo_log4x_format_x_axis'));
$AxisX->forceMinimum($fechatope);
$AxisX->forceMaximum($now);
$interval_x *= 2;
}
$minIntervalWidth = $Plot->getTextWidth("88/88/8888");
$interval_x = $adjust_time;
$AxisX->setLabelInterval($interval_x);
$AxisX->setLabelOption("showtext",true);
while (true) {
$intervalWidth = $width * 0.85 * $interval_x/ $periodo;
if ($intervalWidth >= $minIntervalWidth)
break;
//*
$GridY2 =& $Plotarea->addNew('line_grid');
$GridY2->setLineColor('gray');
$GridY2->setFillColor('lightgray@0.05');
$GridY2->_setPrimaryAxis($AxisX);
//$GridY2->setLineStyle(Image_Graph::factory('Image_Graph_Line_Dotted', array("white", "gray", "gray", "gray")));
$GridY2->setLineStyle(Image_Graph::factory('Image_Graph_Line_Formatted', array(array("transparent", "transparent", "transparent", "gray"))));
//*/
//grafico_modulo_log4x_trace(print_r($AxisX, true));
$interval_x *= 2;
}
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'grafico_modulo_log4x_format_y_axis'));
$AxisY->setLabelOption("showtext",true);
//$AxisY->setLabelInterval(0);
//$AxisY->showLabel(IMAGE_GRAPH_LABEL_ZERO);
$AxisX->setLabelInterval($interval_x);
$AxisX->setLabelOption("showtext",true);
//*
$GridY2 =& $Plotarea->addNew('line_grid');
$GridY2->setLineColor('gray');
$GridY2->setFillColor('lightgray@0.05');
$GridY2->_setPrimaryAxis($AxisY);
$GridY2->setLineStyle(Image_Graph::factory('Image_Graph_Line_Formatted', array(array("transparent", "transparent", "transparent", "gray"))));
//*/
//*
$GridY2 =& $Plotarea->addNew('line_grid');
$GridY2->setLineColor('gray');
$GridY2->setFillColor('lightgray@0.05');
$GridY2->_setPrimaryAxis($AxisX);
//$GridY2->setLineStyle(Image_Graph::factory('Image_Graph_Line_Dotted', array("white", "gray", "gray", "gray")));
$GridY2->setLineStyle(Image_Graph::factory('Image_Graph_Line_Formatted', array(array("transparent", "transparent", "transparent", "gray"))));
//*/
//grafico_modulo_log4x_trace(print_r($AxisX, true));
$AxisY->forceMinimum(0);
$AxisY->forceMaximum(count($severities) + 1) ;
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'grafico_modulo_log4x_format_y_axis'));
$AxisY->setLabelOption("showtext",true);
//$AxisY->setLabelInterval(0);
//$AxisY->showLabel(IMAGE_GRAPH_LABEL_ZERO);
// set line colors
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
//*
$GridY2 =& $Plotarea->addNew('line_grid');
$GridY2->setLineColor('gray');
$GridY2->setFillColor('lightgray@0.05');
$GridY2->_setPrimaryAxis($AxisY);
$GridY2->setLineStyle(Image_Graph::factory('Image_Graph_Line_Formatted', array(array("transparent", "transparent", "transparent", "gray"))));
//*/
$Plot->setFillStyle($FillArray);
foreach($colors as $color)
$FillArray->addColor($color);
$AxisY->forceMinimum(0);
$AxisY->forceMaximum(count($severities) + 1) ;
grafico_modulo_log4x_trace(__LINE__);
// set line colors
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
$FillArray->addColor('green@0.6');
//$AxisY_Weather =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$Plot->setFillStyle($FillArray);
foreach($colors as $color)
$FillArray->addColor($color);
// Show events !
if ($show_event == 1){
$Plot =& $Plotarea->addNew('Plot_Impulse', array($dataset_event));
$Plot->setLineColor( 'red' );
$Marker_event =& Image_Graph::factory('Image_Graph_Marker_Cross');
$Plot->setMarker($Marker_event);
$Marker_event->setFillColor( 'red' );
$Marker_event->setLineColor( 'red' );
$Marker_event->setSize ( 5 );
}
grafico_modulo_log4x_trace(__LINE__);
$Axis =& $PlotareaMinMax->getAxis(IMAGE_GRAPH_AXIS_X);
$Axis->Hide();
$Axis =& $PlotareaMinMax->getAxis(IMAGE_GRAPH_AXIS_Y);
$Axis->Hide();
$FillArray->addColor('green@0.6');
//$AxisY_Weather =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$plotMinMax =& $PlotareaMinMax->addNew('bubble', array(&$dataset, true));
// Show events !
if ($show_event == 1){
$Plot =& $Plotarea->addNew('Plot_Impulse', array($dataset_event));
$Plot->setLineColor( 'red' );
$Marker_event =& Image_Graph::factory('Image_Graph_Marker_Cross');
$Plot->setMarker($Marker_event);
$Marker_event->setFillColor( 'red' );
$Marker_event->setLineColor( 'red' );
$Marker_event->setSize ( 5 );
}
grafico_modulo_log4x_trace(__LINE__);
$Axis =& $PlotareaMinMax->getAxis(IMAGE_GRAPH_AXIS_X);
$Axis->Hide();
$Axis =& $PlotareaMinMax->getAxis(IMAGE_GRAPH_AXIS_Y);
$Axis->Hide();
$Graph->done();
$plotMinMax =& $PlotareaMinMax->addNew('bubble', array(&$dataset, true));
grafico_modulo_log4x_trace(__LINE__);
$Graph->done();
grafico_modulo_log4x_trace(__LINE__);
grafico_modulo_log4x_trace(__LINE__);
}
function grafico_modulo_log4x_index($x, $interval)

View File

@ -191,7 +191,7 @@ function threshold_graph($flash_chart, $chart_data, $width, $height, $ttl = 1) {
}
function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
$long_index, $no_data_image, $xaxisname = "", $yaxisname = "", $homedir="",
$long_index, $no_data_image, $xaxisname = "", $yaxisname = "", $homeurl="",
$water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1) {
if (empty($chart_data)) {
@ -199,7 +199,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
}
if($flash_chart) {
return fs_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homedir, $unit);
return fs_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit);
}
else {
$graph = array();
@ -216,7 +216,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='".$homedir."include/graphs/functions_pchart.php?graph_type=area&ttl=".$ttl."&id_graph=" . $id_graph . "'>";
return "<img src='".$homeurl."include/graphs/functions_pchart.php?graph_type=area&ttl=".$ttl."&id_graph=" . $id_graph . "'>";
}
}
@ -249,7 +249,7 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color,
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "/include/graphs/functions_pchart.php?graph_type=stacked_area&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?graph_type=stacked_area&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
}
}
@ -282,7 +282,7 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color,
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "/include/graphs/functions_pchart.php?graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
}
}
@ -312,7 +312,7 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "/include/graphs/functions_pchart.php?graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
}
}

View File

@ -126,7 +126,7 @@ $colors['pep4'] = array('border' => '#000000', 'color' => '#0000ff', 'alpha' =>
$step = 1;
if ($force_steps) {
$pixels_between_xdata = 40;
$pixels_between_xdata = 50;
$max_xdata_display = round($width / $pixels_between_xdata);
$ndata = count($data);
if($max_xdata_display > $ndata) {
@ -139,7 +139,7 @@ if ($force_steps) {
$step = round($ndata/$xdata_display);
}
$c = 0;
$c = 1;
switch($graph_type) {
case 'hbar':
@ -336,8 +336,6 @@ function pch_slicebar_graph ($graph_type, $data, $period, $width, $height, $colo
$myPicture->drawRoundedFilledRectangle ($i, 0, $ratio+$i,
$height, $radius, array('R' => $color['R'], 'G' => $color['G'], 'B' => $color['B']));
$i+=$ratio;
}
if ($round_corner) {
@ -408,16 +406,8 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width,
/* Write down the legend next to the 2nd chart*/
//Calculate the bottom margin from the size of string in each index
$max_chars = 0;
foreach ($legend_values as $string_legend) {
if (empty($string_legend)) continue;
$len = strlen($string_legend);
if ($len > $max_chars) {
$max_chars = $len;
}
}
$legend_with_aprox = 32 + (7 * $max_chars);
$max_chars = graph_get_max_index($legend_values);
$legend_with_aprox = 32 + (7 * $max_chars);
$PieChart->drawPieLegend($width - $legend_with_aprox, 5, array("R"=>255,"G"=>255,"B"=>255, "BoxSize"=>10));
@ -540,15 +530,7 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
// TODO: AvoidTickWhenEmpty = TRUE When the distance between two ticks will be greater than 50 px
//Calculate the top margin from the size of string in each index
$max_chars = 0;
foreach ($index as $string_index) {
if (empty($string_index)) continue;
$len = strlen($string_index);
if ($len > $max_chars) {
$max_chars = $len;
}
}
$max_chars = graph_get_max_index($index);
$margin_top = 10 * $max_chars;
switch($graph_type) {
@ -640,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,
@ -670,7 +652,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
$MyData->setPalette($point_id, $palette_color);*/
}
$MyData->setSerieWeight($point_id, 1);
$MyData->setSerieWeight($point_id, 0);
}
//$MyData->addPoints($data,"Yaxis");
@ -705,15 +687,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
}
//Calculate the bottom margin from the size of string in each index
$max_chars = 0;
foreach ($index as $string_index) {
if (empty($string_index)) continue;
$len = strlen($string_index);
if ($len > $max_chars) {
$max_chars = $len;
}
}
$max_chars = graph_get_max_index($index);
$margin_bottom = $font_size * $max_chars;
$water_mark_height = 0;

View File

@ -113,4 +113,22 @@ function stack_data(&$chart_data, &$legend = null, &$color = null) {
ksort($color);
}
}
function graph_get_max_index($legend_values) {
$max_chars = 0;
foreach ($legend_values as $string_legend) {
if (empty($string_legend)) continue;
$string_legend = explode("\n",$string_legend);
foreach($string_legend as $st_lg) {
$len = strlen($st_lg);
if ($len > $max_chars) {
$max_chars = $len;
}
}
}
return $max_chars;
}
?>

View File

@ -204,7 +204,7 @@ else {
$typeCell = ui_print_moduletype_icon($module["id_tipo_modulo"], true);
$intervalCell = ($module['module_interval'] == 0) ? $module['agent_interval'] : $module['intervalo'];
$intervalCell = modules_get_interval ($module['id_agente_modulo']);
if($module['utimestamp'] == 0 && (($module['module_type'] < 21 || $module['module_type'] > 23) && $module['module_type'] != 100)){
$statusCell = ui_print_status_image(STATUS_MODULE_NO_DATA, __('NOT INIT'), true);