File tree 1 file changed +22
-12
lines changed
packages/foam-vscode/static/dataviz
1 file changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ const initGUI = () => {
19
19
if ( ! nodeTypeFilterControllers . has ( type ) ) {
20
20
const ctrl = nodeTypeFilterFolder
21
21
. add ( m . showNodesOfType , type )
22
- . onFinishChange ( function ( ) {
22
+ . onFinishChange ( function ( ) {
23
23
Actions . updateFilters ( ) ;
24
24
} ) ;
25
25
ctrl . domElement . previousSibling . style . color = getNodeTypeColor (
@@ -249,23 +249,33 @@ function initDataviz(channel) {
249
249
}
250
250
251
251
function augmentGraphInfo ( graph ) {
252
+ const tagNodes = { } ;
252
253
Object . values ( graph . nodeInfo ) . forEach ( node => {
254
+ if ( node . type === 'tag' ) {
255
+ tagNodes [ node . title ] = node ;
256
+ }
253
257
node . neighbors = [ ] ;
254
258
node . links = [ ] ;
259
+ } ) ;
260
+ Object . values ( graph . nodeInfo ) . forEach ( node => {
255
261
if ( node . tags && node . tags . length > 0 ) {
256
262
node . tags . forEach ( tag => {
257
- const tagNode = {
258
- id : tag . label ,
259
- title : tag . label ,
260
- type : 'tag' ,
261
- properties : { } ,
262
- neighbors : [ ] ,
263
- links : [ ] ,
264
- } ;
265
- graph . nodeInfo [ tag . label ] = tagNode ;
263
+ let tagNode = tagNodes [ tag . label ] ;
264
+ if ( ! tagNode ) {
265
+ tagNode = {
266
+ id : tag . label ,
267
+ title : tag . label ,
268
+ type : 'tag' ,
269
+ properties : { } ,
270
+ neighbors : [ ] ,
271
+ links : [ ] ,
272
+ } ;
273
+ graph . nodeInfo [ tag . label ] = tagNode ;
274
+ tagNodes [ tag . label ] = tagNode ;
275
+ }
266
276
graph . links . push ( {
267
- source : tagNode . id ,
268
- target : node . id ,
277
+ source : node . id ,
278
+ target : tagNode . id ,
269
279
} ) ;
270
280
} ) ;
271
281
}
You can’t perform that action at this time.
0 commit comments