用Vis.js可视化Neo4j图

时间:2017-09-26 10:13:11

标签: javascript json neo4j vis.js vis.js-network

我想在我的网络界面上可视化Neo4j图形。所以我使用using (System.IO.StreamReader sr = new System.IO.StreamReader("path")) { int fileNumber = 0; while (!sr.EndOfStream) { int count = 0; using (System.IO.StreamWriter sw = new System.IO.StreamWriter("other path" + ++fileNumber + ".xlsx")) { sw.AutoFlush = true; while (!sr.EndOfStream && ++count < 20000) { sw.WriteLine(sr.ReadLine()); } } } } 的{​​{1}}。当我在此示例中指定JSON文件时,它可以正常工作:

Netwok

但是当我尝试使用此Vis.js函数进行检索时:

    var container = document.getElementById('graph');
    var options = {         
        clickToUse : true,
        edges: {

        },
        nodes: {

        }
    };


    var json= {
                "nodes":[
                    {
                        "id":"203437",
                        "label":"test",
                        "properties":{"id":"1","name":"test","uuid":"23e0a5f0-9f73-11e7-a866-7427e54567dc3"}

                    },
                    {
                        "id":"200624",
                        "label":"test 2",
                        "properties":{"id":"2","name":"test 2","uuid":"045ea890-9f72-11e7-a866-7427ea637dc3"}

                    }
                ],
                "relationships":[
                    {
                        "id":"164107",
                        "type":"IS_IN",
                        "from":200624,
                        "to":203437,
                        "properties":[]
                    }
                ]
            };

      var g = {
                nodes: json.nodes,
                edges: json.relationships
            }; 
    var network = new vis.Network(container, g, options);

它不起作用,因为JavaScript结果不相同,并且不尊重 getDataFromCypherQuery: function(request, callback) { var json = { "query": "MATCH path= (I:Person)-[IS_IN*1..1]-() WHERE I.name=~'.*" + request + ".*' RETURN path" }; var res = $http.post( NEO4J_URL, json, config) .success(function(data) { if (callback && callback.success && typeof(callback.success) === 'function') { callback.success(data); } }) .error(function() { if (callback && callback.error && typeof(callback.error) === 'function') { callback.error(); } }); return res; } 期望的结构。事实上,我使用此函数获得的结果如下所示:

JSON

因此,我没有获得vis.Network格式的详细信息,而是获得了节点或关系的链接。 我该如何解决?

0 个答案:

没有答案