2008-01-09 Sancho Lerena <slerena@gmail.com>

* fgraph.php: Solved problem in combined area render (ugly graphs most of times).
        Now graphs are stacked by default (in the future could be choose between in 
        stacked mode or plain (old one), as suggested in feature request #1835681.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@691 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2008-01-09 16:48:50 +00:00
parent 349cbd7b92
commit 94d924c0e1
2 changed files with 53 additions and 46 deletions

View File

@ -1,3 +1,9 @@
2008-01-09 Sancho Lerena <slerena@gmail.com>
* fgraph.php: Solved problem in combined area render (ugly graphs most of times).
Now graphs are stacked by default (in the future could be choose between in
stacked mode or plain (old one), as suggested in feature request #1835681.
2008-01-08 Sancho Lerena <slerena@gmail.com>
* pandoradb_data.sql: Added keep_alive as module id 100 for the new keepalive

View File

@ -109,8 +109,7 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
$nombre_agente = dame_nombre_agente_agentemodulo($id_agente_modulo);
$id_agente = dame_agente_id($nombre_agente);
$nombre_modulo = dame_nombre_modulo_agentemodulo($id_agente_modulo);
$module_list_name[$y] = substr($nombre_agente,0,8)."/".substr($nombre_modulo,0,18);
$module_list_name[$y] = substr($nombre_agente,0,9)." / ".substr($nombre_modulo,0,20);
for ($x = 0; $x <= $resolution; $x++) {
$valores[$x][0] = 0; // SUM of all values for this interval
$valores[$x][1] = 0; // counter
@ -121,6 +120,7 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
$valores[$x][6] = 0; // Event
}
// Init other general variables
if ($show_event == 1){
// If we want to show events in graphs
$sql1="SELECT utimestamp FROM tevento WHERE id_agente = $id_agente AND utimestamp > $fechatope";
@ -147,22 +147,21 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
$alert_low = $row["dis_min"];
}
}
$previous=0;
// Get the first data outsite (to the left---more old) of the interval given
$sql1="SELECT datos,utimestamp FROM tagente_datos WHERE id_agente = $id_agente AND id_agente_modulo = $id_agente_modulo AND utimestamp < $fechatope ORDER BY utimestamp DESC LIMIT 1";
$result=mysql_query($sql1);
if ($row=mysql_fetch_array($result))
$previous=$row[0];
$sql1="SELECT datos, utimestamp FROM tagente_datos WHERE id_agente = $id_agente AND id_agente_modulo = $id_agente_modulo AND utimestamp < $fechatope ORDER BY utimestamp DESC LIMIT 1";
if ($result=mysql_query($sql1)){
$row=mysql_fetch_array($result);
$previous = $row[0];
}
$sql1="SELECT datos,utimestamp FROM tagente_datos WHERE id_agente = $id_agente AND id_agente_modulo = $id_agente_modulo AND utimestamp > $fechatope";
$sql1="SELECT datos,utimestamp FROM tagente_datos WHERE id_agente = $id_agente AND id_agente_modulo = $id_agente_modulo AND utimestamp >= $fechatope";
if ($result=mysql_query($sql1))
while ($row=mysql_fetch_array($result)){
$datos = $row[0];
$utimestamp = $row[1];
if ($datos >= 0) {
for ($i=0; $i <= $resolution; $i++) {
if ( ($utimestamp <= $valores[$i][3]) && ($utimestamp >= $valores[$i][2]) ){
if ( ($utimestamp <= $valores[$i][3]) && ($utimestamp > $valores[$i][2]) ){
$valores[$i][0]=$valores[$i][0]+$datos;
$valores[$i][1]++;
// Init min value
@ -180,14 +179,13 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
}
}
}
}
// Calculate Average value for $valores[][0]
for ($x =0; $x <= $resolution; $x++) {
if ($valores[$x][1] > 0){
$real_data[$y][$x] = $weight_list[$y] * ($valores[$x][0]/$valores[$x][1]);
$valores[$x][0] = $valores[$x][0]/$valores[$x][1];
$real_data[$y][$x] = $weight_list[$y]*($valores[$x][0]/$valores[$x][1]);
} else {
$valores[$x][0] = $previous;
$real_data[$y][$x] = $previous * $weight_list[$y];
@ -284,7 +282,7 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
for ($cc=0; $cc < $resolution; $cc++) {
$tdate = date('d/m', $valores[$cc][2])."\n".date('H:i', $valores[$cc][2]);
for ($y = 0; $y < $module_number; $y++){
$dataset[$y]->addPoint($tdate, $real_data[$y][$cc] * $weight_list[$y]);
$dataset[$y]->addPoint($tdate, $real_data[$y][$cc]);
if (($show_event == 1) AND (isset($real_event[$cc]))) {
$dataset_event->addPoint($tdate, $max_value);
}
@ -313,7 +311,10 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
// create the 1st plot as smoothed area chart using the 1st dataset
$Plot =& $Plotarea->addNew('area', array(&$dataset));
// Non-stacked
// $Plot =& $Plotarea->addNew('area', array(&$dataset));
// Stacked (v1.4)
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Area', array(&$dataset, 'stacked'));
$Plot->setLineColor('gray@0.4');
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
// $AxisX->Hide();