Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@
},
{
"name": "CLI",
"program": "${workspaceFolder}/src/cli.js",
"program": "${workspaceFolder}/bin/cli.js",
"request": "launch",
"args": [
"-K neato",
"-n 2",
"./input.dot"
],
"skipFiles": [
Expand Down
35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,34 @@ npm install --global @hpcc-js/wasm
Usage: dot-wasm [options] fileOrDot

Options:
--version Show version number [boolean]
-K, --layout Set layout engine (circo | dot | fdp | sfdp | neato | osage |
patchwork | twopi). By default, dot is used.
-T, --format Set output language to one of the supported formats (svg, dot,
json, dot_json, xdot_json, plain, plain-ext). By default, svg
is produced.
-h, --help Show help [boolean]
--version Show version number [boolean]
-K, --layout Set layout engine (circo | dot | fdp | sfdp | neato | osage
| patchwork | twopi). By default, dot is used.
-T, --format Set output language to one of the supported formats (svg,
dot, json, dot_json, xdot_json, plain, plain-ext). By
default, svg is produced.
-n, --neato-no-op Sets no-op flag in neato.
"-n 1" assumes neato nodes have already been positioned and
all nodes have a pos attribute giving the positions. It
then performs an optional adjustment to remove node-node
overlap, depending on the value of the overlap attribute,
computes the edge layouts, depending on the value of the
splines attribute, and emits the graph in the appropriate
format.
"-n 2" Use node positions as specified, with no adjustment
to remove node-node overlaps, and use any edge layouts
already specified by the pos attribute. neato computes an
edge layout for any edge that does not have a pos
attribute. As usual, edge layout is guided by the splines
attribute.
-y, --invert-y By default, the coordinate system used in generic output
formats, such as attributed dot, extended dot, plain and
plain-ext, is the standard cartesian system with the origin
in the lower left corner, and with increasing y coordinates
as points move from bottom to top. If the -y flag is used,
the coordinate system is inverted, so that increasing
values of y correspond to movement from top to bottom.
-h, --help Show help [boolean]

Examples:
dot-wasm -K neato -T xdot ./input.dot Execute NEATO layout and outputs XDOT
Expand Down
22 changes: 21 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const yargs = require("yargs/yargs")(process.argv.slice(2))
.alias("T", "format")
.nargs("T", 1)
.describe("T", "Set output language to one of the supported formats (svg, dot, json, dot_json, xdot_json, plain, plain-ext). By default, svg is produced.")
.alias("n", "neato-no-op")
.nargs("n", 1)
.describe("n", "Sets no-op flag in neato.\n\"-n 1\" assumes neato nodes have already been positioned and all nodes have a pos attribute giving the positions. It then performs an optional adjustment to remove node-node overlap, depending on the value of the overlap attribute, computes the edge layouts, depending on the value of the splines attribute, and emits the graph in the appropriate format.\n\"-n 2\" Use node positions as specified, with no adjustment to remove node-node overlaps, and use any edge layouts already specified by the pos attribute. neato computes an edge layout for any edge that does not have a pos attribute. As usual, edge layout is guided by the splines attribute.")
.alias("y", "invert-y")
.nargs("y", 0)
.describe("y", "By default, the coordinate system used in generic output formats, such as attributed dot, extended dot, plain and plain-ext, is the standard cartesian system with the origin in the lower left corner, and with increasing y coordinates as points move from bottom to top. If the -y flag is used, the coordinate system is inverted, so that increasing values of y correspond to movement from top to bottom.")
.help("h")
.alias("h", "help")
.epilog("https://github.com/hpcc-systems/hpcc-js-wasm")
Expand All @@ -29,7 +35,21 @@ try {
} else {
dot = argv._[0];
}
gvMod.graphviz.layout(dot, argv.format ?? "svg", argv.layout ?? "dot").then(response => {

if (argv.n && argv.layout.trim() !== "neato") {
throw new Error("-n option is only supported with -T neato");
}

const ext = {
};
if (argv.n) {
ext.nop = parseInt(argv.n);
}
if (argv.y) {
ext.yInvert = true;
}

gvMod.graphviz.layout(dot, argv.format?.trim() ?? "svg", argv.layout?.trim() ?? "dot", ext).then(response => {
console.log(response);
}).catch(e => {
console.error(e.message);
Expand Down
Loading