Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

      Can anyone see where I might be going astray?

I usually work better when I have code in front of me to poke holes at.... so I'll provide some. This is taken straight from the CPAN download's examples for DBD::Chart here is some sample code for a pie chart:

#!/usr/bin/perl -w use DBI; use DBD::Chart; open(OUTF, ">pietest.html"); print OUTF "<html><body> <img src=simppie.png> <img src=updpie.png> <img src=delpie.png> </body></html>\n"; close OUTF; $dbh = DBI->connect('dbi:Chart:'); # # simple piechart # $dbh->do('CREATE TABLE pie (region CHAR(20), sales FLOAT)'); $sth = $dbh->prepare('INSERT INTO pie VALUES( ?, ?)'); $sth->execute('East', 2756.34); $sth->execute('Southeast', 3456.78); $sth->execute('Midwest', 1234.56); $sth->execute('Southwest', 4569.78); $sth->execute('Northwest', 33456.78); $rsth = $dbh->prepare( "SELECT PIECHART FROM pie WHERE WIDTH=400 AND HEIGHT=400 AND TITLE = \'Sales By Region\' AND COLOR=(red, green, blue, lyellow, lpurple) AND SIGNATURE=\'Copyright(C) 2001, GOWI Systems, Inc.\' AND BACKGROUND=lgray"); $rsth->execute; $rsth->bind_col(1, \$buf); $rsth->fetch; open(OUTF, '>simppie.png'); binmode OUTF; print OUTF $buf; close(OUTF); print "simppie.png OK\n"; $updsth = $dbh->prepare('UPDATE pie SET sales = ? WHERE region = \'Nor +thwest\' '); $updsth->bind_param(1, 12999.45); $updsth->execute; $rsth->execute; $rsth->bind_col(1, \$buf); $rsth->fetch; open(OUTF, '>updpie.png'); binmode OUTF; print OUTF $buf; close(OUTF); print "updpie.png OK\n"; $delsth = $dbh->prepare('delete from pie where region = ? '); $delsth->bind_param(1, 'Northwest'); $delsth->execute; $rsth->execute; $rsth->bind_col(1, \$buf); $rsth->fetch; open(OUTF, '>delpie.png'); binmode OUTF; print OUTF $buf; close(OUTF); print "delpie.png OK\n";

I ran the code and did an "ls" in my CWD and lo and behold I found:

[pberghol@cowdawg pietest]$ ls delpie.png pietest.html pietest.pl simppie.png updpie.png

I bet if I open pietest.html I should see a pretty chart. I tried it and I did. If you look here you'll see what I mean.


In reply to Re: Re: Re: Drawing graphs with perl by blue_cowdawg
in thread Drawing graphs with perl by Melanie

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2024-04-18 10:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found