图片存到图数据库

把图片路径+名称存到库里

d3.js 对Neo4j进行可视化展示原理,rest接口访问案例

1、从Neo4j里查出数据,通过Java或Curl(Rest 接口)
2、转成D3.js需要的格式,如:
{“nodes”:[{name:”Peter”,label:”Person”,id:1},{name:”Michael”,label:”Person”,id:2}, {name:”Neo4j”,label:”Database”,id:3}],
“links”:[{source:0, target:1, type:”KNOWS”, since:2010},{source:0, target:2, type:”FOUNDED”}, {source:1, target:2, type:”WORKS_ON”}]}
3、通过D3.js进行可视化展示。
https://neo4j.com/developer/guide-data-visualization/

Rest接口访问

案例:

  1. curl http://master:7474/db/data/transaction/commit -u neo4j:123456 -H "Content-Type: application/json" -d '{"statements":[{"statement":"MATCH path = (n:People)-[r]->(m:People) RETURN path"}]}‘

返回结果增加[graph] ,是为了方便解析json结果:

  1. curl http://master:7474/db/data/transaction/commit -u neo4j:123456 -H "Content-Type: application/json" -d '{"statements":[{"statement":"MATCH path = (n:People)-[r]->(m:People) RETURN path","resultDataContents":["graph"]}]}'

Curl是PHP带的命令,用于访问http接口的。

Java调http接口

HttpClient.post(http://master:7474/db/data/transaction/commit , -u=neo4j:123456& -H =Content-Type: application/json…)
(格式不合法的,举个例子而已)

目前流行的可视化js框架

Highchats、Echarts

开发流程

1、Java API执行Match语句

2、结果拼成D3.js需要的格式,如:
{“nodes”:
[
{“tupian”:”houliangping.png”,”name”:”侯亮平”,”id”:0},
{“tupian”:”gaoxiaoqin.png”,”name”:”高小琴”,”id”:1},
{“tupian”:”qitongwei.png”,”name”:”祁同伟”,”id”:2},
{“tupian”:”gaoyuliang.png”,”name”:”高玉良”,”id”:3},
{“tupian”:”caichenggong.png”,”name”:”蔡成功”,”id”:4},
{“tupian”:”lidakang.png”,”name”:”李达康”,”id”:5}
],
“links”:
[
{“source”:0,”target”:3,”type”:”学生”},
{“source”:2,”target”:1,”type”:”情妇”},
{“source”:4,”target”:0,”type”:”发小”},
{“source”:5,”target”:3,”type”:”同事”},
{“source”:2,”target”:3,”type”:”上司”}
]
}