Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/03/2013, 15:58
DM270
 
Fecha de Ingreso: octubre-2012
Mensajes: 7
Antigüedad: 11 años, 6 meses
Puntos: 0
Mensaje Generar gráficos con PHP desde BD

Que tal estoy tratando de generar reportes gráficos con PHP extrayendo los datos de una base de datos, para esto estoy utilizando la librería JPGRAPH. El problema que me esta surgiendo es que al correr el html este aparece en blanco.
Aquí dejo el código de mi conexion y donde genero el gráfico.

Este se llama "consulta2.php"
<?
$link = mysql_connect('localhost', 'user', 'password');
@mysql_database("indicadores",$link);
if (!$link) {
die('Error de Conexión' . mysql_error());
}
echo 'Conexión Correcta';
?>

En este código lo mando llamar para extraer los datos y generar el gráfico.

<?php
include ("consulta2.php");
include_once ("jpgraph.php");
include_once ("jpgraph_bar.php");

$query = mysql_query("SELECT nombre,producido FROM aa1");

while($row = mysql_fetch_array($query))
{
$data[] = $row[0];
$can[] = $row[1];
}

// Create the graph.
// One minute timeout for the cached image
// INLINE_NO means don't stream it back to the browser.
$graph = new Graph(310,250,'auto');
$graph->SetScale("textlin");
$graph->img->SetMargin(60,30,20,40);
$graph->yaxis->SetTitleMargin(45);
$graph->yaxis->scale->SetGrace(30);
$graph->SetShadow();

// Turn the tickmarks
$graph->xaxis->SetTickSide(SIDE_DOWN);
$graph->yaxis->SetTickSide(SIDE_LEFT);

// Create a bar pot
$bplot = new BarPlot($can);

// Create targets for the image maps. One for each column
$targ=array("bar_clsmex1.php#1","bar_clsmex1.php#2 ","bar_clsmex1.php#3","bar_clsmex1.php#4","bar_cls mex1.php#5","bar_clsmex1.php#6");
$alts=array("val=%d","val=%d","val=%d","val=%d","v al=%d","val=%d");
$bplot->SetCSIMTargets($targ,$alts);
$bplot->SetFillColor("orange");

// Use a shadow on the bar graphs (just use the default settings)
$bplot->SetShadow();
$bplot->value->SetFormat(" $ %2.1f",70);
$bplot->value->SetFont(FF_ARIAL,FS_NORMAL,9);
$bplot->value->SetColor("blue");
$bplot->value->Show();

$graph->Add($bplot);

$graph->title->Set("Línea AA1, 2, 9, E3");
$graph->xaxis->title->Set("Supervisor");
$graph->yaxis->title->Set("Objetivo");

$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);

// Send back the HTML page which will call this script again
// to retrieve the image.
$graph->StrokeCSIM();
?>

Espero me puedan ayudar, porque me esta rompiendo la cabeza este proyecto. De antemano, gracias y saludos!