PHP - problema con el header

 
Vista:

problema con el header

Publicado por luis santos (9 intervenciones) el 07/06/2007 20:16:52
Hola que tal. Tengo la impresion de que la duda que tengo es basica. Lo que pasa es que nunk he trabajado con el header.
estoy tratando de hacer una grafica pero cuando ejecuto la pagina me sale un poco de basura. Algo asi como :

‰PNG  IHDRh,aN¾ø IDATxœíݐՁðïüØÙí V²YÌꐴ![!°°ð ®$|pg¹„,?¯ˆ8|Eì`—*)Cì„Ê!T®²¹\Îq|‘Nò™B!9PˆddÙŠ½ gI ­Yýس³;;?òGk›Þîžžî™î~¯û}?E‰Ýžžž·óã;ï½~ïu¢Z­‚ˆÈ‹¤èQô08ˆÈ3yÆà "ÏD䃃ˆ8ŒÚÛ1:Š«®Âš5øÜçpñžÂ#ÙÇ`:7_ÚÖoƒº!‚é}ŸÎ;HÅAœýNïÂøQ$Ò¨‚z ƒC—Ë¡TBO֯ǾrC†š'ÇÇ€Ü;·§^AþP°y¡ (8tZ‚,Y‚±zuÀF¾apDDáNÿ¿‰ŒÿíA‡®½Å"6nĺu˜??¬G¥18¤7ôOøð%ä@u2ìG-84--°d î¼×]îc“ ‰ îÂï_ÆÄ€?çGrpèÚÚ0w.î¸ë× *9apHip^Dy$ÔV‰-

tengo la impresion que es por el header pero realmente no se.

Aqui esta el codigo por si acaso

<?
# The data for the pie chart
$data = array(25, 18, 15, 12, 8, 30, 35);

# The labels for the pie chart
$labels = array("Labor", "Licenses", "Taxes", "Legal", "Insurance", "Facilities",
"Production");

# Create a PieChart object of size 360 x 300 pixels
$c = new PieChart(360, 300);

# Set the center of the pie at (180, 140) and the radius to 100 pixels
$c->setPieSize(180, 140, 100);

# Set the pie data and the pie labels
$c->setData($data, $labels);

# output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));

?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:problema con el header

Publicado por basnek (63 intervenciones) el 13/06/2007 18:04:57
La verdad es que nola he usado a esa clase pero mientras la descargue para hacer alguna prueba te dejo esto para que vayas viendo

http://hagopriloudersporcomida.wordpress.com/2007/04/09/creacion-de-graficas-con-libchart-en-php/

A ver si ahi esta tu respuesta

Salu2 y mas tarde veo de instalar la libreria
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:problema con el header

Publicado por basnek (63 intervenciones) el 13/06/2007 20:17:08
Bueno ahi como te dije lo baje aunque creo que es otra versión pero bueno te paso el codigo modificado para 1ue veas tu ejemplo funcionar con esta vesión

Lo descargue de:
http://naku.dohcrew.com/libchart/pages/download/
libchart-1.1.tar.gz (96 kB)

Espero te sirva los cambios son menores. pero bueno puedes probar tambien el poner el header arriba de todo como he hecho en este ejemplo a ver si con eso con tu versión si funciona.

Salu2 y Éxitos

<?
include "../libchart/libchart.php";
$datos=array(
array( "dato"=>"Labor", "valor"=>25),
array( "dato"=>"Licenses", "valor"=>18),
array( "dato"=>"Taxes", "valor"=>15),
array( "dato"=>"Legal", "valor"=>12),
array( "dato"=>"Insurance", "valor"=>8),
array( "dato"=>"Facilities", "valor"=>30),
array( "dato"=>"Production", "valor"=>35)
);

header("Content-type: image/png");

# Create a PieChart object of size 360 x 300 pixels
$c = new PieChart(360, 300);

# Set the center of the pie at (180, 140) and the radius to 100 pixels
// $c->setPieSize(180, 140, 100);

# Set the pie data and the pie labels
// $c->setData($data, $labels);
for ($i=0; $i<count($datos); $i++) {
$c->addPoint(new Point($datos[$i]["dato"], $datos[$i]["valor"]));
}

# output the chart
$c->render();
?>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar