Repository navigation
Allowing for custom node positions on graphs - #193
Merged
Merged
Conversation
Can add custom (x,y) positions for all the nodes in a graph! This code doesn’t not work or effect the graphs that are “trees” i.e using setTreeData.
64json
added a commit
that referenced
this pull request
Jun 23, 2016
64json
added a commit
that referenced
this pull request
Jul 24, 2018
Allowing for custom node positions on graphs
64json
added a commit
that referenced
this pull request
Jul 24, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Can add custom (x,y) positions for all the nodes in a graph! This code
should not work or effect the graphs that are “trees”, i.e using _setTreeData.
I needed some way to force tracer._setData(G) to reset the graph even though the data in G didn't change so I added some helper functions that make the data "dirty" to force it to reset and set the data again and the node positions because they need to be redrawn on the screen. Maybe there is a better way to achieve this?
this.nodePositions (inside directed_graph.js) stores objects in the format
var myNodePositions = [{x:0,y:0},{x:1,y:1},{x:2,y:2}];someTracer._setNodePositions(myNodePositions);that means the 0th node will get its (x,y) = (0,0) when drawn on the screen. This allows someone to control the positions of the nodes.
If someone gives an array of length 4 and there are 6 nodes in the graph it will go back to the default positioning given. Thats what the ternary check is for.