This question about Using an extension: Task closed
GraphvizPlugin table example: string ran past end of line
I just installed the
GraphvizPlugin and tried to generate a Graph as described in
GraphvizPlugin#Graphviz_from_Table (using the exact same code as on the Plugin Page). It looks like this:
| *Node* | *Attributes* |
| hello | color="red" |
| world | shape=box |
| *Source* | *Label* | *Target* | *Attributes* |
| hello | | world | |
Given these two tables where the only two tables in a topic then this would render the appropriate graph:
%GRAPHVIZ{
topic="GraphvizTest"
nodestable="0"
nodecol="0"
nodeattrcol="1"
edgestable="1"
sourcecol="0"
labelcol="1"
targetcol="2"
edgeattrcol="3"
}%
After saving the page for the first time I got this message (instead of a graph):
Warning: string ran past end of line
Error: /tmp/QRNZOFPrVI.dot:4: syntax error near line 4
context: "world" [1]"] "hello" -> "world" [xlabel="", >>> 3]"] <<< }
00001: digraph GraphViz {
00002:
00003:
00004: "hello" [1]"]
00005: "world" [1]"] "hello" -> "world" [xlabel="", 3]"]}
After reloading the page, a graph was being displayed, but not the one I expected (more nodes with square brackets, probably resulting from the error above).
- I use foswiki 2.1.3
- Checked the InstalledPlugins page - no errors
--
EinExperte - 21 Oct 2017
Good morning anonymous expert. You are correct. The example does not work.
There is an error in the code of the
GraphvizPlugin/TableParser.pm module. Here is the patch:
diff --git a/lib/Foswiki/Plugins/GraphvizPlugin/TableParser.pm b/lib/Foswiki/Plugins/GraphvizPlugin/TableParser.pm
index 162c7d3..947173e 100644
--- a/lib/Foswiki/Plugins/GraphvizPlugin/TableParser.pm
+++ b/lib/Foswiki/Plugins/GraphvizPlugin/TableParser.pm
@@ -47,7 +47,7 @@ sub getNodes {
$index++;
next if $index == 1;# skip header
my @attrs = ();
- push @attrs, "$params->{nodeattrcol}]\"" if defined $params->{nodeattrcol};
+ push @attrs, "$row->[$params->{nodeattrcol}]" if defined $params->{nodeattrcol};
my $attrs = '';
$attrs = "[".join(", ", @attrs)."]" if @attrs;
push @lines, " \"$row->[$params->{nodecol}]\" $attrs";
@@ -77,7 +77,7 @@ sub getEdges {
next if $index == 1;# skip header
my @attrs = ();
push @attrs, "xlabel=\"$row->[$params->{labelcol}]\"" if defined $params->{labelcol};
- push @attrs, "$params->{edgeattrcol}]\"" if defined $params->{edgeattrcol};
+ push @attrs, "$row->[$params->{edgeattrcol}]" if defined $params->{edgeattrcol};
my $attrs = '';
$attrs = "[".join(", ", @attrs)."]" if @attrs;
push @lines, " \"$row->[$params->{sourcecol}]\" -> \"$row->[$params->{targetcol}]\" $attrs";
I will create a task and uploadt the change to github
--
BramVanOosterhout - 20 Nov 2017
Awesome. Will create a new release based on
Tasks.Item14531
--
MichaelDaum - 20 Nov 2017