2011-03-31 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_graph.php, operation/agentes/stat_win.php: changes for
	to show with new engine.
	 
	* include/graphs/functions_pchart.php,
	include/graphs/pChart/pData.class.php,
	include/graphs/pChart/pDraw.class.php,
	include/graphs/functions_fsgraph.php,
	include/graphs/fgraph.php: part of job is Sergio Martin in my laptop, the
	changes to show borders in the static image graph.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4158 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2011-03-31 17:07:00 +00:00
parent 8ac591eddb
commit c56f7439fa
8 changed files with 320 additions and 77 deletions

View File

@ -1,3 +1,15 @@
2011-03-31 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_graph.php, operation/agentes/stat_win.php: changes for
to show with new engine.
* include/graphs/functions_pchart.php,
include/graphs/pChart/pData.class.php,
include/graphs/pChart/pDraw.class.php,
include/graphs/functions_fsgraph.php,
include/graphs/fgraph.php: part of job is Sergio Martin in my laptop, the
changes to show borders in the static image graph.
2011-03-31 Juan Manuel Ramon <juanmanuel.ramon@artica.es> 2011-03-31 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/config_process.php: Fixed wrong condition when global * include/config_process.php: Fixed wrong condition when global

View File

@ -168,6 +168,33 @@ function grafico_modulo_sparse2 ($agent_module_id, $period, $show_events,
$k++; $k++;
} }
// 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';
}
elseif ($period <= 604800) {
$title_period = __('Last week');
$time_format = 'M j';
}
elseif ($period <= 2419200) {
$title_period = __('Last month');
$time_format = 'M j';
}
else {
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
$time_format = 'M j';
}
$timestamp_short = date($time_format, $timestamp);
$long_index[$timestamp_short] = date(
html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp);
$timestamp = $timestamp_short;
// Data // Data
if ($count > 0) { if ($count > 0) {
$chart[$timestamp]['sum'] = $total; $chart[$timestamp]['sum'] = $total;
@ -187,13 +214,17 @@ function grafico_modulo_sparse2 ($agent_module_id, $period, $show_events,
} }
} }
$chart[$timestamp]['count'] = 0; //$chart[$timestamp]['count'] = 0;
///////// /////////
//$chart[$timestamp]['timestamp_bottom'] = $timestamp; //$chart[$timestamp]['timestamp_bottom'] = $timestamp;
//$chart[$timestamp]['timestamp_top'] = $timestamp + $interval; //$chart[$timestamp]['timestamp_top'] = $timestamp + $interval;
///////// /////////
$chart[$timestamp]['event'] = $event_value; if($show_events) {
$chart[$timestamp]['alert'] = $alert_value; $chart[$timestamp]['event'] = $event_value;
}
if($show_alerts) {
$chart[$timestamp]['alert'] = $alert_value;
}
$chart[$timestamp]['baseline'] = array_shift ($baseline_data); $chart[$timestamp]['baseline'] = array_shift ($baseline_data);
if ($chart[$timestamp]['baseline'] == NULL) { if ($chart[$timestamp]['baseline'] == NULL) {
$chart[$timestamp]['baseline'] = 0; $chart[$timestamp]['baseline'] = 0;
@ -213,36 +244,14 @@ function grafico_modulo_sparse2 ($agent_module_id, $period, $show_events,
// Fix event and alert scale // Fix event and alert scale
$event_max = $max_value * 1.25; $event_max = $max_value * 1.25;
foreach ($chart as $timestamp => $chart_data) { foreach ($chart as $timestamp => $chart_data) {
if ($chart_data['event'] > 0) { if ($show_events && $chart_data['event'] > 0) {
$chart[$timestamp]['event'] = $event_max; $chart[$timestamp]['event'] = $event_max;
} }
if ($chart_data['alert'] > 0) { if ($show_alerts && $chart_data['alert'] > 0) {
$chart[$timestamp]['alert'] = $event_max; $chart[$timestamp]['alert'] = $event_max;
} }
} }
// 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';
}
elseif ($period <= 604800) {
$title_period = __('Last week');
$time_format = 'M j';
}
elseif ($period <= 2419200) {
$title_period = __('Last month');
$time_format = 'M j';
}
else {
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
$time_format = 'M j';
}
// 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
@ -252,21 +261,30 @@ function grafico_modulo_sparse2 ($agent_module_id, $period, $show_events,
/////// ///////
$color = array(); $color = array();
$color['sum'] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 100); $color['sum'] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50);
$color['event'] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50); if($show_events) {
$color['alert'] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50); $color['event'] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
$color['max'] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 100); }
$color['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 100); if($show_alerts) {
$color['alert'] = array('border' => '#ff0000', 'color' => '#ff0000', '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['baseline'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10); $color['baseline'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10);
$legend = array(); $legend = array();
$legend['sum'] = __('Avg') . ' (' . $avg_value . ')'; $legend['sum'] = __('Avg') . ' (' . $avg_value . ')';
$legend['event'] = __('Events'); if($show_events) {
$legend['alert'] = __('Alerts'); $legend['event'] = __('Events');
}
if($show_alerts) {
$legend['alert'] = __('Alerts');
}
$legend['max'] = __('Max') . ' (' . $max_value . ')'; $legend['max'] = __('Max') . ' (' . $max_value . ')';
$legend['min'] = __('Min') . ' (' . $min_value . ')'; $legend['min'] = __('Min') . ' (' . $min_value . ')';
$legend['baseline'] = __('Baseline'); $legend['baseline'] = __('Baseline');
//$legend = null;
area_graph(0, $chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts, $caption, $baseline, $color, $legend); area_graph(0, $chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts, $caption, $baseline, $color, $legend, $long_index);
} }
?> ?>

