@@ -11,6 +11,9 @@ window.Widgets.Panel.Utils = {};
11
11
constructor ( ) {
12
12
this . t = new Map ( ) ;
13
13
}
14
+ getEdge ( node1 ) {
15
+ return this . t . get ( node1 ) ;
16
+ }
14
17
addEdge ( node1 , node2 ) {
15
18
const s = this . t . get ( node1 ) ;
16
19
if ( s == null ) {
@@ -95,6 +98,7 @@ window.Widgets.Panel.Utils = {};
95
98
nodeStrength : - 100 ,
96
99
centreStrength : 80 ,
97
100
promoSim : true ,
101
+ scratchSim : true ,
98
102
theme : 'light' ,
99
103
light_theme : {
100
104
treeFill : 'white' ,
@@ -146,25 +150,6 @@ window.Widgets.Panel.Utils = {};
146
150
ns . contentMenuItem = false ;
147
151
148
152
149
- // 1. Instantiate Visualisation Variables
150
- // 3. Setup RMB Menu Items
151
- // ns.menuItems = [
152
- // {
153
- // title: 'Copy Object',
154
- // action: (d) => {
155
- // // TODO: add any action you want to perform
156
- // console.log('Copy Object', d);
157
- // },
158
- // },
159
- // {
160
- // title: 'Create Relationship',
161
- // action: (d) => {
162
- // // TODO: add any action you want to perform
163
- // console.log('Create Relationship ->', d);
164
- // },
165
- // },
166
- // ];
167
-
168
153
// setup the left click capability
169
154
ns . selectArray = [ ] ;
170
155
ns . leftclick = function ( event , d ) {
@@ -516,7 +501,7 @@ window.Widgets.Panel.Utils = {};
516
501
517
502
// B. Update Data, Simulations and Drive Show Graph
518
503
ns . processGraphData = function ( graphData ) {
519
- console . group ( 'Widgets.Panel.Utils.updateGraph' ) ;
504
+ console . groupCollapsed ( 'Widgets.Panel.Utils.updateGraph' ) ;
520
505
// console.log('graphData->', graphData);
521
506
522
507
let nodes = graphData . nodes ;
@@ -606,7 +591,9 @@ window.Widgets.Panel.Utils = {};
606
591
let centreX = dummywidth / 2 // ns.options.width/2; this is NaN
607
592
// 4. Setup layout
608
593
let j = - 1 ;
594
+ var nodeRef = { } ;
609
595
nodes . forEach ( function ( node ) {
596
+ nodeRef [ node . id ] = node ;
610
597
let annotate = { } ;
611
598
annotate . connections = [ ] ;
612
599
annotate . promo_IDs = [ ] ;
@@ -691,15 +678,10 @@ window.Widgets.Panel.Utils = {};
691
678
}
692
679
} ) ;
693
680
694
- console . log ( 'annotate list->' , ns . split . promo_annotate_list )
695
-
696
681
ns . split . promo_IDs = Array . from (
697
682
ns . split . adjacency . dirs ( ns . split . promo_nodes_IDs ) ,
698
683
( path ) => path . at ( - 1 ) ,
699
684
) ;
700
- // console.log('ns.split.promo_nodes_IDs->', ns.split.promo_nodes_IDs);
701
- // console.log('ns.split.promo_IDs->', ns.split.promo_IDs);
702
-
703
685
704
686
// 4. Now split the Graphs and update the
705
687
nodes . forEach ( function ( node ) {
@@ -712,7 +694,6 @@ window.Widgets.Panel.Utils = {};
712
694
ns . split . scratch . nodes . push ( node ) ;
713
695
}
714
696
} ) ;
715
- console . log ( 'ns.split.promo.nodes->' , ns . split . promo . nodes )
716
697
717
698
edges . forEach ( function ( edge ) {
718
699
if (
@@ -722,6 +703,17 @@ window.Widgets.Panel.Utils = {};
722
703
ns . split . promo . edges . push ( edge ) ;
723
704
} else {
724
705
ns . split . scratch . edges . push ( edge ) ;
706
+ //TODO: find out why edges for sratch do not get mapped to object
707
+ const edge_source = edge . source ;
708
+ const edge_target = edge . target ;
709
+
710
+ //if string try to find in nodeRef
711
+ if ( typeof edge_source === 'string' ) {
712
+ edge . source = nodeRef [ edge_source ] ;
713
+ }
714
+ if ( typeof edge_target === 'string' ) {
715
+ edge . target = nodeRef [ edge_target ] ;
716
+ }
725
717
}
726
718
} ) ;
727
719
0 commit comments