Saturday, 15 June 2013

ruby on rails 3 - D3 Graph Example Using In Memory Object -


It seems that it should be simple, but I have really spent hours without any success.

On the D3 graph example. Example Graph Uses a local file called Jason, I have set up a rail app for the service of a similar graph, though I do not want to write a JSON file. Instead, I generate nodes and links in one object such as:

  {"nodes": [{"node_type": "person", "name": "damian", "id "{{" Source: ":" demian_piners "," "" "{" node_type ":" person "," name ":" grant "," id ":" grant-owner "}}}," link " Goal Now when I present the D3, call me  d3.json ("need to update graph.json)", function (jsn) {...});  Instead of local file (or url) in my in-memory ob For reference, I have tried to break my HTML / JavaScript, for example, for example I set the  var dataset = & lt;% = raw (@myInMemoryObject)% & gt ;; / /> , And he works to work (I had a warning on the dataset), although I can not get the D3 code to use it.  

I use my in-memory How can I change the d3.json call to use the object?

Thanks,

> Damien

Your idea of ​​using , For example, var dataset = & lt;% = raw (@myInMemoryObject)% & gt; ; The right way to go is, but you need to present your object in the correct format.

Nodes in the nodes node array specified in the link require numerical reference. For the first time, 1 for the second

  var json = {"nodes": [{"name": "damian", "id": "a"}, {"name" : "Link": ["source": 0, "target": 1, "value": 1}]}    P> or links to real objects that create nodes themselves:  
  var a = {"name": "damian", "id": "a"}; Var = "name": "Bob", "id": "b"} var json = {"nodes": [a, b], "links": [{"source": a, "target": B, "value": 1}]};   

The relevant discussion is given here:

Here the example:

No comments:

Post a Comment