<html>
<head>
<title>Graficas</title>
</head>
<body>
<?php
$servicio=$_GET['servicio'];
$fechainicio=$_GET['fechainicio'];
$fechafinal=$_GET['fechafinal'];
// Me conecto a la base de datos
if (!empty($_GET['button'])){ // en caso de que se ha presionado el boton enviar, procesar el formulario
$servicio=$_GET['servicio'];
$fechainicio=$_GET['fechainicio'];
$fechafinal=$_GET['fechafinal'];
/* Incluimos las clases */
include("/var/www/graficas/pChart/class/pData.class.php");
include("/var/www/graficas/pChart/class/pDraw.class.php");
include("/var/www/graficas/pChart/class/pImage.class.php");
/* Creamos el objeto */
$myData = new pData();
//conectamos
$sql2="select Fecha, Cantidad from $servicio where Fecha between '&fechainicio' and 'fechafinal'";
{
$Fecha = $row["Fecha"];
$myData->addPoints($Fecha,"Fecha");
$Cantidad = $row["Cantidad"];
$myData->addPoints($Cantidad,"Cantidad");
}
$myData-> setSerieOnAxis("Cantidad", 0); //assigns the data to the frist axis
$myData-> setAxisName(0, "Frecuencia (Hz)"); //adds the label to the first axis
$myData-> setAxisPosition(1,AXIS_POSITION_LEFT); //moves the second axis to the far left
$myData->setAbscissa("Fecha"); //sets the time data set as the x axis label
$myPicture = new pImage(1100,300,$myData); /* Create a pChart object and associate your dataset */
$myPicture->setFontProperties(array("FontName"=>"/var/www/graficas/pChart/fonts/pf_arma_five.ttf","FontSize"=>6)); /* Choose a nice font */ $myPicture->setGraphArea(80,40,1000,200); /* Define the boundaries of the graph area */
$Settings = array("R"=>250, "G"=>250, "B"=>250, "Dash"=>1, "DashR"=>0, "DashG"=>0, "DashB"=>0); $myPicture->drawScale(array("LabelRotation"=>320)); /* Draw the scale, keep everything automatic */ /*The combination makes a cool looking graph*/
$myPicture->drawPlotChart();
$myPicture->drawLineChart();
$myPicture->drawLegend(90,20); //adds the legend
$myPicture->autoOutput(); /* Build the PNG file and send it to the web browser */
}
else
{
?>
<form method="get" action="index.php">
<table width="70%" border="0" align="center">
<?php
print ("
<input type=\"hidden\" name=\"paisant\" value=\"$paisant\">
<input type=\"hidden\" name=\"cantonant\" value=\"$cantonant\">
<tr>
<td><div align=\"right\"><strong>Servicio:</strong></div></td>
<td><select name=\"servicio\" onchange=\"submit();\">
");
//Muestra el combobox de las provincias una vez que se haya elegido el país, no antes
print ("<option selected>Seleccione el servicio</option>");
$servicio="0";
}
$sql="SHOW FULL TABLES FROM base";
print("<option value=\"$fila[Tables_in_base]\"");
if ($fila[Tables_in_base] == $servicio) {
print ("selected");
}
print(">$fila[Tables_in_base]</option>\n");
}
print("</select></td></tr>");
print ("
<tr>
<td><div align=\"right\"><strong>Fecha de inicio:</strong></div></td>
<td><select name=\"fechainicio\" onchange=\"submit();\">
");
print ("<option selected>Seleccione la fecha de inicio</option>");
//Muestra el combobox de las parroquias una vez que se haya elegido el canton, no antes
if (!isset($fechainicio)){ $fechainicio="0";
}
$sqlcan="select Fecha from $servicio where Tabla='$servicio'";
print("<option value=\"$fila[Fecha]\"");
if ($fila[Fecha] == $fechainicio) {
print ("selected");
}
print(">$fila[Fecha]</option>\n");
}
print("</select></td></tr>");
print("
<tr>
<td><div align=\"right\"><strong>Fecha de final:</strong></div></td>
<td><select name=\"fechafinal\">
");
print ("<option selected>Seleccione la fecha final</option>");
if (!isset($fechafinal)){
$fechafinal="0";
}
$sqlparr="select Fecha from $servicio where Tabla='$servicio'";
print("<option value=\"$filaprov[Fecha]\">$filaprov[Fecha]</option>");
}
print("
</select>
</td>
</tr>
");
?>
<tr>
<td><div align="right"><input name="button" type="submit" value="Enviar"></div></td>
<td><input name="reset" type="reset" value="Borrar"></td>
</tr>
</table>
</form>
<?php
} // cierro if principal del boton enviar
?>
</body>
</html>