Código PHP :
<?php
require ('../modelo/modeloReportes.php');
require_once ('../jpgraph/jpgraph.php');
require_once ('../jpgraph/jpgraph_bar.php');
$objcon=new Reportes();
$res=$objcon->grafica();
while($filas=mysql_fetch_array($res)){
$datos[]=$filas['edad'];//valores en y
$nombres[]=$filas['nombre'];//valores en x
}
$graph = new Graph(500,500,"auto");
$graph->SetScale("textint");
$graph->img->SetMargin(50,30,50,50);
$graph->SetShadow();
$graph->title->Set("EDADES USUARIOS");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetTickLabels($nombres);
$graph->yaxis->title->Set('Edades');
$graph->xaxis->title->Set('Nombres');
$bplot = new BarPlot($datos);
$bplot->SetFillColor("lightgreen"); // Fill color
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL,FS_BOLD);
$bplot->value->SetAngle(0);
$bplot->value->SetColor("black","navy");
$bplot->SetColor("blue");
$bplot->SetFillGradient("blue","yellow",GRAD_MIDVER);
$graph->Add($bplot);
$graph->Stroke();
?> En el archivo modeloReportes tengo esto:
Código PHP :
function grafica(){
$sql="select edad,nombre from usuario";
$resultado=mysql_query($sql,$this->con);
return $resultado;
}
