@@ -23,33 +23,35 @@ export class Node {
23
23
public attributes : Attribute [ ] ;
24
24
25
25
public toJsonString ( ) : string {
26
- let nodeShapeAttr = '' ;
26
+ const jsStringProperties : string [ ] = [ ] ;
27
+ jsStringProperties . push ( `id: "${ this . id } "` ) ;
28
+ const label = this . config . maximumNodeLabelLength !== - 1 && this . name . length > this . config . maximumNodeLabelLength ? this . name . substr ( 0 , this . config . maximumNodeLabelLength ) + '...' : this . name ;
29
+ jsStringProperties . push ( `label: "${ label } "` ) ;
30
+ jsStringProperties . push ( `color: "${ this . getNodeTypeColor ( this . nodeType ) } "` ) ;
27
31
switch ( this . nodeType ) {
28
32
case NodeType . rootNode :
29
- nodeShapeAttr = `, shape: "${ this . config . rootNodeShape } "`;
33
+ jsStringProperties . push ( ` shape: "${ this . config . rootNodeShape } "`) ;
30
34
break ;
31
35
case NodeType . component :
32
- nodeShapeAttr = `, shape: "${ this . config . componentNodeShape } "`;
36
+ jsStringProperties . push ( ` shape: "${ this . config . componentNodeShape } "`) ;
33
37
break ;
34
38
case NodeType . module :
35
- nodeShapeAttr = `, shape: "${ this . config . moduleNodeShape } "`;
39
+ jsStringProperties . push ( ` shape: "${ this . config . moduleNodeShape } "`) ;
36
40
break ;
37
41
case NodeType . pipe :
38
- nodeShapeAttr = `, shape: "${ this . config . pipeNodeShape } "`;
42
+ jsStringProperties . push ( ` shape: "${ this . config . pipeNodeShape } "`) ;
39
43
break ;
40
44
case NodeType . directive :
41
- nodeShapeAttr = `, shape: "${ this . config . directiveNodeShape } "`;
45
+ jsStringProperties . push ( ` shape: "${ this . config . directiveNodeShape } "`) ;
42
46
break ;
43
47
case NodeType . injectable :
44
- nodeShapeAttr = `, shape: "${ this . config . injectableNodeShape } "`;
48
+ jsStringProperties . push ( ` shape: "${ this . config . injectableNodeShape } "`) ;
45
49
break ;
46
50
default :
47
- nodeShapeAttr = '' ;
48
51
break ;
49
52
}
50
- const nodeColorAttr = `, color: "${ this . getNodeTypeColor ( this . nodeType ) } "` ;
51
- const label = this . config . maximumNodeLabelLength !== - 1 && this . name . length > this . config . maximumNodeLabelLength ? this . name . substr ( 0 , this . config . maximumNodeLabelLength ) + '...' : this . name ;
52
- return `{id: "${ this . id } ", label: "${ label } "${ nodeColorAttr } ${ nodeShapeAttr } }` ;
53
+ if ( this . position !== undefined && this . position . x !== undefined && this . position . y !== undefined ) { jsStringProperties . push ( `x: ${ this . position . x } , y: ${ this . position . y } , fixed: { x: true, y: true}` ) ; }
54
+ return `{ ${ jsStringProperties . join ( ', ' ) } }` ;
53
55
}
54
56
55
57
public toGraphViz ( ) : string {
0 commit comments