CSV Chart
This tiny module uses Custom filter (previously CCK Computed field) and Chart API modules and embeds a Google Chart anywhere inside the node text. It needs some setup before it can be used, but thankfully it's easier now than previously with the Computed Field module, and it allows multiple graphs per node.
First, you need to have Custom Filter installed. Then in any Filterset of your choice, add a new filter and name it eg. CSV Custom Filter. In the Pattern field enter:
/[<\[]csvdata[>\]](.*?)[<\[]\/csvdata[>\]]/isexactly. That way, you may use csvdata with [] or <> brackets (for bbcode-style or HTML input formats). In the Replacement Text enter:
$output = "";
$csvdata = $matches[1];
if ($csvdata != "") {
$csv = csvchart_get_csv_values($csvdata);
$graph = csvchart_create_graph($csv,TRUE);
$output .= "[img]".$graph."[/img]";
}
return $output;for the bbcode input format. If you want to use HTML filtering, use the following instead:
$output = "";
$csvdata = $matches[1];
if ($csvdata != "") {
$csv = csvchart_get_csv_values($csvdata);
$graph = csvchart_create_graph($csv);
$output .= $graph;
}
return $output;Note: For most/all input formats, unless you rearrange the CSV custom filter to be processed first of all, then the layout will break. This is because of the Line break and url filters in most input formats. You can change the order in admin/settings/filters, in the Rearrange tab, by setting the weight to -9 (or anything less the other filters actually). I'm still looking for a way so that this is not needed but, so far I have not been lucky.
The data inside the csvdata tags must be of the following form:
title,{chart title}
type,{chart type}
labels,{xlabel},{ylabel}
xdata,{csv list of X axis markers}
{legend of 1st graph},{csv list of Y axis data}
{legend of 2nd graph},{csv list of Y axis data}
...Note: The type field must be one of the following values:
lc|Line Chart
lxy|Line Chart XY
bhs|Bars Horizontal
bvs|Bars Vertical
bhg|Bars Horizontal Grouped
bvg|Bars Vertical Grouped
p|Pie Chart
p3|3D Pie Chart
v|Venn Diagram
s|Scatter PlotHere is an example:
[csvdata]
title, memcpy() - G4 1GHz - warm cache
type, lc
labels,Size (in bytes),MB/s
xdata, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152
glibc al, 17.8814, 31.7891, 57.2205, 114.4409, 190.7349, 326.9741, 538.5455, 762.9395, 893.1974, 1046.3170, 1126.8029, 1157.9792, 1183.7121, 957.4142, 958.1971
glibc nal, 35.7628, 47.6837, 81.7435, 190.7349, 269.2727, 366.2109, 610.3516, 915.5273, 1061.4810, 1126.8029, 1153.4203, 1193.3554, 897.9885, 928.5856
libfreevec al, 23.8419, 31.7891, 81.7435, 104.0372, 254.3132, 508.6263, 508.6263, 1220.7031, 1307.8962, 2929.6875, 3854.8520, 4185.2679, 4542.1512, 2271.0756, 2295.5436
libfreevec nal, 35.7628, 71.5256, 127.1566, 208.0744, 457.7637, 704.2518, 1017.2526, 2034.5052, 3051.7578, 3854.8520, 4372.6679, 4842.4587, 2103.9048, 1964.5851
libmotovec al, 17.8814, 28.6102, 47.6837, 95.3674, 254.3132, 653.9481, 832.2976, 1077.0910, 1408.5036, 2362.6512, 2929.6875, 3020.2964, 3150.2016, 2253.6058, 2295.5436
libmotovec nal, 31.7891, 81.7435, 143.0511, 326.9741, 416.1488, 704.2518, 915.5273, 1307.8962, 2092.6339, 2763.8561, 2639.3581, 3291.7837, 2186.3340, 2198.6398
[/csvdata]which produces one of the results in http://freevec.org/function/memcpy.
Enjoy, and I hope you might find the module useful. Thanks to the guys in Drupal for the best CMS ever and to the customfilter/chart module authors!
Releases
| Official releases | Date | Size | Links | Status | |
|---|---|---|---|---|---|
| 5.x-1.1 | 2008-Mar-28 | 6.86 KB | Download · Release notes | Recommended for 5.x | |
| Development snapshots | Date | Size | Links | Status | |
|---|---|---|---|---|---|
| 5.x-1.x-dev | 2008-Apr-06 | 6.86 KB | Download · Release notes | Development snapshot | |
