Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Add support for graphviz edge "dir" #4202

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions examples/network/data/dotLanguage/dotEdgeStyles.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ <h1>DOT edge styles</h1>
' ahs -> diamond[label="diamond", arrowhead=diamond]; \n' +
' ahs -> tee[label="tee", arrowhead=tee]; \n' +
' ahs -> vee[label="vee", arrowhead=vee]; \n' +
' ahs -> both[label="both", dir=both]; \n' +
' ahs -> back[label="back", dir=back]; \n' +
' ahs -> none[label="none", dir=none]; \n' +
'}';

// create a network
Expand Down
27 changes: 26 additions & 1 deletion lib/network/dotparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,13 +740,38 @@ function parseAttributeList() {
vee: 'vee'
};

var dirTypes = {
forward: ["to"],
back: ["from"],
both: ["to", "from"],
none: []
};

if (name === 'arrowhead') {
var arrowType = arrowTypes[value];
name = 'arrows';
value = {to: {enabled:true, type: arrowType}};
}

setValue(attr, name, value); // name can be a path
if (name === 'dir') {
// First set all arrows to disabled
var status = {enabled: false};
var prop = "";
for (prop in dirTypes["both"]) {
name = `arrows.${dirTypes["both"][prop]}`;
setValue(attr, name, status);
}

var dirType = dirTypes[value];
for (prop in dirType) {
name = `arrows.${dirType[prop]}`;
status = {enabled: true};
setValue(attr, name, status); // name can be a path
}

} else {
setValue(attr, name, value); // name can be a path
}

getToken();
if (token ==',') {
Expand Down