|
Cookbook /
GoalMeterSummary: Create thermometers or columns showing goals and current values
Version: 2009-01-29
Prerequisites: pmwiki 2, GD library
Status: stable
Maintainer:
Categories: Images
Download: goalmeter.phpΔ
Questions answered by this recipeI like to add a fundraising thermometer on a page. DescriptionShow a thermometer or column with goal and current values. Install goalmeter.phpΔ the usual way by copying file to cookbook/ direcory and adding to a local configuration file: include_once("$FarmD/cookbook/goalmeter.php");
Then use in a page the markup To customise the image you can add lots of parameters. You can have multiple goalmeters on one page. Set Default settings:
'current' => '0', # current value
'goal' => '100', # goal value
'max' => '', # max value as alternative to goal, goal will not be displayed
'height' => '360', # outer height
'width' => '', # outer width, default automatic calculation
'bar' => '3', # bar thickness 1 ... 5
'font' => '4', # font size 1 ... 5
'bg' => 'ffffffff',# background color (transparent)
'fill' => 'FF0000', # main fill and border color
'topfill' => 'FFFFCC', # top fill color
'bulbfill'=> '', # bulb fill color (defaults to main fill color)
'scale' => '666666', # scale color
'value' => '000000', # value text color
'percent' => 'FFFFFF', # percent text color
'border' => '', # outer border color
'nobulb' => '', # set to 1 for column only display
'noscale' => '', # set to 1 for no scale display
'padding' => '8', # img padding
'rpad' => '40', # right hand extra padding
'base' => '', # pagename of base page to check for page modifications
The resulting image(s) are stored in a cache directory with unique filenames as png images. The markup directive only constructs images fresh if the page is updated. Make sure to force a page refresh after changing any parameters in the markup, to force the new image file to be loaded.
You can see a demo here: http://softflow.co.uk/design/Test/GoalMeter NotesThe server needs to have the php GD library installed, which supports image functions. See www.php.net/gd Release Notes
CommentsSimon Brown 16/Nov/06 I added this recipe but I get an error message; Fatal error: Call to undefined function: imagefontwidth() in c:\inetpub\wwwroot\pmwiki\cookbook\goalmeter.php on line 66 When I try to preview or save. I am using Wiki 2.2.0.beta2 with the triad skin Any ideas? I think your server does not have the GD graphic library installed. Probably not part of your local default php installation. See www.php.net/gd. ~HansB Currently, the recipe uses $LastModTime which forces a regeneration of the pictures if any page on the whole wiki is modified. May I suggest that it regenerates them only if the embedding page itself is changed? It will use less server resources. Also, an automatic id could be added with Recipe now updated. No more use of $LastModTime. By default only changes to current page will trigger image regeneration. For the case the markup is using a parameter witha PTV from another page, a base=pagename parameter can be set, so the image will regenerate on changes to that page. I did not introduce a global var to enable wiki-wide mod time checking. I also followed your suggestion and generate the id automatically, thanks! - HansB January 29, 2009, at 01:35 PM See Also
ContributorsSandbox
User notes?: If you use, used or reviewed this recipe, you can add your name. The following format is recognized:
* (+) Optional positive comment. Name, date * (-) Optional negative comment. Name, date These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |