Foros del Web » Programando para Internet » PHP »

Graficas en PHP

Estas en el tema de Graficas en PHP en el foro de PHP en Foros del Web. Holas señores, tengo que hacer un programa con gráficas, estoy utilizando php, mysql en dreamweaver, vi un código de ejemplo ya me bajé la librería ...
  #1 (permalink)  
Antiguo 20/12/2007, 09:04
 
Fecha de Ingreso: febrero-2006
Mensajes: 42
Antigüedad: 18 años, 2 meses
Puntos: 0
Graficas en PHP

Holas señores, tengo que hacer un programa con gráficas, estoy utilizando php, mysql en dreamweaver, vi un código de ejemplo ya me bajé la librería jpgraph, pero igual me está dando el error de que ha mandado texto antes de la imagen, cómo lo puedo solucionar.

Ya revisé y no tengo ningin espacio ningun texto antes de llaamr al codigo php que genera la gráfica, aqui se los dejo a ver que opinan

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?php include("jpgraph-1.22/src/jpgraph.php");
include("jpgraph-1.22/src/jpgraph_pie.php");
include("jpgraph-1.22/src/jpgraph_pie3d.php");
$data=array(40,60,21,33);
$graph=new PieGraph(450,200,"auto");
$graph->img->SetAntiAliasing();
$graph->SetMarginColor('gray');
//$graph->SetShadow();
// Setup margin and titles
$graph->title->Set("Ejemplo: Horas de Trabajo");
$p1=new PiePlot3D($data);
$p1->SetSize(0.35);
$p1->SetCenter(0.5);
// Setup slice labels and move them into the plot
$p1->value->SetFont(FF_FONT1,FS_BOLD);
$p1->value->SetColor("black");
$p1->SetLabelPos(0.2);
$nombres=array("pepe","luis","miguel","alberto");
$p1->SetLegends($nombres);
// Explode all slices
$p1->ExplodeAll();
$graph->Add($p1);
$graph->Stroke();
?>
</head>
<body>
</body>
</html>

EL error que me da es este:
JpGraph Error: HTTP headers have already been sent.
Caused by output from file grafico_linea.php at line 6.
Explanation:
HTTP headers have already been sent back to the browser indicating the data as text before the library got a chance to send it's image HTTP header to this browser. This makes it impossible for the library to send back image data to the browser (since that would be interpretated as text by the browser and show up as junk text).
Most likely you have some text in your script before the call to Graph::Stroke(). If this texts gets sent back to the browser the browser will assume that all data is plain text. Look for any text, even spaces and newlines, that might have been sent back to the browser.

For example it is a common mistake to leave a blank line before the opening "<?php".
__________________
Somos lo que nos proponemos...Cuenta con la ayuda de un ser supremo para lograrlo.
  #2 (permalink)  
Antiguo 20/12/2007, 09:07
Avatar de mauled  
Fecha de Ingreso: marzo-2005
Ubicación: Cd. de México.
Mensajes: 3.001
Antigüedad: 19 años, 1 mes
Puntos: 33
Re: Graficas en PHP

jeje lo que te quiere decir el error es que no puede haber ninguna salida al explorador ya sea echo ""; o etiquetas <html> antes de tu función stroke(). Por lo que te sugiero elimines cualquier tipo de salida antes de esto.

Saludillos.
  #3 (permalink)  
Antiguo 20/12/2007, 09:23
 
Fecha de Ingreso: febrero-2006
Mensajes: 42
Antigüedad: 18 años, 2 meses
Puntos: 0
Re: Graficas en PHP

Por eso mismo, no veo nada ningun código html o echo antes de eso. Ahí lo puedes ver en el código que publiqué, ese es todo mi código. No entiendo que pasa, si te fijas dice que el error esta en la linea 6, lo que tiene esa linea es el inicio del codigo php.
__________________
Somos lo que nos proponemos...Cuenta con la ayuda de un ser supremo para lograrlo.
  #4 (permalink)  
Antiguo 20/12/2007, 09:27
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: Graficas en PHP

Todo este:
Código HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
Es codigo HTML, al ponerlo antes de tu codigo PHP haces que las cabeceras se envien y no puedes enviar ya las cabeceras para la imagen.

Fijate tu codigo completo:
Código PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?php
// Antes de esto esta todo ese HTML = error
include("jpgraph-1.22/src/jpgraph.php");
include(
"jpgraph-1.22/src/jpgraph_pie.php");
include(
"jpgraph-1.22/src/jpgraph_pie3d.php");
$data=array(40,60,21,33);
$graph=new PieGraph(450,200,"auto");
$graph->img->SetAntiAliasing();
$graph->SetMarginColor('gray');
//$graph->SetShadow();
// Setup margin and titles
$graph->title->Set("Ejemplo: Horas de Trabajo");
$p1=new PiePlot3D($data);
$p1->SetSize(0.35);
$p1->SetCenter(0.5);
// Setup slice labels and move them into the plot
$p1->value->SetFont(FF_FONT1,FS_BOLD);
$p1->value->SetColor("black");
$p1->SetLabelPos(0.2);
$nombres=array("pepe","luis","miguel","alberto");
$p1->SetLegends($nombres);
// Explode all slices
$p1->ExplodeAll();
$graph->Add($p1);
$graph->Stroke();

// Igual al final de Stroke no debe de haber nada de HTML
?>
</head>
<body>
</body>
</html>
Saludos.
  #5 (permalink)  
Antiguo 20/12/2007, 09:36
 
Fecha de Ingreso: febrero-2006
Mensajes: 42
Antigüedad: 18 años, 2 meses
Puntos: 0
Re: Graficas en PHP

EEEEE!!! gracias!!!! si tienen razón era por eso... yo pensaba que se refería sólo a código HTML pero que si texto o algo por el estilo... perdona mi ignorancia... muchas gracia spor la pronta respuesta.

Saludos
__________________
Somos lo que nos proponemos...Cuenta con la ayuda de un ser supremo para lograrlo.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:12.