Guru's

I am trying to put a graph in my application and I am getting the junk on
the web page insted of the image. I changed the header to image/png via
$q->header() method still its not working. Can anyone help me with this
problem. The code for the script is as below.

Thanks for your help and time.
Bal.


sub showdetails{
.....

print $q->header( {-type=>'image/png'} );

showgraph();

print $q->end_html();
}



sub showgraph{

############################################################
## SHOW GRAPH
##############################################################

use GD::Graph;
use CGI qw(:standard);
use GD::Graph::bars;

die "Can't open the data file\n" unless open(DF,"<c:/temp/grph.txt");

my @ndata = ( 
    ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"],
    [    1,    2,    5,    6,    3,  1.5,    1,     3,     4],
    [ sort { $a <=> $b } (1, 2, 5, 6, 3, 1.5, 1, 3, 4) ]
  );

my $graph = GD::Graph::bars->new(400, 300);

$graph->set( 
      x_label           => 'X Label',
      y_label           => 'Y label',
      title             => 'Some simple graph'
  );


my $gd = $graph->plot(\@ndata);

open(IMG, '>file.png') or die $!;

  binmode IMG;
  print IMG $gd->png;

  #...
  my $format = $graph->export_format;
  print header("image/$format");
  binmode STDOUT;
  print $graph->plot(\@ndata)->$format();

##########################################################
## Done Graph
##########################################################

}

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to