Skip to content

Commit

Permalink
Merge pull request #55 from moul/dev/moul/compact-graphs
Browse files Browse the repository at this point in the history
feat: make the generated graph more compact
  • Loading branch information
moul authored Sep 20, 2018
2 parents 4097ce4 + 976e2fa commit 855c3a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
27 changes: 16 additions & 11 deletions graphviz.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ func graphviz(issues Issues, opts *runOptions) (string, error) {
panicIfErr(g.SetName("G"))
attrs := map[string]string{}
attrs["truecolor"] = "true"
attrs["overlap"] = "false"
attrs["overlap"] = "compress"
attrs["sep"] = "-0.7"
attrs["compound"] = "true"
attrs["splines"] = "true"
attrs["rankdir"] = "RL"
attrs["ranksep"] = "0.3"
Expand Down Expand Up @@ -79,7 +81,7 @@ func graphviz(issues Issues, opts *runOptions) (string, error) {
if issue.Hidden {
continue
}
parent := fmt.Sprintf("anon%d", issue.Weight())
parent := fmt.Sprintf("cluster_weight_%d", issue.Weight())
if issue.IsOrphan || !issue.LinkedWithEpic {
if len(issue.DependsOn) > 0 || len(issue.Blocks) > 0 {
parent = "cluster_orphans_with_links"
Expand Down Expand Up @@ -149,7 +151,10 @@ func graphviz(issues Issues, opts *runOptions) (string, error) {
}
}
if hasOrphansWithLinks {
panicIfErr(g.AddSubGraph("G", "cluster_orphans_with_links", map[string]string{"label": escape("orphans with links"), "style": "dashed"}))
attrs := map[string]string{}
attrs["label"] = escape("orphans with links")
attrs["style"] = "dashed"
panicIfErr(g.AddSubGraph("G", "cluster_orphans_with_links", attrs))
stats["subgraphs"]++

panicIfErr(g.AddNode("cluster_orphans_with_links", "placeholder_orphans_with_links", invisStyle))
Expand All @@ -166,19 +171,19 @@ func graphviz(issues Issues, opts *runOptions) (string, error) {

// set weights clusters and placeholders
for _, weight := range weights {
clusterName := fmt.Sprintf("anon%d", weight)
panicIfErr(g.AddSubGraph("G", clusterName, map[string]string{"rank": "same"}))
clusterName := fmt.Sprintf("cluster_weight_%d", weight)
attrs := invisStyle
attrs["rank"] = "same"
panicIfErr(g.AddSubGraph("G", clusterName, attrs))
stats["subgraphs"]++

//clusterName := fmt.Sprintf("cluster_w%d", weight)
//panicIfErr(g.AddSubGraph("G", clusterName, map[string]string{"label": fmt.Sprintf("w%d", weight)}))
attrs = invisStyle
attrs["shape"] = "none"
attrs["label"] = fmt.Sprintf(`"weight=%d"`, weight)
panicIfErr(g.AddNode(
clusterName,
fmt.Sprintf("placeholder_%d", weight),
map[string]string{
"shape": "none",
"label": fmt.Sprintf(`"weight=%d"`, weight),
},
attrs,
))
stats["nodes"]++
}
Expand Down
2 changes: 1 addition & 1 deletion issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func (issues Issues) prepare() error {
blocksRegex, _ = regexp.Compile(`(?i)(blocks|block|address|addresses|part of|child of|fix|fixes) ([a-z0-9:/_.-]+issues/[0-9]+|[a-z0-9:/_.-]+#[0-9]+|[a-z0-9/_-]*#[0-9]+)`)
isDuplicateRegex, _ = regexp.Compile(`(?i)(duplicates|duplicate|dup of|dup|duplicate of) ([a-z0-9:/_.-]+issues/[0-9]+|[a-z0-9:/_.-]+#[0-9]+|[a-z0-9/_-]*#[0-9]+)`)
weightMultiplierRegex, _ = regexp.Compile(`(?i)(depviz.weight_multiplier[:= ]+)([0-9]+)`)
baseWeightRegex, _ = regexp.Compile(`(?i)(depviz.base_weight[:= ]+)([0-9]+)`)
baseWeightRegex, _ = regexp.Compile(`(?i)(depviz.base_weight|depviz.weight)[:= ]+([0-9]+)`)
hideFromRoadmapRegex, _ = regexp.Compile(`(?i)(depviz.hide)`) // FIXME: use label
)

Expand Down

0 comments on commit 855c3a6

Please sign in to comment.