Skip to content

Commit 5ef90dc

Browse files
authored
Merge pull request #157 from neo4j-contrib/example
Migrate all examples to 2.0.0
2 parents 8fffe33 + 3298b95 commit 5ef90dc

File tree

7 files changed

+217
-185
lines changed

7 files changed

+217
-185
lines changed

examples/advanced-example.csv

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
all
2+
"[{""size"":10,""pagerank"":test2,""community"":tew12},{""wight"":1},{""size"":100,""pagerank"":test,""community"":tew1}]"
3+
"[{""size"":10,""pagerank"":test2,""community"":tew12},{""wight"":1},{""size"":100,""pagerank"":test,""community"":tew1}]"
4+
"[{""size"":100,""pagerank"":test,""community"":tew1},{""wight"":1},{""size"":100,""pagerank"":test,""community"":tew1}]"
5+
"[{""size"":10,""pagerank"":test2,""community"":tew12},{""wight"":1},{""size"":10,""pagerank"":test2,""community"":tew12}]"
6+
"[{""size"":100,""pagerank"":test,""community"":tew1},{""wight"":1},{""size"":10,""pagerank"":test2,""community"":tew12}]"
7+
"[{""size"":100,""pagerank"":test,""community"":tew1},{""wight"":1},{""size"":10,""pagerank"":test2,""community"":tew12}]"

examples/advanced-example.html

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,34 +31,42 @@
3131
// draw
3232

3333

34-
35-
3634
var viz;
3735

3836
function draw() {
3937
var config = {
4038
container_id: 'viz',
41-
neo4j: {
39+
neo4j: {
4240
server_url: 'bolt://localhost:7687',
4341
server_user: 'neo4j',
4442
server_password: 'gland-presentation-worry',
43+
encrypted: "ENCRYPTION_OFF"
44+
},
45+
visConfig: {
46+
nodes: {
47+
shape: 'square'
48+
},
49+
edges: {
50+
arrows: {
51+
to: {enabled: true}
52+
}
53+
},
4554
},
4655
labels: {
4756
//"Character": "name",
4857
'Character': {
49-
'value': 'pagerank',
58+
'label': 'pagerank',
5059
'group': 'community',
5160
//'label': 'name',
5261
//"sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
5362
[NeoVis.NEOVIS_ADVANCED_CONFIG]: {
54-
'static': {
55-
'shape': 'dot',
56-
'label': '12'
63+
cypher: {
64+
value: "MATCH (n) WHERE id(n) = $id RETURN n.size"
5765
},
5866
'function': {
5967
'title': (node) => {
6068
return viz.nodeToHtml(node, undefined);
61-
}
69+
}
6270
},
6371
}
6472
}
@@ -76,7 +84,7 @@
7684
}
7785
}
7886
},
79-
initial_cypher: 'MATCH (n)-[r:INTERACTS]->(m) where id(n) < 40 and id(m) < 40 RETURN n,r,m'
87+
initial_cypher: 'MATCH (n)-[r]->(m) RETURN n,r,m'
8088
};
8189

8290
viz = new NeoVis.default(config);

examples/example-labels.html

Lines changed: 62 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -26,48 +26,59 @@
2626
crossorigin="anonymous"></script>
2727

