|Perl: the Markov chain saw|
Re: Seeking GD::Graph like goal-thermometer graphby mattr (Curate)
|on Dec 19, 2006 at 06:20 UTC||Need Help??|
Hi! I'd like to point you to a GPL thermometer image, alert you to a problem with a module mentioned in this thread, and mention how to do it easily in GD or (probably more quickly) with rsvg. (the image mentioned is available as both PNG and SVG).
First, I tried GD-Dashboard mentioned above many moons ago, on a bug that was 2 years old at the time. I decided instead to roll my own GD-based Gantt-like workflow scheduler and I was very happy with plain GD. So, if you want to try Dashboard note that CPAN says it fails to build and you may have to debug it.
I would say use plain GD, but I also found a neat SVG one.
First, with GD: First find a free thermometer graphic or draw your own. Then use Gimp or another drawing program to find the coordinates of the red rectangle you need to draw to fill the thermometer, and adjust its height based on the thermometer's value. Also make some space above the thermometer to display a big XXX% label (maybe at the top of the thermometer) and get the coordinates of that rectangle too. The rest is pretty straightforward.
As for the graphic and the SVG one I found, I googled for thermometer gpl image (also open clipart might work). Check out this page which provides a script that uses rsvg to rasterize an svg image into a png file. This looks pretty easy to perlize, if you are on linux and install rsvg. At the very least, you can use the png image they show here as a template for your own GD-based thermometer if you don't want to use svg. If you can't view SVG you can get one here at Adobe. It will install an ActiveX component that lets you see the other thermometer in that siteÂs svg chemistry set on this page though it is more chemistry and less PR style.
Here is something like what you need for the svg one for your info (untested but syntax checked) though if you already are using GD then maybe you just want to use the PNG file on the same page. It is nice and easy to read.
Anyway in the bash script provided replace sed with s/// in perl, and use the system command to run rsvg and it should be doable really in 5 minutes. This will let you easily make a web form or config file to painlessly update the thermometer perhaps automatically. Watch out for when you exceed the boiling point though!
Oh some more links found in some later google results, which you can bend to your purposes.. ugly gd thermometer from php, webthermometer is gpl and has a nice thermo. gif image you can use