Enable tweaking of QNA-produced network and export of DOT code
Currently, rock::parse_source()
doesn't yet store the Dot object when creating the network diagram, so that can't be easily exported. Also, it doesn't yet allow easy manipulation of, for example, the layout engine to use (by default set to neato
, but could also be e.g. dot
or fdp
) or its parameters.
If somebody currently wants to tweak those parameters, they'd have to do the following:
### Import and parse a source
parsedSource <-
rock::parse_source(
file.path(
here::here("filename.rock")
)
);
### Write the output of the DiagrammeR function to convert the
### network to the Dot language to the clipboard
writeClipboard(
DiagrammeR::generate_dot(
parsedSource$networkCodes$network$graph
)
);
Then, they have to paste this into a text editor (e.g. Notepad, TextEdit, RStudio, etc) and use the Search & Replace functionality to replace all single quotes with double quotes, e.g.:
graph [layout = 'neato',
outputorder = 'nodesfirst',
bgcolor = 'white']
should become:
graph [layout = "neato",
outputorder = "nodesfirst",
bgcolor = "white"]
This is because the single quotes are a bug in the DiagrammeR package: they have to be double quotes.
Then, the users have go to https://dreampuf.github.io/GraphvizOnline and copy-paste the entire Dot specification in the left box. That shows the diagram in the right-hand panel.
Users can then tweak the layout type from "neato"
to "dot
or something else, and specify additional parameters to tweak the behavior of whichever rendering engine they choose (see e.g. https://graphviz.org/docs/layouts/neato/).