diff --git a/examples/network/data/dotLanguage/dotEdgeStyles.html b/examples/network/data/dotLanguage/dotEdgeStyles.html new file mode 100644 index 000000000..9d5644b08 --- /dev/null +++ b/examples/network/data/dotLanguage/dotEdgeStyles.html @@ -0,0 +1,197 @@ + + + + Network | DOT edge styles + + + + + + + + + + + + +
+
+ +
+ +
+ + + + diff --git a/lib/network/dotparser.js b/lib/network/dotparser.js index 9bb7e3c1f..577f5ed90 100644 --- a/lib/network/dotparser.js +++ b/lib/network/dotparser.js @@ -52,6 +52,7 @@ var NODE_ATTR_MAPPING = { }; var EDGE_ATTR_MAPPING = Object.create(NODE_ATTR_MAPPING); EDGE_ATTR_MAPPING.color = 'color.color'; +EDGE_ATTR_MAPPING.style = 'dashes'; // token types enumeration var TOKENTYPE = { @@ -682,6 +683,13 @@ function parseEdge(graph, from) { function parseAttributeList() { var attr = null; + // edge styles of dot and vis + var edgeStyles = { + 'dashed': true, + 'solid': false, + 'dotted': [1, 5] + }; + while (token === '[') { getToken(); attr = {}; @@ -701,6 +709,12 @@ function parseAttributeList() { throw newSyntaxError('Attribute value expected'); } var value = token; + + // convert from dot style to vis + if (name === 'style') { + value = edgeStyles[value]; + } + setValue(attr, name, value); // name can be a path getToken(); @@ -885,7 +899,6 @@ function DOTToGraph (data) { } } - // TODO: support of solid/dotted/dashed edges (attr = 'style') // TODO: support for attributes 'dir' and 'arrowhead' (edge arrows) if (dotEdge.to instanceof Object) {