I’ve seen a couple of sites with a nifty thermometer graphic to show the current temperature, so I decided to create a generalized one for my site too
The thermometer.php (and associated thermometer-blank.png graphic) will create a 170x54 PNG graphic of the (rounded value) current, daily minimum and daily maximum temperature from the WD clientraw.txt or the VWS Weather Flash wflash.txt/wflash2.txt files.
Sample images (the PNGs are transparent background, shown in gray on the samples)
Thanks for the comments! That big red box (someday) will be a small image of a radar (preferably GR2). I keep on trying to ask Mike kindly to add FTP uploading to it, but he hasn’t done it yet. Oh well. :lol:
Thanks for all the kind words! I’m pleased you’ve found the thermometer script useful for your websites … it does seem to add a bit of zing to the display of conditions, and is very low overhead (graphic is about 1.5kb).
I was asked by WeatherBeacon on the WXForum.net about how to AJAX the updates to the thermometer image… I’ve come up with this mode for ajaxWDwx.js.
I haven’t implemented it yet in the distribution files, but if you’d like to modify your copy of ajaxWDwx.js to have the thermometer image update when the temperature changes via AJAX update, here’s what you can do:
In ajaxWDwx.js:
Insert this line in the settings area of the script
var thermometer = './thermometer.php'; // script for dynamic thermometer PNG image
Set the thermometer to the relative URL address of your thermometer.php script.
Kevin’s correct… I’ve updated the posting above to show it better, and changed the script slightly to make sure the browser will pull a fresh copy of the image generated by the thermometer.php script.
The script currently uses the built-in font(s) for GD … font size=1 for the scale, font size=2 for the min/max and font size=3 for the top legend.
The metrics for the font are used in the script to place the text over the image.
GD does support using TrueType fonts (as does Anole’s Weather Graphic script), but the current thermometer.php only supports the built-in fonts at the present time.
Did you have a particular font in mind? Arial Narrow or Franklin Gothic Condensed are two fonts that could work (given their small dimensions), but it would take a major rewrite of the script to support TrueType fonts (have to change multiple function calls and some of the math for placement to accomplish). Maybe in a future version?
Thanks for your reply.
I tough that font changing could be easily performed with some CSS coding, I don’t want to waste your time asking for major code rewriting, your script look pleasant as is.
My request was only for a little extra aesthetically touch.
I embedded the “ajax update to the thermometer image” on my work in progress page.
Everything work fine except a problem with the “Current temp is xx.x” tooltip message that appear when you hover the mouse over the image.
It work on IE6 but it fail (no tooltip) using the latest Opera and FireFox release.
Anyone could verify if the same happen on your pages ?