Ver Mensaje Individual
  #2 (permalink)  
Antiguo 25/06/2013, 14:14
Avatar de Karmac
Karmac
 
Fecha de Ingreso: agosto-2011
Ubicación: Bilbao
Mensajes: 196
Antigüedad: 12 años, 8 meses
Puntos: 34
Respuesta: CodeIgniter y JpGraph

A la hora de crear imágenes dinamicamente lo que se hace es colocar un header al principio del código que indique que el contenido va a ser una imagen, por lo que el navegador ignorará la extensión y tratará al archivo como tal.

Código PHP:
Ver original
  1. header( 'Content-type: image/png' );

Después, utilizando las funciones de imagenes en PHP se suele crear una imagen y hacerla PNG con la función imagepng();

Buscando por la documentación de JpGraph he encontrado el siguiente código que parece hacer lo que tu buscas, aunque eso sí, esta un poco sucio y ilegible.

Código PHP:
Ver original
  1. // Assume we would like to combine graph1,2 and 3
  2. // ...... create graph 1 here.......
  3. $handle1 =  $graph1->Stroke( _IMG_HANDLER);
  4.  
  5. // ...... create graph 2 here.......
  6. $handle2 =  $graph2->Stroke( _IMG_HANDLER);
  7.  
  8. // ...... create graph 3 here.......
  9. $handle3 =  $graph3->Stroke( _IMG_HANDLER);
  10.  
  11.  
  12. // Now create the "melting graph" which should contain all three graphs
  13. // $WIDTH1 and $HEIGHT1 are width and height of graph 1 ($handle1)
  14. // $WIDTH2 and $HEIGHT2 are width and height of graph 2 ($handle2)
  15. // $WIDTH3 and $HEIGHT3 are width and height of graph 3 ($handle3)
  16. // $x2,$x3 and $y2,$y3 shift from top left of global graph (ie position of
  17. // graph2 and graph3 in global graph)
  18.  
  19. $image = imagecreatetruecolor($WIDTH1,$HEIGHT1);
  20. imagecopy($image, $handle1,0, 0, 0, 0, $WIDTH1,$HEIGHT1);
  21. imagecopy($image, $handle1,$x1,$y1,0,0,$WIDTH2,$HEIGHT2);
  22. imagecopy($image, $handle1,$x2,$y2,0,0,$WIDTH3,$HEIGHT3);
  23.  
  24. // Stream the result back as a PNG image
  25. header("Content-type: image/png");
  26. imagepng ($image);

Básicamente lo que hace es crear una imagen con la librería JpGraph, y después crea otro lienzo con las funciones nativas de PHP para imagenes. Al final con imagecopy copia la imagen del gráfico al lienzo.

Si me muestras tu código quizá pueda pasartelo adaptado. Saludos.