1
- const graphElem = document . getElementById ( ' idea-graph' ) ;
1
+ const graphElem = document . getElementById ( " idea-graph" ) ;
2
2
const Graph = ForceGraph3D ( ) ( graphElem )
3
3
displayGraph ( ) ;
4
4
@@ -11,10 +11,11 @@ window.onclick = function (event) {
11
11
async function displayGraph ( ) {
12
12
let newData
13
13
try {
14
- newData = await getData ( )
14
+ newData = await getData ( ) ;
15
+ newData . nodes = newData . nodes . map ( node => ( { ...node , tags : new Set ( node . tags ) } ) ) ;
15
16
Graph . graphData ( newData )
16
- . nodeLabel ( ' name' )
17
- . onNodeHover ( node => graphElem . style . cursor = node ? ' pointer' : null )
17
+ . nodeLabel ( " name" )
18
+ . onNodeHover ( node => graphElem . style . cursor = node ? " pointer" : null )
18
19
. onNodeClick ( node => {
19
20
// Aim at node from outside it
20
21
const distance = 40 ;
@@ -44,10 +45,10 @@ function displayDetail(node) {
44
45
detailTags . textContent = [ ...node . tags ] . join ( ', ' ) ;
45
46
detailCreator . textContent = node . creator ;
46
47
detailDescription . textContent = node . description ;
47
-
48
- modal . style . top = event . pageY ;
49
- modal . style . left = event . pageX ;
50
- modal . style . display = ' block' ;
48
+
49
+ modal . style . top = event . pageY + "px" ;
50
+ modal . style . left = event . pageX + "px" ;
51
+ modal . style . display = " block" ;
51
52
}
52
53
53
54
function onAddItemClick ( ) {
@@ -86,7 +87,7 @@ function onModalSubmitClick(event, form) {
86
87
}
87
88
88
89
function onModalCloseClick ( modal ) {
89
- modal . parentElement . style . display = ' none' ;
90
+ modal . parentElement . style . display = " none" ;
90
91
}
91
92
92
93
function matchTags ( newIdea , nodes ) {
@@ -97,4 +98,5 @@ function matchTags(newIdea, nodes) {
97
98
newLinks = [ ...newLinks , { source : newIdea . id , target : idea . id } ]
98
99
}
99
100
}
101
+ return newLinks
100
102
}
0 commit comments