我正在使用Neo4j应用程序。并创建节点图。为了在UI上显示节点图,我们有Neovis.js。 Neovis.js名称取自vis.js。我得到的输出是-
在图片中,所有节点的颜色都不同。我们具有部门,功能,系统,参数等关系。我希望所有具有关系的节点(参数)和所有具有关系的节点(部门)都具有统一的颜色。
请建议更改以下代码。这将非常有用。
代码-
Neovis.js中的visjs
visjs: {
interaction: {
hover: true,
hoverConnectedEdges: true,
selectConnectedEdges: false,
// multiselect: true,
multiselect: 'alwaysOn',
zoomView: false,
experimental: { }
},
physics: {
barnesHut: {
damping: 0.1
}
},
nodes: {
mass: 4,
shape: 'neo',
labelHighlightBold: false,
widthConstraint: {
maximum: 40
},
heightConstraint: {
maximum: 40
}
},
edges: {
hoverWidth: 0,
selectionWidth: 0,
smooth: {
type: 'continuous',
roundness: 0.15
},
font: {
size: 9,
strokeWidth: 0,
align: 'top'
},
color: {
inherit: false
},
arrows: {
to: {
enabled: true,
type: 'arrow',
scaleFactor: 0.5
}
}
}
}
前端Neovis.js显示节点
var config = {
container_id: "viz",
server_url: "bolt://localhost:7474/",
server_user: "neo4j",
server_password: "ib1",
labels: {
//"Character": "name",
"Banking": {
"caption": "name",
"size": "pagerank",
community: "community",
"sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
},
"Parameter": {
"thickness": "weight",
"caption": true,
community: "community",
"sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
},
"Method": {
"thickness": "weight",
"caption": true,
community: "community",
"sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
},
"Request": {
"thickness": "weight",
"caption": true,
community: "community",
},
"Response": {
"thickness": "weight",
"caption": true,
"community": "Pink"
},
"Paths": {
"thickness": "weight",
"caption": true,
"community": "Purple"
},
"API": {
"thickness": "weight",
"caption": true,
"community": "Black"
},
"Department": {
"thickness": "weight",
"caption": true,
community: "community",
"sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
},
"System": {
"thickness": "weight",
"caption": true,
"community": "Red"
},
},
relationships: {
"Parameter": {
thickness: "weight",
caption: true,
community: "community",
color:'red'
},
"Method": {
"thickness": "weight",
"caption": true,
"community": "Blue",
'color':'red'
},
"Request": {
"thickness": "weight",
"caption": true,
"community": "Red",
'color':'green'
},
"Response": {
"thickness": "weight",
"caption": true,
"community": "Red",
'color':'black'
},
"Paths": {
"thickness": "weight",
"caption": true,
"community": "Red",
'color':'pink'
},
"API": {
"thickness": "weight",
"caption": true,
"community": "Red",
'color':'pink'
},
"Department": {
"thickness": "weight",
"caption": true,
"community": "Red",
'color':'pink'
},
"System": {
"thickness": "weight",
"caption": true,
"community": "Red",
'color':'pink'
},
},
initial_cypher:cypherQuery ,
arrows: true,
hierarchical_layout:true,
hierarchical_sort_method:"directed",
};