View File

@ -33,9 +33,12 @@ function threshold_graph($flash_chart, $chart_data, $width, $height) {
} }
} }
function area_graph($flash_chart, $chart_data, $width, $height, $avg_only, $resolution, $time_format, $show_events, $show_alerts, $caption, $baseline, $color) { function area_graph($flash_chart, $chart_data, $width, $height, $avg_only, $resolution, $time_format, $show_events, $show_alerts, $caption, $baseline, $color,$legend, $long_index) {
$flash_chart = 1;
if($flash_chart) { if($flash_chart) {
echo fs_module_chart ($chart_data, $width, $height, $avg_only, $resolution, $time_format, $show_events, $show_alerts, $caption, $baseline); echo fs_area_graph($chart_data, $width, $height, $color, $legend, $long_index);
//echo fs_module_chart ($chart_data, $width, $height, $avg_only, $resolution, $time_format, $show_events, $show_alerts, $legend, $baseline, $color);
} }
else { else {
$id_graph = uniqid(); $id_graph = uniqid();
@ -45,6 +48,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $avg_only, $reso
$graph['width'] = $width; $graph['width'] = $width;
$graph['height'] = $height; $graph['height'] = $height;
$graph['color'] = $color; $graph['color'] = $color;
$graph['legend'] = $legend;
// $graph['avg_only'] = $avg_only; // $graph['avg_only'] = $avg_only;
// $graph['resolution'] = $resolution; // $graph['resolution'] = $resolution;
// $graph['time_format'] = $time_format; // $graph['time_format'] = $time_format;
@ -54,7 +58,9 @@ function area_graph($flash_chart, $chart_data, $width, $height, $avg_only, $reso
// $graph['baseline'] = $baseline; // $graph['baseline'] = $baseline;
session_start(); session_start();
$_SESSION['graph'][$id_graph] = $graph; //unset($_SESSION['graph']);
$_SESSION['graph_session'][$id_graph] = $graph;
//debugPrint($_SESSION);
session_write_close(); session_write_close();
//echo "<img src='include/graphs/functions_pchart.php?graph_type=area&data=".json_encode($chart_data)."&width=".$width."&height=".$height."'>"; //echo "<img src='include/graphs/functions_pchart.php?graph_type=area&data=".json_encode($chart_data)."&width=".$width."&height=".$height."'>";

View File

@ -26,6 +26,134 @@ require_once ("FusionCharts/FusionCharts_Gen.php");
/////////////////////////////// ///////////////////////////////
/////////////////////////////// ///////////////////////////////
function fs_area_graph($chart_data, $width, $height, $color, $legend, $long_index) {
global $config;
$graph_type = "MSArea2D"; //MSLine is possible also
$chart = new FusionCharts($graph_type, $width, $height);
$pixels_between_xdata = 25;
$max_xdata_display = round($width / $pixels_between_xdata);
$ndata = count($chart_data);
if($max_xdata_display > $ndata) {
$xdata_display = $ndata;
}
else {
$xdata_display = $max_xdata_display;
}
$step = round($ndata/$xdata_display);
if(is_array(reset($chart_data))) {
$data2 = array();
$count = 0;
foreach($chart_data as $i =>$values) {
// $count = 0;
// $step = 10;
// $num_vlines = 0;
//
// if ($count++ % $step == 0) {
// $show_name = '1';
// $num_vlines++;
// }
// else {
// $show_name = '0';
// }
$count++;
$show_name = '0';
if (($count % $step) == 0) {
$show_name = '1';
}
$chart->addCategory($i, //'');
'hoverText=' . $long_index[$i] .
';showName=' . $show_name);
$c = 0;
foreach($values as $i2 => $value) {
$data2[$i2][$i] = $value;
$c++;
}
}
$data = $data2;
}
else {
$data = array($chart_data);
}
$a = 0;
$empty = 1;
foreach ($data as $i => $value) {
$showAreaBorder = 0;
if (!is_null($color[$i]['border'])) {
$showAreaBorder = 1;
}
$chart->addDataSet($legend[$i], 'alpha=' . $color[$i]['alpha'] . ';' .
'showAreaBorder=' . $showAreaBorder . ';' .
'areaBorderColor=' . $color[$i]['border'] . ';' .
'color=#' . $color[$i]['color']);
$count = 0;
$step = 10;
$num_vlines = 0;
foreach ($value as $i2 => $v) {
if ($count++ % $step == 0) {
$show_name = '1';
$num_vlines++;
}
else {
$show_name = '0';
}
$empty = 0;
if ($a < 3) {
$a++;
// $chart->addCategory(date('G:i', $i2), //'');
// 'hoverText=' . date (html_entity_decode ($config['date_format'], ENT_QUOTES, "UTF-8"), $i2) .
// ';showName=' . $show_name);
}
//Add data
$chart->addChartData($v);
}
}
$chart->setChartParams('animation=0;numVDivLines=' . $num_vlines .
';showShadow=0;showAlternateVGridColor=1;showNames=1;rotateNames=1;' .
'lineThickness=0.1;anchorRadius=0.5;showValues=0;baseFontSize=9;showLimits=0;' .
'showAreaBorder=1;areaBorderThickness=0.1;areaBorderColor=000000' . ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
$random_number = uniqid();
$div_id = 'chart_div_' . $random_number;
$chart_id = 'chart_' . $random_number;
$pre_url = ($config["homeurl"] == "/") ? '' : $config["homeurl"];
$output = '<div id="' . $div_id. '" style="z-index:1;"></div>';
$output .= '<script language="JavaScript" src="' . $pre_url . '/include/FusionCharts/FusionCharts.js"></script>';
$output .= '<script type="text/javascript">
<!--
function pie_' . $chart_id . ' () {
var myChart = new FusionCharts("' . $pre_url . '/include/FusionCharts/FCF_'.$graph_type.'.swf", "' . $chart_id . '", "' . $width. '", "' . $height. '", "0", "1");
myChart.setDataXML("' . addslashes($chart->getXML ()) . '");
myChart.addParam("WMode", "Transparent");
myChart.render("' . $div_id . '");
}
pie_' . $chart_id . ' ();
-->
</script>';
return $output;
}
function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $time_format = 'G:i', $show_events = 0, $show_alerts = 0, $caption = '', $baseline = 0, $color) { function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $time_format = 'G:i', $show_events = 0, $show_alerts = 0, $caption = '', $baseline = 0, $color) {
global $config; global $config;
@ -66,6 +194,7 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti
} else { } else {
$show_name = '0'; $show_name = '0';
} }
//$chart->addCategory(date($time_format, $i), '');
$chart->addCategory(date($time_format, $i), $chart->addCategory(date($time_format, $i),
'hoverText=' . date (html_entity_decode ($config['date_format'], ENT_QUOTES, "UTF-8"), $i) . ';showName=' . $show_name); 'hoverText=' . date (html_entity_decode ($config['date_format'], ENT_QUOTES, "UTF-8"), $i) . ';showName=' . $show_name);
} }
@ -142,10 +271,13 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti
if (!is_null($color['baseline']['border'])) { if (!is_null($color['baseline']['border'])) {
$showAreaBorder = 1; $showAreaBorder = 1;
} }
//debugPrint($color);
$chart->addDataSet($caption['baseline'], 'color=' . $color['baseline']['color'] . ';' . $chart->addDataSet($caption['baseline'], 'color=' . $color['baseline']['color'] . ';' .
'alpha=' . $color['baseline']['alpha'] . ';' . 'alpha=' . $color['baseline']['alpha'] . ';' .
'showAreaBorder=' . $showAreaBorder . ';'); 'showAreaBorder=' . $showAreaBorder . ';');
debugPrint('color=' . $color['baseline']['color'] . ';' .
'alpha=' . $color['baseline']['alpha'] . ';' .
'showAreaBorder=' . $showAreaBorder . ';');
foreach ($data as $value) { foreach ($data as $value) {
$chart->addChartData($value['baseline']); $chart->addChartData($value['baseline']);
} }

View File

@ -37,9 +37,8 @@ $id_graph = get_parameter('id_graph', false);
if ($id_graph) { if ($id_graph) {
session_start(); session_start();
$graph = $_SESSION['graph'][$id_graph]; $graph = $_SESSION['graph_session'][$id_graph];
unset($_SESSION['graph_session'][$id_graph]);
unset($_SESSION['graph'][$id_graph]);
session_write_close(); session_write_close();
if (isset($graph)) { if (isset($graph)) {
@ -50,10 +49,10 @@ if ($id_graph) {
$legend = $graph['legend']; $legend = $graph['legend'];
/* /*
$colors = array(); $colors = array();
$colors['pep1'] = array('border' => '#000000', 'color' => '#000000', 'alpha' => 100); $colors['pep1'] = array('border' => '#000000', 'color' => '#000000', 'alpha' => 50);
$colors['pep2'] = array('border' => '#ff7f00', 'color' => '#ff0000', 'alpha' => 50); $colors['pep2'] = array('border' => '#ff7f00', 'color' => '#ff0000', 'alpha' => 50);
$colors['pep3'] = array('border' => '#ff0000', 'color' => '#00ff00', 'alpha' => 20); $colors['pep3'] = array('border' => '#ff0000', 'color' => '#00ff00', 'alpha' => 50);
$colors['pep4'] = array('border' => '#000000', 'color' => '#0000ff', 'alpha' => 100); $colors['pep4'] = array('border' => '#000000', 'color' => '#0000ff', 'alpha' => 50);
*/ */
$rgb_color = array(); $rgb_color = array();
foreach($colors as $i => $color) { foreach($colors as $i => $color) {
@ -82,7 +81,7 @@ if ($id_graph) {
if($graph_type != 'pie3d' && $graph_type != 'pie2d') { if($graph_type != 'pie3d' && $graph_type != 'pie2d') {
$pixels_between_xdata = 10; $pixels_between_xdata = 25;
$max_xdata_display = round($width / $pixels_between_xdata); $max_xdata_display = round($width / $pixels_between_xdata);
$ndata = count($data); $ndata = count($data);
if($max_xdata_display > $ndata) { if($max_xdata_display > $ndata) {
@ -94,20 +93,21 @@ if($graph_type != 'pie3d' && $graph_type != 'pie2d') {
$step = round($ndata/$xdata_display); $step = round($ndata/$xdata_display);
$c = 0; $c = 0;
foreach($data as $i => $d) { foreach($data as $i => $d) {
$data_values[] = $d; $data_values[] = $d;
if($c == 0) {
if (($c % $step) == 0) {
$data_keys[] = $i; $data_keys[] = $i;
} }
else { else {
if($c == $step) {
$c = -1;
}
$data_keys[] = ""; $data_keys[] = "";
} }
$c++; $c++;
} }
//debugPrint($data_values);
} }
switch($graph_type) { switch($graph_type) {
@ -299,14 +299,16 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, $rgb_c
if(!is_array($legend) || empty($legend)) { if(!is_array($legend) || empty($legend)) {
unset($legend); unset($legend);
} }
//$legend=array('pep1','pep2','pep3','pep4'); /*$legend=array('pep1' => 'pep1','pep2' => 'pep2','pep3' => 'pep3','pep4' => 'pep4');
//$data=array(array(1,1,3,3), array(1,3,1,4), array(3,1,1,1), array(1,1,1,0)); $data=array(array('pep1' => 1, 'pep2' => 1, 'pep3' => 3, 'pep4' => 3), array('pep1' => 1, 'pep2' => 3, 'pep3' => 1,'pep4' => 4), array('pep1' => 3, 'pep2' => 1, 'pep3' => 1,'pep4' =>1), array('pep1' => 1, 'pep2' =>1, 'pep3' =>1,'pep4' =>0));
if(is_array($data[0])) { $index=array(1,2,3,4);
*/
if(is_array(reset($data))) {
$data2 = array(); $data2 = array();
foreach($data as $i =>$values) { foreach($data as $i =>$values) {
$c = 0; $c = 0;
foreach($values as $value) { foreach($values as $i2 => $value) {
$data2[$c][$i] = $value; $data2[$i2][$i] = $value;
$c++; $c++;
} }
} }
@ -318,6 +320,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, $rgb_c
/* Create and populate the pData object */ /* Create and populate the pData object */
$MyData = new pData(); $MyData = new pData();
//debugPrint($data);
foreach($data as $i => $values) { foreach($data as $i => $values) {
if(isset($legend)) { if(isset($legend)) {
$point_id = $legend[$i]; $point_id = $legend[$i];
@ -325,8 +328,20 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, $rgb_c
else { else {
$point_id = $i; $point_id = $i;
} }
if ($i == 'alert') {
$values[100] = 100;
}
$MyData->addPoints($values,$point_id); $MyData->addPoints($values,$point_id);
$MyData->setPalette($point_id, array("R" => $rgb_color[$point_id]['color']["R"], "G" => $rgb_color[$point_id]['color']["G"], "B" => $rgb_color[$point_id]['color']["B"], "Alpha" => $rgb_color[$point_id]['alpha'])); $MyData->setPalette($point_id,
array("R" => $rgb_color[$i]['color']["R"],
"G" => $rgb_color[$i]['color']["G"],
"B" => $rgb_color[$i]['color']["B"],
"BorderR" => $rgb_color[$i]['border']["R"],
"BorderG" => $rgb_color[$i]['border']["G"],
"BorderB" => $rgb_color[$i]['border']["B"],
"Alpha" => $rgb_color[$i]['alpha']));
} }
//$MyData->addPoints($data,"Yaxis"); //$MyData->addPoints($data,"Yaxis");
@ -356,14 +371,22 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, $rgb_c
if(isset($legend)) { if(isset($legend)) {
/* Write the chart legend */ /* Write the chart legend */
$myPicture->drawLegend($height/2,$width/1.8,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL)); //$myPicture->drawLegend($height/2,$width/1.8,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
$myPicture->drawLegend($height/2,$height-20,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
} }
/* Turn on shadow computing */ /* Turn on shadow computing */
//$myPicture->setShadow(TRUE,array("X"=>0,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10)); //$myPicture->setShadow(TRUE,array("X"=>0,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
/* Draw the chart */ /* Draw the chart */
$settings = array("ForceTransparency"=>"-1", "Gradient"=>TRUE,"GradientMode"=>GRADIENT_EFFECT_CAN,"DisplayValues"=>$show_values,"DisplayZeroValues"=>FALSE,"DisplayR"=>100,"DisplayG"=>100,"DisplayB"=>100,"DisplayShadow"=>TRUE,"Surrounding"=>5,"AroundZero"=>FALSE); $settings = array("ForceTransparency"=>"-1",
"Gradient"=>TRUE,
"GradientMode"=>GRADIENT_EFFECT_CAN,
"DisplayValues"=>$show_values,
"DisplayZeroValues"=>FALSE,
"DisplayR"=>100,
"DisplayZeros"=> FALSE,
"DisplayG"=>100,"DisplayB"=>100,"DisplayShadow"=>TRUE,"Surrounding"=>5,"AroundZero"=>FALSE);
switch($graph_type) { switch($graph_type) {
case "area": case "area":

View File

@ -344,19 +344,35 @@
$G = isset($Format["G"]) ? $Format["G"] : 0; $G = isset($Format["G"]) ? $Format["G"] : 0;
$B = isset($Format["B"]) ? $Format["B"] : 0; $B = isset($Format["B"]) ? $Format["B"] : 0;
$Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100; $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
$BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : $R;
$BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : $G;
$BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : $B;
if ( isset($this->Data["Series"][$Serie]) ) if ( isset($this->Data["Series"][$Serie]) )
{ {
$OldR = $this->Data["Series"][$Serie]["Color"]["R"]; $OldG = $this->Data["Series"][$Serie]["Color"]["G"]; $OldB = $this->Data["Series"][$Serie]["Color"]["B"]; $OldR = $this->Data["Series"][$Serie]["Color"]["R"];
$OldG = $this->Data["Series"][$Serie]["Color"]["G"];
$OldB = $this->Data["Series"][$Serie]["Color"]["B"];
$this->Data["Series"][$Serie]["Color"]["R"] = $R; $this->Data["Series"][$Serie]["Color"]["R"] = $R;
$this->Data["Series"][$Serie]["Color"]["G"] = $G; $this->Data["Series"][$Serie]["Color"]["G"] = $G;
$this->Data["Series"][$Serie]["Color"]["B"] = $B; $this->Data["Series"][$Serie]["Color"]["B"] = $B;
$this->Data["Series"][$Serie]["Color"]["BorderR"] = $BorderR;
$this->Data["Series"][$Serie]["Color"]["BorderG"] = $BorderG;
$this->Data["Series"][$Serie]["Color"]["BorderB"] = $BorderB;
$this->Data["Series"][$Serie]["Color"]["Alpha"] = $Alpha; $this->Data["Series"][$Serie]["Color"]["Alpha"] = $Alpha;
/* Do reverse processing on the internal palette array */ /* Do reverse processing on the internal palette array */
foreach ($this->Palette as $Key => $Value) foreach ($this->Palette as $Key => $Value) {
{ if ($Value["R"] == $OldR && $Value["G"] == $OldG && $Value["B"] == $OldB) { $this->Palette[$Key]["R"] = $R; $this->Palette[$Key]["G"] = $G; $this->Palette[$Key]["B"] = $B; $this->Palette[$Key]["Alpha"] = $Alpha;} } if ($Value["R"] == $OldR && $Value["G"] == $OldG && $Value["B"] == $OldB) {
} $this->Palette[$Key]["R"] = $R;
$this->Palette[$Key]["G"] = $G;
$this->Palette[$Key]["B"] = $B;
$this->Palette[$Key]["BorderR"] = $BorderR;
$this->Palette[$Key]["BorderG"] = $BorderG;
$this->Palette[$Key]["BorderB"] = $BorderB;
$this->Palette[$Key]["Alpha"] = $Alpha;}
}
}
} }
/* Load a palette file */ /* Load a palette file */

View File

@ -3676,7 +3676,14 @@
{ {
if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] ) if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
{ {
$R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"]; $R = $Serie["Color"]["R"];
$G = $Serie["Color"]["G"];
$B = $Serie["Color"]["B"];
$BorderR = $Serie["Color"]["BorderR"];
$BorderG = $Serie["Color"]["BorderG"];
$BorderB = $Serie["Color"]["BorderB"];
$Alpha = $Serie["Color"]["Alpha"];
$Ticks = $Serie["Ticks"];
if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; } if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
$AxisID = $Serie["Axis"]; $AxisID = $Serie["Axis"];
@ -3705,10 +3712,14 @@
foreach($PosArray as $Key => $Y) foreach($PosArray as $Key => $Y)
{ {
// Hack to avoid draw zero values // Hack to avoid draw zero values
debugPrint($Serie["Data"][$Key]." - ".$lastKey, '/tmp/logo'); debugPrint((int)$DisplayZeros . " - " . $Serie["Data"][$Key]." - ".$lastKey, '/tmp/logo');
if(!$DisplayZeros && $Serie["Data"][$Key] == 0 && $lastKey == 0) { if(!$DisplayZeros && $Serie["Data"][$Key] == 0 && $lastKey == 0) {
debugPrint("HOLA", "/tmp/logo");
$Y = VOID; $Y = VOID;
} }
else {
//debugPrint("ADIOS", "/tmp/logo");
}
$lastKey = $Serie["Data"][$Key]; $lastKey = $Serie["Data"][$Key];
if ( $DisplayValues && $Serie["Data"][$Key] != VOID ) if ( $DisplayValues && $Serie["Data"][$Key] != VOID )
@ -3743,7 +3754,7 @@
if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaY2-1; } if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaY2-1; }
$Alpha = $ForceTransparency != -1 ? $ForceTransparency : $Alpha; $Alpha = $ForceTransparency != -1 ? $ForceTransparency : $Alpha;
$Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); $Color = array("BorderR" => $BorderR, "BorderG" => $BorderG, "BorderB" => $BorderB, "R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
foreach($Areas as $Key => $Points) foreach($Areas as $Key => $Points)
$this->drawPolygon($Points,$Color); $this->drawPolygon($Points,$Color);
} }
@ -3795,7 +3806,7 @@
$Areas[$AreaID][] = $LastY; $Areas[$AreaID][] = $LastY;
$Alpha = $ForceTransparency != -1 ? $ForceTransparency : $Alpha; $Alpha = $ForceTransparency != -1 ? $ForceTransparency : $Alpha;
$Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); $Color = array("BorderR" => $BorderR, "BorderG" => $BorderG, "BorderB" => $BorderB, "R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
foreach($Areas as $Key => $Points) foreach($Areas as $Key => $Points)
$this->drawPolygon($Points,$Color); $this->drawPolygon($Points,$Color);
} }

View File

@ -27,7 +27,8 @@ if (! isset($_SESSION["id_user"])) {
require_once ($config["homedir"] . '/include/functions.php'); require_once ($config["homedir"] . '/include/functions.php');
require_once ($config["homedir"] . '/include/functions_db.php'); require_once ($config["homedir"] . '/include/functions_db.php');
require_once ($config["homedir"] . '/include/functions_reporting.php'); require_once ($config["homedir"] . '/include/functions_reporting.php');
require_once ($config["homedir"] . '/include/fgraph.php'); require_once ($config["homedir"] . '/include/functions_graph.php');
//require_once ($config["homedir"] . '/include/fgraph.php');
check_login (); check_login ();
?> ?>
@ -137,9 +138,11 @@ else
// log4x doesnt support flash yet // log4x doesnt support flash yet
// //
if ($config['flash_charts'] && $graph_type != "log4x") { if ($config['flash_charts'] && $graph_type != "log4x") {
//if (true) {
switch ($graph_type) { switch ($graph_type) {
case 'sparse': case 'sparse':
echo grafico_modulo_sparse ($id, $period, $draw_events, $width, $height, echo grafico_modulo_sparse2 ($id, $period, $draw_events, $width, $height,
$label, $unit_name, $draw_alerts, $avg_only, $pure, $date, $baseline); $label, $unit_name, $draw_alerts, $avg_only, $pure, $date, $baseline);
break; break;
case 'boolean': case 'boolean':
@ -160,11 +163,33 @@ if ($config['flash_charts'] && $graph_type != "log4x") {
} }
} }
else { else {
$image = "../../include/fgraph.php?tipo=".$graph_type."&draw_alerts=".$draw_alerts."&draw_events=".$draw_events."&id=".$id."&zoom=".$zoom."&label=". base64_encode ($label) ."&height=".$height."&width=".$width."&period=".$period."&avg_only=".$avg_only."&baseline=".$baseline; switch ($graph_type) {
case 'sparse':
echo grafico_modulo_sparse2 ($id, $period, $draw_events, $width, $height,
$label, $unit_name, $draw_alerts, $avg_only, $pure, $date, $baseline);
break;
case 'boolean':
echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height,
$label, $unit_name, $draw_alerts, 1, $pure, $date);
break;
case 'string':
echo grafico_modulo_string ($id, $period, $draw_events, $width, $height,
$label, $unit_name, $draw_alerts, 1, $pure, $date, 1);
break;
case 'log4x':
echo grafico_modulo_log4x ($id, $period, $draw_events, $width, $height,
$label, $unit_name, $draw_alerts, 1, $pure, $date, 1);
break;
default:
echo fs_error_image ('../images');
break;
}
$image .= "&date=" . $date; //$image = "../../include/fgraph.php?tipo=".$graph_type."&draw_alerts=".$draw_alerts."&draw_events=".$draw_events."&id=".$id."&zoom=".$zoom."&label=". base64_encode ($label) ."&height=".$height."&width=".$width."&period=".$period."&avg_only=".$avg_only."&baseline=".$baseline;
//
print_image ($image, false, array ("border" => 0)); //$image .= "&date=" . $date;
//
//print_image ($image, false, array ("border" => 0));
} }
//z-index is 1 because 2 made the calendar show under the divmenu. //z-index is 1 because 2 made the calendar show under the divmenu.