|
Cookbook /
ChartDirectorSummary: Add a bar chart to a page using modifiable data in page markup
Version:
Prerequisites:
Status:
Maintainer:Chris Cox
QuestionCan I add a bar chart to my page using modifiable data in page markup? AnswerThis is a quick hack. I am using the Chart Director package from Advanced Software Engineering. Put the download Markup('chartdir','<include',
"/\\(:chartdir\\s*(.*?):\\)/e",
"chartDir('$1')");
function commaURLEncode($items) {
return implode(",",array_map("urlencode", explode(",",$items)));
}
function chartDir($opts) {
$args = ParseArgs("$opts");
$first=1;
foreach ($args as $key => $value) {
if ($key == "#") {
continue;
}
if ($first) {
$httpParam = "?";
$first=0;
} else {
$httpParam = $httpParam."&";
}
$httpParam = $httpParam.$key."=".commaURLEncode($value);
}
# Replace localhost with your host.
# You may have to locate barchart.php somewhere else depending on your policies.
return "http://localhost/pmwiki/cookbook/barchart.php{$httpParam}&d=.png";
}
If it were enabled on this page, the markup example would show: ![]() Notes and Comments
See AlsoContributors |