http://www.perlmonks.org?node_id=590403

hesco has asked for the wisdom of the Perl Monks concerning the following question:

Hello all:

I've been poking around for a couple of days looking for a module or script which would dynamically generate a goal-thermometer graph to support a fundraising effort.

I was hoping that GD::Graph might help, but so far, I haven't figured out how to turn its graphs into a thermometer shaped object.

The only thing I've found for this purpose so far is some php code on a Friends of Scouting site. But I'm hoping for a perl module, or script instead.

If anyone here has done this before and can share some sample code, or knows of something on CPAN designed for this job, I would certainly appreciate hearing about it. Failing that, I guess I can start porting the php code to perl, but I'd love to find the ready-made solution, instead.

Thanks,
-- Hugh

UPDATE:

Here is where I am at so far on this project:

package themometer; use strict; use warnings; use GD::Graph::bars; $GD::Graph::Error::Debug = '5'; my $g = GD::Graph::bars->new(80,180) or die GD::Graph->error; my @data = (['Your Contributions'],[55]); $g->set( y_label => 'Progress toward our Goal (%)', y_max_value => '100', y_tick_number => '10', y_label_skip => '2' ) or die $g->error; my $gd = $g->plot(\@data) or die $g->error; unlink 'fundraising_progress_graph.gif'; open(IMG, '>fundraising_progress_graph.gif') or die $!; binmode IMG; print IMG $gd->gif; close IMG; 1;
If it had a bulb filled with mercury at the bottom, this would fulfill my requirement for a thermometer graphic. As it is, this is getting pretty close. Can any of your GD fans advise me how best to add the bulb at the bottom of this image, please?

if( $lal && $lol ) { $life++; }