我正在尝试在个人Web应用程序上显示一些Neo4j节点数据。
我从那里尝试了github示例: https://github.com/neo4j-contrib/neovis.js/tree/master/examples
并从此处阅读所有问题: https://github.com/neo4j-contrib/neovis.js/issues
我只想先显示一些简单的内容。
这是我的代码:
<html>
<head>
<title>DataViz</title>
<style type="text/css">
#viz {
width: 900px;
height: 700px;
}
</style>
<script src="https://rawgit.com/neo4j-contrib/neovis.js/master/dist/neovis.js"></script>
</head>
<script>
function draw() {
var config = {}
var viz = new NeoVis.default(config);
viz.render();
}
</script>
<body onload="draw()">
<div id="viz"></div>
</body>
</html>
在我的代码中,config是我要显示的数据集。
{
"comment": "AlchemyJS contributors",
"nodes": [
{
"id": 0,
"caption": "AlchemyJS",
"role": "project",
"fun_fact": "built almost entirely in D3",
"root": true
},
{
"id": 1,
"caption": "Huston Hedinger",
"github": "hustonhedinger",
"role": "Maintainer",
"fun_fact": "hooligan"
},
{
"id": 2,
"caption": "Grace Andrews",
"github": "Grace-Andrews",
"role": "Maintainer",
"fun_fact": "was born left handed, now right handed."
},
{
"id": 3,
"caption": "Isabella Jorissen",
"github": "ifjorissen",
"role": "Maintainer",
"fun_fact": "knows a lot of digits of pi. Also loves pie."
},
{
"id": 4,
"caption": "Matt Cox",
"github": "MDCox",
"role": "Maintainer",
"fun_fact": "is not fun"
},
{
"id": 5,
"caption": "Dave Torbeck",
"github": "DaveTorbeck",
"role": "Contributor",
"fun_fact": ""
}
],
"edges": [
{
"source": 1,
"target": 0,
"caption": "Maintains"
},
{
"source": 2,
"target": 0,
"caption": "Maintains"
},
{
"source": 3,
"target": 0,
"caption": "Maintains"
},
{
"source": 4,
"target": 0,
"caption": "Often Breaks"
},
{
"source": 5,
"target": 0,
"caption": "contributes"
}
]
}
该示例中的原始配置为:
{
container_id: "viz",
server_url: "bolt://54.88.38.186:32889",
server_user: "neo4j",
server_password: "change-guest-honks",
labels: {
"Troll": {
caption: "user_key",
size: "pagerank",
community: "community"
}
},
relationships: {
"RETWEETS": {
caption: false,
thickness: "count"
}
},
initial_cypher: "MATCH p=(:Troll)-[:RETWEETS]->(:Troll) RETURN p"
}
我想直接在我的视图中显示Neo4j数据,而不用从客户端查询数据库。