Created
May 7, 2013 12:29
-
-
Save antonkulaga/5532205 to your computer and use it in GitHub Desktop.
Vivagraph serialization bug
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
### | |
it is an extract from one of my classes. | |
Here a save a log of nodes to the graph but only first one is shown =( | |
### | |
@graph = Viva.Graph.graph() | |
params = | |
container: @get("node") | |
@renderer = Viva.Graph.View.renderer(@graph, params) | |
@renderer.run() | |
@graph.addNode(1, "some first data") | |
@graph.addNode(2, "some second data") | |
@graph.addNode(3, "is not saved") | |
@graph.addNode(4, "is not saved") | |
@graph.addNode(5, "is not saved") | |
@graph.addNode(6, "is not saved") | |
@graph.addNode(7, "is not saved") | |
@graph.addNode(8, "is not saved") | |
@graph.addLink(1, 2) | |
@graph.addLink(2, 3) | |
@graph.addLink(4, 5) | |
@graph.addLink(5, 1) | |
@graph.addLink(1, 4) | |
#@graph.addLink(8, 6) | |
nodes = [] | |
edges = [] | |
@graph.forEachNode( (n)-> | |
node = | |
id: n.id | |
data: n.data | |
nodes.push(node) | |
) | |
@graph.forEachLink( (link)-> | |
edges.push | |
fromId : link.fromId, | |
toId: link.toId, | |
data : link.data | |
) | |
g = | |
nodes:nodes | |
edges:edges | |
alert JSON.stringify(g) | |
@ | |
### | |
alert's outpit, only first node is given ;=( | |
{"nodes":[{"id":1,"data":"some first data"}],"edges":[{"fromId":1,"toId":2},{"fromId":2,"toId":3},{"fromId":4,"toId":5},{"fromId":5,"toId":1},{"fromId":1,"toId":4}]} | |
### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment