Merge pull request #3288 from hiroponz/fix-style-network-graph
Fix style of network graph.
This commit is contained in:
commit
235605fc6d
1 changed files with 51 additions and 50 deletions
|
@ -51,21 +51,21 @@ class BranchGraph
|
||||||
buildGraph: ->
|
buildGraph: ->
|
||||||
graphHeight = $(@element).height()
|
graphHeight = $(@element).height()
|
||||||
graphWidth = $(@element).width()
|
graphWidth = $(@element).width()
|
||||||
ch = Math.max(graphHeight, @unitTime * @mtime + 100)
|
ch = Math.max(graphHeight, @offsetY + @unitTime * @mtime + 150)
|
||||||
cw = Math.max(graphWidth, @unitSpace * @mspace + 260)
|
cw = Math.max(graphWidth, @offsetX + @unitSpace * @mspace + 300)
|
||||||
@r = r = Raphael(@element.get(0), cw, ch)
|
@r = r = Raphael(@element.get(0), cw, ch)
|
||||||
top = r.set()
|
top = r.set()
|
||||||
cuday = 0
|
cuday = 0
|
||||||
cumonth = ""
|
cumonth = ""
|
||||||
barHeight = Math.max(graphHeight, @unitTime * @days.length + 320)
|
barHeight = Math.max(graphHeight, @unitTime * @days.length + 320)
|
||||||
|
|
||||||
r.rect(0, 0, 20, barHeight).attr fill: "#222"
|
r.rect(0, 0, 26, barHeight).attr fill: "#222"
|
||||||
r.rect(20, 0, 20, barHeight).attr fill: "#444"
|
r.rect(26, 0, 20, barHeight).attr fill: "#444"
|
||||||
|
|
||||||
for day, mm in @days
|
for day, mm in @days
|
||||||
if cuday isnt day[0]
|
if cuday isnt day[0]
|
||||||
# Dates
|
# Dates
|
||||||
r.text(30, @offsetY + @unitTime * mm, day[0])
|
r.text(36, @offsetY + @unitTime * mm, day[0])
|
||||||
.attr(
|
.attr(
|
||||||
font: "12px Monaco, monospace"
|
font: "12px Monaco, monospace"
|
||||||
fill: "#DDD"
|
fill: "#DDD"
|
||||||
|
@ -74,7 +74,7 @@ class BranchGraph
|
||||||
|
|
||||||
if cumonth isnt day[1]
|
if cumonth isnt day[1]
|
||||||
# Months
|
# Months
|
||||||
r.text(10, @offsetY + @unitTime * mm, day[1])
|
r.text(13, @offsetY + @unitTime * mm, day[1])
|
||||||
.attr(
|
.attr(
|
||||||
font: "12px Monaco, monospace"
|
font: "12px Monaco, monospace"
|
||||||
fill: "#EEE"
|
fill: "#EEE"
|
||||||
|
@ -191,56 +191,57 @@ class BranchGraph
|
||||||
|
|
||||||
drawLines: (x, y, commit) ->
|
drawLines: (x, y, commit) ->
|
||||||
r = @r
|
r = @r
|
||||||
for parent in commit.parents
|
for parent, i in commit.parents
|
||||||
parentCommit = @preparedCommits[parent[0]]
|
parentCommit = @preparedCommits[parent[0]]
|
||||||
parentY = @offsetY + @unitTime * parentCommit.time
|
parentY = @offsetY + @unitTime * parentCommit.time
|
||||||
parentX1 = @offsetX + @unitSpace * (@mspace - parentCommit.space)
|
parentX1 = @offsetX + @unitSpace * (@mspace - parentCommit.space)
|
||||||
parentX2 = @offsetX + @unitSpace * (@mspace - parent[1])
|
parentX2 = @offsetX + @unitSpace * (@mspace - parent[1])
|
||||||
|
|
||||||
if parentCommit.space is commit.space and parentCommit.space is parent[1]
|
# Set line color
|
||||||
r.path(["M", x, y, "L", parentX1, parentY]).attr(
|
if parentCommit.space <= commit.space
|
||||||
stroke: @colors[parentCommit.space]
|
color = @colors[commit.space]
|
||||||
"stroke-width": 2
|
|
||||||
|
else
|
||||||
|
color = @colors[parentCommit.space]
|
||||||
|
|
||||||
|
# Build line shape
|
||||||
|
if parent[1] is commit.space
|
||||||
|
d1 = [0, 5]
|
||||||
|
d2 = [0, 10]
|
||||||
|
arrow = "l-2,5,4,0,-2,-5"
|
||||||
|
|
||||||
|
else if parent[1] < commit.space
|
||||||
|
d1 = [3, 3]
|
||||||
|
d2 = [7, 5]
|
||||||
|
arrow = "l5,0,-2,4,-3,-4"
|
||||||
|
|
||||||
|
else
|
||||||
|
d1 = [-3, 3]
|
||||||
|
d2 = [-7, 5]
|
||||||
|
arrow = "l-5,0,2,4,3,-4"
|
||||||
|
|
||||||
|
# Start point
|
||||||
|
route = ["M", x + d1[0], y + d1[1]]
|
||||||
|
|
||||||
|
# Add arrow if not first parent
|
||||||
|
if i > 0
|
||||||
|
route.push(arrow)
|
||||||
|
|
||||||
|
# Circumvent if overlap
|
||||||
|
if commit.space isnt parentCommit.space or commit.space isnt parent[1]
|
||||||
|
route.push(
|
||||||
|
"L", x + d2[0], y + d2[1],
|
||||||
|
"L", parentX2, y + 10,
|
||||||
|
"L", parentX2, parentY - 5,
|
||||||
)
|
)
|
||||||
|
|
||||||
else if parentCommit.space < commit.space
|
# End point
|
||||||
if x is parentX2
|
route.push("L", parentX1, parentY)
|
||||||
r
|
|
||||||
.path([
|
|
||||||
"M", x, y + 5,
|
|
||||||
"l-2,5,4,0,-2,-5",
|
|
||||||
"L", x, y + 10,
|
|
||||||
"L", parentX2, y + 10,
|
|
||||||
"L", parentX2, parentY - 5,
|
|
||||||
"L", parentX1, parentY])
|
|
||||||
.attr(
|
|
||||||
stroke: @colors[commit.space]
|
|
||||||
"stroke-width": 2)
|
|
||||||
|
|
||||||
else
|
|
||||||
r
|
r
|
||||||
.path([
|
.path(route)
|
||||||
"M", x + 3, y + 3,
|
|
||||||
"l5,0,-2,4,-3,-4",
|
|
||||||
"L", x + 7, y + 5,
|
|
||||||
"L", parentX2, y + 10,
|
|
||||||
"L", parentX2, parentY - 5,
|
|
||||||
"L", parentX1, parentY])
|
|
||||||
.attr(
|
.attr(
|
||||||
stroke: @colors[commit.space]
|
stroke: color
|
||||||
"stroke-width": 2)
|
|
||||||
|
|
||||||
else
|
|
||||||
r
|
|
||||||
.path([
|
|
||||||
"M", x - 3, y + 3,
|
|
||||||
"l-5,0,2,4,3,-4",
|
|
||||||
"L", x - 7, y + 5,
|
|
||||||
"L", parentX2, y + 10,
|
|
||||||
"L", parentX2, parentY - 5,
|
|
||||||
"L", parentX1, parentY])
|
|
||||||
.attr(
|
|
||||||
stroke: @colors[parentCommit.space]
|
|
||||||
"stroke-width": 2)
|
"stroke-width": 2)
|
||||||
|
|
||||||
markCommit: (x, y, commit, graphHeight) ->
|
markCommit: (x, y, commit, graphHeight) ->
|
||||||
|
|
Loading…
Reference in a new issue