2828
<script type="text/javascript">
29-
// define config car
30-
// instantiate nodevis object
31-
// draw
32-
33-
var viz;
34-
35-
function draw() {
36-
var config = {
37-
container_id: "viz",
38-
server_url: "bolt://54.209.44.254:33146",
39-
server_user: "neo4j",
40-
server_password: "investigators-spill-future",
41-
labels: {
42-
//"Character": "name",
43-
"Person": {
44-
"caption": "name",
45-
"size": 1.0,
46-
"sizeCypher": "MATCH (n) WHERE id(n) = {id} RETURN SIZE((n)--()) AS s;",
47-
"icon": "????"
48-
},
49-
"Organization": {
50-
"caption": "name",
51-
"size": 2.0,
52-
"sizeCypher": "MATCH (n) WHERE id(n) = {id} RETURN SIZE((n)--()) AS s",
53-
"icon": "???"
54-
}
55-
56-
},
57-
relationships: {
58-
"PRESIDENT": {
59-
"caption": "El Presidente"
60-
}
61-
},
62-
initial_cypher: "match (p:Person)-[r]-(o:Organization)-[r1]-(p2:Person) RETURN * LIMIT 10",
63-
arrows: false
64-
};
65-
66-
viz = new NeoVis.default(config);
67-
viz.render();
68-
console.log(viz);
69-
70-
}
29+
// define config car
30+
// instantiate nodevis object
31+
// draw
32+
33+
var viz;
34+
35+
function draw() {
36+
var config = {
37+
container_id: "viz",
38+
neo4j: {
39+
server_url: "bolt://54.209.44.254:33146",
40+
server_user: "neo4j",
41+
server_password: "investigators-spill-future"
42+
},
43+
labels: {
44+
//"Character": "name",
45+
Person: {
46+
label: "name",
47+
[NeoVis.NEOVIS_ADVANCED_CONFIG]: {
48+
static: {
49+
value: 1.0
50+
},
51+
cypher: {
52+
value: "MATCH (n) WHERE id(n) = $id RETURN SIZE((n)--()) AS s;"
53+
}
54+
}
55+
},
56+
"Organization": {
57+
caption: "name",
58+
[NeoVis.NEOVIS_ADVANCED_CONFIG]: {
59+
static: {
60+
value: 2.0
61+
},
62+
cypher: {
63+
value: "MATCH (n) WHERE id(n) = $id RETURN SIZE((n)--()) AS s"
64+
}
65+
}
66+
}
67+
68+
},
69+
relationships: {
70+
PRESIDENT: {
71+
label: "El Presidente"
72+
}
73+
},
74+
initial_cypher: "match (p:Person)-[r]-(o:Organization)-[r1]-(p2:Person) RETURN * LIMIT 10"
75+
};
76+
77+
viz = new NeoVis.default(config);
78+
viz.render();
79+
console.log(viz);
80+
81+
}
7182
</script>
7283
</head>
7384
<body onload="draw()">
@@ -81,19 +92,19 @@
8192
</body>
8293

8394
<script>
84-
$("#reload").click(function() {
95+
$("#reload").click(function () {
8596

86-
var cypher = $("#cypher").val();
97+
var cypher = $("#cypher").val();
8798

88-
if (cypher.length > 3) {
89-
viz.renderWithCypher(cypher);
90-
} else {
91-
console.log("reload");
92-
viz.reload();
99+
if (cypher.length > 3) {
100+
viz.renderWithCypher(cypher);
101+
} else {
102+
console.log("reload");
103+
viz.reload();
93104

94-
}
105+
}
95106

96-
});
107+
});
97108

98109
</script>
99110
</html>

examples/form-example.html

Lines changed: 76 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99

1010
#viz {
1111
width: 75%;
12-
height:700px;
12+
height: 700px;
1313
border: 1px solid lightgray;
1414
font: 22pt arial;
15-
margin: 10px;
15+
margin: 10px;
16+
}
17+
18+
label {
19+
display: inline-block;
20+
width: 10em;
1621
}
17-
label {
18-
display: inline-block;
19-
width: 10em;
20-
}
2122

2223
</style>
2324

@@ -29,94 +30,96 @@
2930
crossorigin="anonymous"></script>
3031

3132
<script type="text/javascript">
32-
var viz;
33-
34-
function draw() {
35-
var config = {
36-
container_id: "viz",
37-
server_url: $("#url").val(),
38-
server_user: $("#user").val(),
39-
server_password: $("#pass").val(),
40-
labels: {},
41-
relationships: {},
42-
initial_cypher: $("#cypher").val()
43-
};
44-
config.labels[$("#label").val()] = {
45-
"caption": $("#caption").val(),
46-
"size": $("#size").val(),
47-
"community": $("#community").val(),
48-
//"sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
49-
};
50-
config.relationships[$("#rel_type").val()] = {
51-
"thickness": $("#thickness").val(),
52-
"caption": $("#rel_caption").val(),
53-
}
54-
viz = new NeoVis.default(config);
55-
viz.render();
56-
console.log(viz);
57-
58-
}
33+
var viz;
34+
35+
function draw() {
36+
var config = {
37+
container_id: "viz",
38+
neo4j: {
39+
server_url: $("#url").val(),
40+
server_user: $("#user").val(),
41+
server_password: $("#pass").val()
42+
},
43+
labels: {},
44+
relationships: {},
45+
initial_cypher: $("#cypher").val()
46+
};
47+
config.labels[$("#label").val()] = {
48+
label: $("#caption").val(),
49+
value: $("#size").val(),
50+
group: $("#community").val(),
51+
//"sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
52+
};
53+
config.relationships[$("#rel_type").val()] = {
54+
value: $("#thickness").val(),
55+
label: $("#rel_caption").val(),
56+
}
57+
viz = new NeoVis.default(config);
58+
viz.render();
59+
console.log(viz);
60+
61+
}
5962
</script>
6063
</head>
6164
<body>
6265
<div id="viz" style="float:left"></div>
6366

