Last updated 10 November 2014. Created on 4 November 2014.
Edited by Pierre.Vriens. Log in to edit this page.

CSV Chart is a tiny module that uses Custom filter (previously Computed Field) and Google Chart Tools: Image Charts modules and embeds a Google Chart anywhere inside the node text. It allows for multiple graphs on a single node.

CSV Chart requires some setup before it can be used, as further detailed below.

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[>\]]/is

exactly. 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 Plot

Here 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 (Note: this link seems to not work anymore ... use the links near the top of this page instead).

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.