Change 'vertical' argument to a more generic 'layout', fix api

This commit is contained in:
jolo
2017-01-16 22:13:01 +01:00
parent 0e8ea6363a
commit 91561b40f6
3 changed files with 18 additions and 20 deletions
+11 -9
View File
@@ -7,7 +7,7 @@ import (
)
// BuildGraph generates graph contents from aptly object database
func BuildGraph(collectionFactory *CollectionFactory, vertical bool) (gographviz.Interface, error) {
func BuildGraph(collectionFactory *CollectionFactory, layout string) (gographviz.Interface, error) {
var err error
graph := gographviz.NewEscape()
@@ -17,14 +17,16 @@ func BuildGraph(collectionFactory *CollectionFactory, vertical bool) (gographviz
var labelStart string
var labelEnd string
if vertical {
graph.AddAttr("aptly", "rankdir", "LR")
labelStart = ""
labelEnd = ""
} else {
graph.AddAttr("aptly", "rankdir", "TB")
labelStart = "{"
labelEnd = "}"
switch layout {
case "vertical":
graph.AddAttr("aptly", "rankdir", "LR")
labelStart = ""
labelEnd = ""
case "horizontal":
fallthrough
default:
labelStart = "{"
labelEnd = "}"
}
existingNodes := map[string]bool{}