From 2e78c617cad44afb2bd5e47c855741d3c3182563 Mon Sep 17 00:00:00 2001 From: Yasufumi Ogawa Date: Mon, 7 Aug 2017 18:57:37 +0900 Subject: [PATCH 1/3] Add support for edge style * Update for TODO: support of solid/dotted/dashed edges (attr = 'style') * Edge styles are defined as var edgeStyles in parseAttributeList(). --- lib/network/dotparser.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/network/dotparser.js b/lib/network/dotparser.js index ee3f19976..2a4998b75 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(); From 97b33d35c4f5aee0b9d1e4e72d769e8630ea2bd6 Mon Sep 17 00:00:00 2001 From: Yasufumi Ogawa Date: Mon, 7 Aug 2017 18:58:51 +0900 Subject: [PATCH 2/3] Add example for edge styles Add an editable example for playing DOT edge styles --- .../data/dotLanguage/dotEdgeSytles.html | 197 ++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 examples/network/data/dotLanguage/dotEdgeSytles.html diff --git a/examples/network/data/dotLanguage/dotEdgeSytles.html b/examples/network/data/dotLanguage/dotEdgeSytles.html new file mode 100644 index 000000000..9d5644b08 --- /dev/null +++ b/examples/network/data/dotLanguage/dotEdgeSytles.html @@ -0,0 +1,197 @@ + + + + Network | DOT edge styles + + + + + + + + + + + + +
+
+ +
+ +
+ + + + From cb1ed1e1ff6ebe96dae382a0c867d12249b5a97b Mon Sep 17 00:00:00 2001 From: Yasufumi Ogawa Date: Thu, 17 Aug 2017 22:23:10 +0900 Subject: [PATCH 3/3] Correct typo and remove TODO description * Correct typo of filename from 'dotEdgeSytles.html' to 'dotEdgeStyles.html'. * Remove TODO description of the issue for edge style --- .../data/dotLanguage/{dotEdgeSytles.html => dotEdgeStyles.html} | 0 lib/network/dotparser.js | 1 - 2 files changed, 1 deletion(-) rename examples/network/data/dotLanguage/{dotEdgeSytles.html => dotEdgeStyles.html} (100%) diff --git a/examples/network/data/dotLanguage/dotEdgeSytles.html b/examples/network/data/dotLanguage/dotEdgeStyles.html similarity index 100% rename from examples/network/data/dotLanguage/dotEdgeSytles.html rename to examples/network/data/dotLanguage/dotEdgeStyles.html diff --git a/lib/network/dotparser.js b/lib/network/dotparser.js index 2a4998b75..cd473423a 100644 --- a/lib/network/dotparser.js +++ b/lib/network/dotparser.js @@ -899,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) {