vasturiano/force-graph

Discrepency between .json files used in demo and syntax on README

Closed this issue · 2 comments

Describe the bug
The following .json file is given as an example in the README page:

{
    "nodes": [
        {
          "id": "id1",
          "name": "name1",
          "val": 1
        },
        {
          "id": "id2",
          "name": "name2",
          "val": 10
        },
        ...
    ],
    "links": [
        {
            "source": "id1",
            "target": "id2"
        },
        ...
    ]
}

However the following syntax is used in the miserables dataset:

 "nodes": [
      {"id": "Myriel", "group": 1},
      {"id": "Napoleon", "group": 1},
      ...

It would be great to see a clear description of what can be included in nodes.

To Reproduce
N/A

Expected behavior
An added section to the README that defines all of the values that can be imported via a JSON file.

Screenshots
N/A

Desktop (please complete the following information):
N/A

Smartphone (please complete the following information):
N/A

Additional context
None

@Harry-OBrien the input data structure is not fixed to a specific format. This is intentional to make the module more flexible. Instead, the accessor functions define how the attributes in the nodes/links objects can be used to interface with the module functionality.

For example, to use the val attribute to determine the node's size, you can do: .nodeVal('val').
This is equivalent to .nodeVal(node => node.val).

So if you wish to add a multiplication factor to it: .nodeVal(node => node.val * 3).

Hopefully this demonstrates how this is a more convenient approach than having a fixed format in the data.

That makes a lot of sense, thank you!