Skip to content

Commit df170e9

Browse files
committed
Generating javascript can now handle missing graphdirection.
1 parent 7831f6a commit df170e9

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/commands/dgmlViewer.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,21 @@ export class DgmlViewer {
116116
}
117117

118118
private convertGraphDirectionToVisLayoutValues(directedGraph: IDirectedGraph): string {
119-
let direction: string = 'LR';
120-
switch(directedGraph.graphDirection.toLowerCase()) {
121-
case 'lefttoright': direction = 'LR'; break;
122-
case 'righttoleft': direction = 'RL'; break;
123-
case 'toptobottom': direction = 'UD'; break;
124-
case 'bottomtotop': direction = 'DU'; break;
125-
default: direction = 'LR'; break;
119+
let direction: string = '';
120+
if (directedGraph.graphDirection !== undefined) {
121+
switch (directedGraph.graphDirection.toLowerCase()) {
122+
case 'lefttoright': direction = 'LR'; break;
123+
case 'righttoleft': direction = 'RL'; break;
124+
case 'toptobottom': direction = 'UD'; break;
125+
case 'bottomtotop': direction = 'DU'; break;
126+
default: direction = 'LR'; break;
127+
}
126128
}
127129
return direction;
128-
}
130+
}
129131

130132
private getDirectedGraphLayoutJs(directedGraph: IDirectedGraph): string {
131-
if(directedGraph.graphDirection !== undefined) {
133+
if (directedGraph.graphDirection !== undefined) {
132134
let direction: string = this.convertGraphDirectionToVisLayoutValues(directedGraph);
133135
return `hierarchical: {enabled: true, direction: '${direction}', sortMethod: 'hubsize' }`;
134136
}

0 commit comments

Comments
 (0)