提交 08439167 authored 作者: tb53863844's avatar tb53863844

修改bug

上级 6b9d77f6
......@@ -43,598 +43,7 @@ export default class Neo4jD3Com extends React.Component {
}
neo4jd3
init=(neo4jData)=>{
/* const x = [
{
"p": {
"start": {
"identity": 548,
"labels": [
"Actor"
],
"properties": {
"name": "Carrie-Anne Moss",
"personId": "carrieanne"
}
},
"end": {
"identity": 0,
"labels": [
"Movie"
],
"properties": {
"movieId": "tt0133093",
"title": "The Matrix",
"year": 1999
}
},
"segments": [
{
"start": {
"identity": 548,
"labels": [
"Actor"
],
"properties": {
"name": "Carrie-Anne Moss",
"personId": "carrieanne"
}
},
"relationship": {
"identity": 6,
"start": 548,
"end": 0,
"type": "ACTED_IN",
"properties": {
"role": "Trinity"
}
},
"end": {
"identity": 0,
"labels": [
"Movie"
],
"properties": {
"movieId": "tt0133093",
"title": "The Matrix",
"year": 1999
}
}
}
],
"length": 1.0
}
},
{
"p": {
"start": {
"identity": 547,
"labels": [
"Actor"
],
"properties": {
"name": "Laurence Fishburne",
"personId": "laurence"
}
},
"end": {
"identity": 0,
"labels": [
"Movie"
],
"properties": {
"movieId": "tt0133093",
"title": "The Matrix",
"year": 1999
}
},
"segments": [
{
"start": {
"identity": 547,
"labels": [
"Actor"
],
"properties": {
"name": "Laurence Fishburne",
"personId": "laurence"
}
},
"relationship": {
"identity": 3,
"start": 547,
"end": 0,
"type": "ACTED_IN",
"properties": {
"role": "Morpheus"
}
},
"end": {
"identity": 0,
"labels": [
"Movie"
],
"properties": {
"movieId": "tt0133093",
"title": "The Matrix",
"year": 1999
}
}
}
],
"length": 1.0
}
},
{
"p": {
"start": {
"identity": 546,
"labels": [
"Actor"
],
"properties": {
"name": "Keanu Reeves",
"personId": "keanu"
}
},
"end": {
"identity": 0,
"labels": [
"Movie"
],
"properties": {
"movieId": "tt0133093",
"title": "The Matrix",
"year": 1999
}
},
"segments": [
{
"start": {
"identity": 546,
"labels": [
"Actor"
],
"properties": {
"name": "Keanu Reeves",
"personId": "keanu"
}
},
"relationship": {
"identity": 0,
"start": 546,
"end": 0,
"type": "ACTED_IN",
"properties": {
"role": "Neo"
}
},
"end": {
"identity": 0,
"labels": [
"Movie"
],
"properties": {
"movieId": "tt0133093",
"title": "The Matrix",
"year": 1999
}
}
}
],
"length": 1.0
}
},
{
"p": {
"start": {
"identity": 548,
"labels": [
"Actor"
],
"properties": {
"name": "Carrie-Anne Moss",
"personId": "carrieanne"
}
},
"end": {
"identity": 1,
"labels": [
"Movie",
"Sequel"
],
"properties": {
"movieId": "tt0234215",
"title": "The Matrix Reloaded",
"year": 2003
}
},
"segments": [
{
"start": {
"identity": 548,
"labels": [
"Actor"
],
"properties": {
"name": "Carrie-Anne Moss",
"personId": "carrieanne"
}
},
"relationship": {
"identity": 7,
"start": 548,
"end": 1,
"type": "ACTED_IN",
"properties": {
"role": "Trinity"
}
},
"end": {
"identity": 1,
"labels": [
"Movie",
"Sequel"
],
"properties": {
"movieId": "tt0234215",
"title": "The Matrix Reloaded",
"year": 2003
}
}
}
],
"length": 1.0
}
},
{
"p": {
"start": {
"identity": 547,
"labels": [
"Actor"
],
"properties": {
"name": "Laurence Fishburne",
"personId": "laurence"
}
},
"end": {
"identity": 1,
"labels": [
"Movie",
"Sequel"
],
"properties": {
"movieId": "tt0234215",
"title": "The Matrix Reloaded",
"year": 2003
}
},
"segments": [
{
"start": {
"identity": 547,
"labels": [
"Actor"
],
"properties": {
"name": "Laurence Fishburne",
"personId": "laurence"
}
},
"relationship": {
"identity": 4,
"start": 547,
"end": 1,
"type": "ACTED_IN",
"properties": {
"role": "Morpheus"
}
},
"end": {
"identity": 1,
"labels": [
"Movie",
"Sequel"
],
"properties": {
"movieId": "tt0234215",
"title": "The Matrix Reloaded",
"year": 2003
}
}
}
],
"length": 1.0
}
},
{
"p": {
"start": {
"identity": 546,
"labels": [
"Actor"
],
"properties": {
"name": "Keanu Reeves",
"personId": "keanu"
}
},
"end": {
"identity": 1,
"labels": [
"Movie",
"Sequel"
],
"properties": {
"movieId": "tt0234215",
"title": "The Matrix Reloaded",
"year": 2003
}
},
"segments": [
{
"start": {
"identity": 546,
"labels": [
"Actor"
],
"properties": {
"name": "Keanu Reeves",
"personId": "keanu"
}
},
"relationship": {
"identity": 1,
"start": 546,
"end": 1,
"type": "ACTED_IN",
"properties": {
"role": "Neo"
}
},
"end": {
"identity": 1,
"labels": [
"Movie",
"Sequel"
],
"properties": {
"movieId": "tt0234215",
"title": "The Matrix Reloaded",
"year": 2003
}
}
}
],
"length": 1.0
}
},
{
"p": {
"start": {
"identity": 548,
"labels": [
"Actor"
],
"properties": {
"name": "Carrie-Anne Moss",
"personId": "carrieanne"
}
},
"end": {
"identity": 2,
"labels": [
"Movie",
"Sequel"
],
"properties": {
"movieId": "tt0242653",
"title": "The Matrix Revolutions",
"year": 2003
}
},
"segments": [
{
"start": {
"identity": 548,
"labels": [
"Actor"
],
"properties": {
"name": "Carrie-Anne Moss",
"personId": "carrieanne"
}
},
"relationship": {
"identity": 8,
"start": 548,
"end": 2,
"type": "ACTED_IN",
"properties": {
"role": "Trinity"
}
},
"end": {
"identity": 2,
"labels": [
"Movie",
"Sequel"
],
"properties": {
"movieId": "tt0242653",
"title": "The Matrix Revolutions",
"year": 2003
}
}
}
],
"length": 1.0
}
},
{
"p": {
"start": {
"identity": 547,
"labels": [
"Actor"
],
"properties": {
"name": "Laurence Fishburne",
"personId": "laurence"
}
},
"end": {
"identity": 2,
"labels": [
"Movie",
"Sequel"
],
"properties": {
"movieId": "tt0242653",
"title": "The Matrix Revolutions",
"year": 2003
}
},
"segments": [
{
"start": {
"identity": 547,
"labels": [
"Actor"
],
"properties": {
"name": "Laurence Fishburne",
"personId": "laurence"
}
},
"relationship": {
"identity": 5,
"start": 547,
"end": 2,
"type": "ACTED_IN",
"properties": {
"role": "Morpheus"
}
},
"end": {
"identity": 2,
"labels": [
"Movie",
"Sequel"
],
"properties": {
"movieId": "tt0242653",
"title": "The Matrix Revolutions",
"year": 2003
}
}
}
],
"length": 1.0
}
},
{
"p": {
"start": {
"identity": 546,
"labels": [
"Actor"
],
"properties": {
"name": "Keanu Reeves",
"personId": "keanu"
}
},
"end": {
"identity": 2,
"labels": [
"Movie",
"Sequel"
],
"properties": {
"movieId": "tt0242653",
"title": "The Matrix Revolutions",
"year": 2003
}
},
"segments": [
{
"start": {
"identity": 546,
"labels": [
"Actor"
],
"properties": {
"name": "Keanu Reeves",
"personId": "keanu"
}
},
"relationship": {
"identity": 2,
"start": 546,
"end": 2,
"type": "ACTED_IN",
"properties": {
"role": "Neo"
}
},
"end": {
"identity": 2,
"labels": [
"Movie",
"Sequel"
],
"properties": {
"movieId": "tt0242653",
"title": "The Matrix Revolutions",
"year": 2003
}
}
}
],
"length": 1.0
}
}
]
var graph = eval(x);
console.log(JSON.stringify(graph))
let nodes =[];
let links = []; // 存放节点和关系
let nodeSet = []; // 存放去重后nodes的id
for (let item of graph) {
// console.log(item.p.start instanceof Array)
// console.log(item.p)
// 重新更改data格式
if(nodeSet.indexOf(item.p.start.identity) == -1){
nodeSet.push(item.p.start.identity)
nodes.push({
id: item.p.start.identity,
labels: item.p.start.labels,
properties: item.p.start.properties
})
}
if(nodeSet.indexOf(item.p.end.identity) == -1){
nodeSet.push(item.p.end.identity)
nodes.push({
id: item.p.end.identity,
labels: item.p.end.labels,
properties: item.p.end.properties
})
}
links.push({
source: item.p.segments[0].relationship.start,
target: item.p.segments[0].relationship.end,
type: item.p.segments[0].relationship.type,
properties: item.p.segments[0].relationship.properties
})
}
console.log(nodes)
console.log(links) */
this.neo4jd3 = new Neo4jD3 ('#id_'+this.uid, {
highlight: [
{
......
......@@ -236,7 +236,7 @@ function Neo4jD3(_selector, _options) {
})
.html(function(d) {
var _icon = icon(d);
return _icon ? '&#x' + _icon : d.id;
return _icon ? '&#x' + _icon : d.properties.name;
});
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论