6467
<div>
65-
<div><h3>Connection Details:</h3>
68+
<div><h3>Connection Details:</h3>
6669

67-
<label for="url">URL</label><input id="url" name="url" type="text" value="bolt://localhost:7687"/><br/>
68-
<label for="user">Username</label><input id="user" name="user" type="text" value="neo4j"/><br/>
69-
<label for="pass">Password</label><input id="pass" name="pass" type="password" value="test"/>
70-
</div>
70+
<label for="url">URL</label><input id="url" name="url" type="text" value="bolt://localhost:7687"/><br/>
71+
<label for="user">Username</label><input id="user" name="user" type="text" value="neo4j"/><br/>
72+
<label for="pass">Password</label><input id="pass" name="pass" type="password" value="test"/>
73+
</div>
7174

72-
<div><h3>Styling Nodes:</h3>
75+
<div><h3>Styling Nodes:</h3>
7376

74-
<label for="label">Node-Label</label><input id="label" name="label" type="text" value="Character"/><br/>
75-
<label for="caption">Label</label><input id="caption" name="caption" type="text" value="name"/><br/>
76-
<label for="size">Size</label><input id="size" name="size" type="text" value="pagerank"/><br/>
77-
<label for="color">Color</label><input id="community" name="community" type="text" value="community"/>
78-
</div>
77+
<label for="label">Node-Label</label><input id="label" name="label" type="text" value="Character"/><br/>
78+
<label for="caption">Label</label><input id="caption" name="caption" type="text" value="name"/><br/>
79+
<label for="size">Size</label><input id="size" name="size" type="text" value="pagerank"/><br/>
80+
<label for="color">Color</label><input id="community" name="community" type="text" value="community"/>
81+
</div>
7982

8083

81-
<div><h3>Styling Relationship:</h3>
84+
<div><h3>Styling Relationship:</h3>
8285

83-
<label for="type">Relationship-Type</label><input id="type" name="type" type="text" value="INTERACTS"/><br/>
84-
<label for="thickness">Thickness</label><input id="thickness" name="thickness" type="text" value="weight"/><br/>
85-
<label for="rel_caption">Caption</label><input id="rel_caption" name="rel_caption" type="text" value=""/>
86-
</div>
86+
<label for="type">Relationship-Type</label><input id="type" name="type" type="text" value="INTERACTS"/><br/>
87+
<label for="thickness">Thickness</label><input id="thickness" name="thickness" type="text" value="weight"/><br/>
88+
<label for="rel_caption">Caption</label><input id="rel_caption" name="rel_caption" type="text" value=""/>
89+
</div>
8790

8891

89-
<div><h3>Cypher query: </h3>
92+
<div><h3>Cypher query: </h3>
9093

91-
<textarea rows="4" cols=50 id="cypher">MATCH (n)-[r:INTERACTS]->(m) RETURN n,r,m</textarea><br>
94+
<textarea rows="4" cols=50 id="cypher">MATCH (n)-[r:INTERACTS]->(m) RETURN n,r,m</textarea><br>
9295

93-
<input type="submit" value="Submit" id="reload">
94-
<input type="submit" value="Stabilize" id="stabilize">
95-
</div>
96+
<input type="submit" value="Submit" id="reload">
97+
<input type="submit" value="Stabilize" id="stabilize">
98+
</div>
9699
</div>
97100
</body>
98101

99102
<script>
100-
$(document).ready(function() {
101-
draw();
103+
$(document).ready(function () {
104+
draw();
105+
})
106+
$("#reload").click(function () {
107+
draw();
108+
/*
109+
var cypher = $("#cypher").val();
110+
111+
if (cypher.length > 3) {
112+
viz.renderWithCypher(cypher);
113+
} else {
114+
console.log("reload");
115+
viz.reload();
116+
}
117+
*/
118+
});
119+
120+
$("#stabilize").click(function () {
121+
viz.stabilize();
102122
})
103-
$("#reload").click(function() {
104-
draw();
105-
/*
106-
var cypher = $("#cypher").val();
107-
108-
if (cypher.length > 3) {
109-
viz.renderWithCypher(cypher);
110-
} else {
111-
console.log("reload");
112-
viz.reload();
113-
}
114-
*/
115-
});
116-
117-
$("#stabilize").click(function() {
118-
viz.stabilize();
119-
})
120123

121124
</script>
122125
</html>

0 commit comments

Comments
 (0)