Skip to content

Commit 40ff573

Browse files
committed
add migrating guide and update nodeToHtml to objectToTitleHtml
1 parent 55a9f14 commit 40ff573

31 files changed

+489
-277
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 2.0.0
4+
5+
- Completely rewrite the configuration to be vis-network extension instead of wrapper
6+
7+
for migrating please check [guide](./MIGRATING.md)
8+
39
## 1.4.0
410

511
- [Add configurable title properties](https://github.com/neo4j-contrib/neovis.js/pull/74)
@@ -31,7 +37,6 @@
3137
- [Allow defining a node caption with a function](https://github.com/neo4j-contrib/neovis.js/pull/48)
3238
- [Add rendering completed event](https://github.com/neo4j-contrib/neovis.js/pull/47)
3339

34-
3540
## 1.0.0
3641

3742
...

MIGRATING.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Migrating From 1.X
2+
3+
2.0.0 was designed to be an extension of vis-network instead of a wrapper, that's means that all custom-made properties
4+
are now the vis-network name
5+
6+
## specifics
7+
8+
- neo4j driver configuration moved from flat onto the config object to `neo4j` onto the object
9+
10+
```ts
11+
// before
12+
const config = {
13+
// ...
14+
server_url: "bolt://localhost:7687",
15+
server_user: "neo4j",
16+
server_password: "sorts-swims-burglaries",
17+
encrypted: "ENCRYPTION_ON",
18+
trust: "TRUST_SYSTEM_CA_SIGNED_CERTIFICATES"
19+
// ...
20+
}
21+
//after
22+
const config = {
23+
// ...
24+
neo4j: { // this can also be a Neo4J driver instance now instead of object
25+
server_url: 'bolt://localhost:7687',
26+
server_user: 'neo4j',
27+
server_password: 'gland-presentation-worry',
28+
driverConfig: { // full driver config object by neo4j https://neo4j.com/docs/api/javascript-driver/current/function/index.html#configuration
29+
encrypted: "ENCRYPTION_ON",
30+
trust: "TRUST_SYSTEM_CA_SIGNED_CERTIFICATES"
31+
}
32+
}
33+
// ...
34+
}
35+
```
36+
37+
- any flat change on the object for the network is now under visConfig and uses the config from vis-network
38+
https://visjs.github.io/vis-network/docs/network/
39+
40+
```ts
41+
// before
42+
const config = {
43+
// ...
44+
arrows: true,
45+
hierarchical: true,
46+
hierarchical_sort_method: "directed"
47+
// ...
48+
}
49+
// after
50+
const config = {
51+
// ...
52+
visConfig: {
53+
edges: {
54+
arrows: {
55+
to: {enabled: true}
56+
}
57+
},
58+
layout: {
59+
enabled: true,
60+
sortMethod: 'directed'
61+
}
62+
},
63+
// ...
64+
}
65+
```
66+
67+
- changed node and relationship config to be vis-network node and edge extension and more consistent
68+
69+
```ts
70+
// before
71+
const config = {
72+
// ...
73+
labels: {
74+
Label: {
75+
caption: "name",
76+
size: "pagerank",
77+
community: "community",
78+
image: 'https://visjs.org/images/visjs_logo.png',
79+
font: {
80+
size: 26,
81+
color: "#000000"
82+
},
83+
title_properties: [
84+
"name",
85+
"pagerank"
86+
],
87+
sizeCypher: "MATCH (n) WHERE id(n) = $id MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
88+
}
89+
},
90+
relationships: {
91+
RELATIONSHIP: {
92+
"thickness": "weight",
93+
"caption": false
94+
}
95+
}
96+
// ...
97+
}
98+
// after
99+
const config = {
100+
labels: {
101+
Label: { // everything that is directly on this object gets mapped from the neo4j node
102+
// full properties list can be found at https://visjs.github.io/vis-network/docs/network/nodes.html
103+
label: "name", // puts the property `name` from the neo4j node and puts it onto the label property of vis.js's node
104+
value: "pagerank",
105+
group: "community",
106+
[NeoVis.NEOVIS_ADVANCED_CONFIG]: {// here you put node properties that aren't mapped directly from the neo4j node
107+
cypher: { // everything here will map to the vis.js node object from a cypher query (like sizeCypher worked but for every property)
108+
value: "MATCH (n) WHERE id(n) = $id MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
109+
},
110+
function: { // everything here will map function thats gets the neo4j node properties to a vis.js node property
111+
title: NeoVis.objectToTitleHtml, // alternativly
112+
title: (props) => NeoVis.objectToTitleHtml(props, ["name", "pagerank"])
113+
},
114+
static: { // everything here will be copied directly to the vis.js's node object
115+
font: {
116+
size: 26,
117+
color: "#000000"
118+
},
119+
shape: "image",
120+
image: 'https://visjs.org/images/visjs_logo.png'
121+
}
122+
}
123+
}
124+
},
125+
relationships: {
126+
RELATIONSHIP: { // same as node but mapped from neo4j relationship to vis.js edge
127+
// full properties list can be found at https://visjs.github.io/vis-network/docs/network/edges.html
128+
value: "wight",
129+
// the default is now without caption
130+
[NeoVis.NEOVIS_ADVANCED_CONFIG]: {// here you put edge properties that aren't mapped directly from the neo4j relationship
131+
cypher: {}, // same as label advance cypher
132+
function: { // same as label advance function
133+
title: NeoVis.objectToTitleHtml // putting caption on the title
134+
},
135+
static: {} // same as label advance static
136+
}
137+
}
138+
}
139+
}
140+
```

dist/neovis-without-dependencies.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/neovis-without-dependencies.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/neovis.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/neovis.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)