Dgraph output to d3.js format

Hi,

Is there any library which helps me to convert the dgraph into the d3.js format.

Something like below (d3.js),

{
    "nodes": [
        {
            "id": "1",
            "labels": ["User"],
            "properties": {
                "userId": "aman"
            }
        },
        {
            "id": "8",
            "labels": ["Project"],
            "properties": {
                "name": "dgraph",
                "title": "dgrpah.js",
                "description": "Dgraph visualization using D3.js.",
                "url": "aman.com"
            }
        }
    ],
    "relationships": [
        {
            "id": "7",
            "type": "seng",
            "startNode": "1",
            "endNode": "8",
            "properties": {
                "from": 5455154685
            },
            "source": "1",
            "target": "8",
            "linknum": 1
        }
    ]
}

Initially all the nodes and then the relationships.

Thanks.

If you are writing in Go, we have a graphql parser package that will give you a graph that you can then iterate over the nodes and edges with. Then just marshal that with the json package in a way that’s similar to how we serialise to cytoscape.js JSON here.

I am trying to implement this graph in UI, https://github.com/eisman/neo4jd3

In this case I need to transform the output of dgraph (json) into the d3.js format.

Sure, but what language are you writing in. If you are writing your code in Go, then you can use the strategy above. Otherwise, you will need to find another approach.

I am using javascript.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.