@@ -21,22 +21,39 @@ export class AppComponent {
2121 'undoManager.isEnabled' : true ,
2222 model : $ ( go . GraphLinksModel ,
2323 {
24+ linkToPortIdProperty : 'toPort' ,
25+ linkFromPortIdProperty : 'fromPort' ,
2426 linkKeyProperty : 'key' // IMPORTANT! must be defined for merges and data sync when using GraphLinksModel
2527 }
2628 )
2729 } ) ;
2830
31+ const makePort = function ( id : string , spot : go . Spot ) {
32+ return $ ( go . Shape , 'Circle' ,
33+ {
34+ opacity : .5 ,
35+ fill : 'gray' , strokeWidth : 0 , desiredSize : new go . Size ( 8 , 8 ) ,
36+ portId : id , alignment : spot ,
37+ fromLinkable : true , toLinkable : true
38+ }
39+ ) ;
40+ }
41+
2942 // define the Node template
3043 dia . nodeTemplate =
31- $ ( go . Node , 'Auto' ,
32- {
33- toLinkable : true , fromLinkable : true
34- } ,
35- $ ( go . Shape , 'RoundedRectangle' , { stroke : null } ,
36- new go . Binding ( 'fill' , 'color' )
44+ $ ( go . Node , 'Spot' ,
45+ $ ( go . Panel , 'Auto' ,
46+ $ ( go . Shape , 'RoundedRectangle' , { stroke : null } ,
47+ new go . Binding ( 'fill' , 'color' )
48+ ) ,
49+ $ ( go . TextBlock , { margin : 8 } ,
50+ new go . Binding ( 'text' , 'key' ) )
3751 ) ,
38- $ ( go . TextBlock , { margin : 8 } ,
39- new go . Binding ( 'text' , 'key' ) )
52+ // Ports
53+ makePort ( 't' , go . Spot . TopCenter ) ,
54+ makePort ( 'l' , go . Spot . Left ) ,
55+ makePort ( 'r' , go . Spot . Right ) ,
56+ makePort ( 'b' , go . Spot . BottomCenter )
4057 ) ;
4158
4259 return dia ;
@@ -49,11 +66,11 @@ export class AppComponent {
4966 { key : 'Delta' , color : 'pink' }
5067 ] ;
5168 public diagramLinkData : Array < go . ObjectData > = [
52- { key : - 1 , from : 'Alpha' , to : 'Beta' } ,
53- { key : - 2 , from : 'Alpha' , to : 'Gamma' } ,
69+ { key : - 1 , from : 'Alpha' , to : 'Beta' , fromPort : 'r' , toPort : '1' } ,
70+ { key : - 2 , from : 'Alpha' , to : 'Gamma' , fromPort : 'b' , toPort : 't' } ,
5471 { key : - 3 , from : 'Beta' , to : 'Beta' } ,
55- { key : - 4 , from : 'Gamma' , to : 'Delta' } ,
56- { key : - 5 , from : 'Delta' , to : 'Alpha' }
72+ { key : - 4 , from : 'Gamma' , to : 'Delta' , fromPort : 'r' , toPort : 'l' } ,
73+ { key : - 5 , from : 'Delta' , to : 'Alpha' , fromPort : 't' , toPort : 'r' }
5774 ] ;
5875 public diagramDivClassName : string = 'myDiagramDiv' ;
5976 public diagramModelData = { prop : 'value' } ;
0 commit comments