Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Needs ghostscript installed, produces a file "tmp.png".
#!/usr/bin/perl -w %stats = (Foo => 14, Bar => 10, Baz => 5, Box => 8); $title = "Widgets, Inc"; $ps_preamble = <<PS_END; %!PS-Adobe-2.0 /big /Helvetica findfont 20 scalefont def /tiny /Helvetica findfont 9 scalefont def /box { newpath moveto lineto lineto lineto closepath } def 0 setgray big setfont 612 ($title) stringwidth pop sub 2 div 648 moveto ($title) show 1 setlinewidth 72 72 72 720 540 720 540 72 box stroke tiny setfont PS_END open (GS, "|gs -dSAFER -dBATCH -dNOPAUSE -q -r80 -sDEVICE=png16m". " -sOutputFile=tmp.png - ") or die "Can't start Ghostscript" +; print GS $ps_preamble; my $n = keys %stats; my $w = 396/$n; my $i=0; for (keys %stats) { my $x = $i*$w+126; my $y = $stats{$_} * 30 + 108; print GS "$x 90 moveto\n($_) show\n"; print GS "0.5 0 0.8 setrgbcolor\n"; print GS "$x 108 ", "$x $y ", $x+$w/2, " $y ", $x+$w/2, " 108 box fill\n"; print GS "0 setgray\n"; $i++; } print GS "showpage\n"; close(GS);

-- All code is 100% tested and functional unless otherwise noted.

In reply to Re^3: What would you guys recommend for generating graphic-based output? by sleepingsquirrel
in thread What would you guys recommend for generating graphic-based output? by FrankRizzo

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 or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2022-10-02 22:08 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (13 votes). Check out past polls.