OSDN Git Service

Improve network graph
authorSato Hiroyuki <sathiroyuki@gmail.com>
Wed, 23 Jan 2013 12:34:19 +0000 (21:34 +0900)
committerGitLab <gitlab@hiroponz.net>
Wed, 23 Jan 2013 12:39:29 +0000 (21:39 +0900)
lib/gitlab/graph/json_builder.rb
vendor/assets/javascripts/branch-graph.js

index 4a48b3b..a3157aa 100644 (file)
@@ -16,6 +16,7 @@ module Gitlab
 
         @commits = collect_commits
         @days = index_commits
+        @space = 0
       end
 
       def to_json(*args)
@@ -97,8 +98,8 @@ module Gitlab
         if leaves.empty?
           return
         end
-        space = find_free_space(leaves, map)
-        leaves.each{|l| l.space = space}
+        @space = find_free_space(leaves, map)
+        leaves.each{|l| l.space = @space}
         # and mark it as reserved
         min_time = leaves.last.time
         parents = leaves.last.parents.collect
@@ -115,7 +116,7 @@ module Gitlab
         else
           max_time = parent_time - 1
         end
-        mark_reserved(min_time..max_time, space)
+        mark_reserved(min_time..max_time, @space)
 
         # Visit branching chains
         leaves.each do |l|
@@ -139,9 +140,10 @@ module Gitlab
           reserved += @_reserved[day]
         end
         space = base_space(leaves, map)
-        while reserved.include? space do
+        while (reserved.include? space) || (space == @space) do
           space += 1
         end
+
         space
       end
 
index 805423b..af3b572 100644 (file)
           if (c.space == this.commits[i].space) {
             r.path([
               "M", x, y,
-              "L", x - 20 * (c.time + 1), y
+              "L", cx, cy
             ]).attr({
               stroke: this.colors[c.space], 
               "stroke-width": 2
@@ -351,4 +351,4 @@ function textWrap(t, width) {
   t.attr({
     "y": b.y + h
   });
-}
\ No newline at end of file
+}