Greetings

I am having a problem with regard to the GD::Graph module.(I've tried the CPAN documentation and the relevant perldocs, but as far as I can see I've done what I'm meant to.)

I've tried to use the following code to produce a graph within a webpage:

#!/usr/bin/perl -w use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use CGI qw(:standard); use GD::Graph; print header(); print start_html( -title=>'Title' -BGCOLOR=>'#e5e6f4', -style=>{'src'=>'/myicons/styledefs.css','title'=>'rtpstd'}); print start_form, #snip form-related stuff, end_form; #snip database interrogation stuff my $graph=GD::Graph::bars->new(); my $format=$graph->export_format; #seems to default to GIF print header("image/$format"); binmode STDOUT; my @data = ( ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 1, 2, 5, 6, 3, 1.5, 1, 3, 4] ); # I originally had @data pointing to some arrays generated from the ab +ove database interrogation, but I changed it to the above to eliminat +e this as a source of error. my $gd=$graph->plot(\@data)->$format() or die $graph->error; print $gd; print end_html;

However, where the graph should be I instead get about 20 lines of meaningless Unicode characters. I've tried manually setting $format to various formats other than the default gif (such as png, gd and jpeg), but this just produces different sets of meaningless Unicode characters. I don't get any error messages when the $gd object is created though, so I think it may be something to do with my browser settings. I've tried poking around in Firefox's and IE's image handling settings, but it doesn't seem to make any difference. I'm running Firefox v. 2.0.0.14, IE v.6 and Perl v.5.8.8

Any ideas?

TIA, campbell


In reply to Use of GD::Graph by campbell

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.