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

Add dir support #3888

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open

Add dir support #3888

wants to merge 17 commits into from

Conversation

geminoa
Copy link

@geminoa geminoa commented Mar 25, 2018

This update is for fixing TODO for 'dir' support. It is to comply with behaviour of graphviz described in [1].

[1] https://www.graphviz.org/doc/info/attrs.html#h:undir_note

As described in TODO, dotparser.js does not support 'arrowhead'
attribubte of edge.
This update is for adding 'dot' and 'tee'(bar) styles.
To support box arrowhead of graphviz, add Box endpoint class in
EndPoints.js and box attribute in dotparser.js.
To support diamond arrowhead of graphviz, add Diamond endpoint
class in EndPoints.js and diamond attribute in dotparser.js.
To support crow arrowhead of graphviz, add Crow endpoint
class in EndPoints.js and crow attribute in dotparser.js.
To support normal arrowhead of graphviz, add Triangle endpoint
class in EndPoints.js and normal attribute in dotparser.js.
To support curve arrowhead of graphviz, add Curve endpoint
class in EndPoints.js and curve attribute in dotparser.js.
To support inverted curve arrowhead of graphviz, add InvertedCurve
endpoint class in EndPoints.js and icurve attribute in
dotparser.js.
To support vee arrowhead of graphviz, add Vee endpoint class in
EndPoints.js and vee attribute in dotparser.js.
In createEdge(), accessing 'attr' causes an error if the edge has no
attribute and the value is null.
This update fixes bug for accessing null 'attr'.
Add followingn options for 'arrows.to.type'.

* box
* crow
* curve
* diamond
* inv_curve
* triangle
* inv_triangle
* vee
Add arrow types for the example.

'box', 'crow', 'curve', 'inv_curve', 'diamond', 'triangle',
'inv_triangle', 'vee'
Directional arrow has 'dir' attribute for defining direction of
'forward', 'back', 'both' or 'none'.

This update enables to 'dir' attribute. If you define an edge as
'a -> b[arrowhead=normal, dir=both]', arrowheads are depicted both
of source and destination.
This update is for comply with graphviz more strictly. As explained
in [1], graphviz has limitations for combination of arrow[head|tail]
and dir but dotparser.js does not behaviour as same.

[1] https://www.graphviz.org/doc/info/attrs.html#h:undir_note

If attribute list includes 'dir', following cases just be supported.
  1. both or none + arrowhead, arrowtail
  2. forward + arrowhead (arrowtail is not affedted)
  3. back + arrowtail (arrowhead is not affected)

In this update, parsed attributes is pushed 'attr_list' at once and
setValue() is not called in while loop in parseAttributeList().
setValue() is called after while loop ends.
It is because for checking attributes which change the same attribute
of vis. For instance, both of 'arrowhead' and 'dir' (edge style defined
in DOT) make changes for the same 'arrows' attribute in vis. If
setValue() is called from while loop, previous change is overwritten.
Merge remote-tracking branch 'upstream/develop' into add_dir
@micahstubbs
Copy link

micahstubbs commented Sep 3, 2018

looks good to me ✅

notice the differences:

dot --> both dot
vee --> back vee

http://localhost:8080/examples/network/data/dotLanguage/dotEdgeStyles.html

before

before-screen shot 2018-09-03 at 2 17 10 pm

after

after-screen shot 2018-09-03 at 2 42 21 pm

@micahstubbs
Copy link

merged here, thanks for the contribution @geminoa 😄 🙏 visjs-community/visjs-network#23

@mojoaxel
Copy link
Member

💌 Thanks @geminoa for your contribution!
This pull-request has been merge into visjs/vis-network#19

@mojoaxel mojoaxel added Network visjs APPLIED this PR was merged into a repo of the visjs family labels Jul 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Network visjs APPLIED this PR was merged into a repo of the visjs family
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants