I want to convert my .dot file generated by Graphviz into an SVG for manipulation with D3.js. Currently, my focus is on reading the .dot file and displaying it in the console using JavaScript.
var fs = require('fs');
var dot = require('graphlib-dot');
var graph = dot.read(fs.readFileSync('profile.dot', 'UTF-8'));
console.log(dot.write(graph));
Upon attempting to execute my file in node, I encounter the following error:
/Users/blank/node_modules/graphlib-dot/lib/dot-grammar.js:114
result[k] = v[3];
^
TypeError: Cannot read property '3' of null
at peg$c34 (/Users/blank/node_modules/graphlib-dot/lib/dot-grammar.js:114:28)
at peg$parseidDef (/Users/blank/node_modules/graphlib-dot/lib/dot-grammar.js:1421:16)
at peg$parseaList (/Users/blank/node_modules/graphlib-dot/lib/dot-grammar.js:1144:12)
at peg$parseattrListBlock (/Users/blank/node_modules/graphlib-dot/lib/dot-grammar.js:1093:16)
at peg$parseattrList (/Users/blank/node_modules/graphlib-dot/lib/dot-grammar.js:1012:12)
at peg$parsenodeStmt (/Users/blank/node_modules/graphlib-dot/lib/dot-grammar.js:808:16)
at peg$parsestmt (/Users/blank/node_modules/graphlib-dot/lib/dot-grammar.js:689:20)
at peg$parsestmtList (/Users/blank/node_modules/graphlib-dot/lib/dot-grammar.js:615:22)
at peg$parsegraphStmt (/Users/blank/node_modules/graphlib-dot/lib/dot-grammar.js:452:28)
at Object.parse (/Users/blank/node_modules/graphlib-dot/lib/dot-grammar.js:2372:18)
The content of my .dot file is as follows:
digraph G {
pad = 0.5;
nodesep = 0.5;
"legend" [label = < <table border="0" cellborder="1"
cellspacing="0"><tr><td>Helix</td><td>Triplet</td>
<td>Frequency</td></tr>
<tr><td>1</td><td>1 73 8</td><td>1000</td></tr>
<tr><td>2</td><td>50 66 5</td><td>656</td></tr>
<tr><td>3</td><td>17 32 5</td><td>614</td></tr>
<tr><td>4</td><td>12 36 6</td><td>585</td></tr>
<tr><td>5</td><td>40 52 5</td><td>545</td></tr>
<tr><td>6</td><td>13 47 8</td><td>278</td></tr>
</table>>, shape = plaintext, fontsize=11];
"1 2 3 4 5 " [shape = box];
"1 2 6 " [shape = box];
"1 3 4 5 " [shape = box];
"1 " [shape = box];
"1 2 " [style = dashed];
"1 2 3 4 5 " [label = "[1[4[3]][5][2]]\n372/372"];
"1 2 6 " [label = "[1[6][2]]\n208/238"];
"1 3 4 5 " [label = "[1[4[3]][5]]\n165/537"];
"1 " [label = "[1]\n121/1000"];
"1 2 " [label = "[1[2]]\n12/656"];
"1 " [label = "[1]\n121/1000"];
"1 3 4 5 " -> "1 2 3 4 5 " [label = "2 ", arrowhead = vee];
"1 2 " -> "1 2 3 4 5 " [label = "3 4 5 ", arrowhead = vee];
"1 2 " -> "1 2 6 " [label = "6 ", arrowhead = vee];
"1 " -> "1 2 3 4 5 " [label = "2 3 4 5 ", arrowhead = vee];
"1 " -> "1 2 6 " [label = "2 6 ", arrowhead = vee];
"1 " -> "1 3 4 5 " [label = "3 4 5 ", arrowhead = vee];
"1 " -> "1 " [label = "", arrowhead = vee];
"1 " -> "1 2 " [label = "2 ", arrowhead = vee];
}