diff --git a/pygit/chart.py b/pygit/chart.py
index 167a74a..9b51665 100644
--- a/pygit/chart.py
+++ b/pygit/chart.py
@@ -16,9 +16,11 @@ class Place(object):
self.y0 = y0
self.width = width
self.height = height
- self.x_ticks = None
+ self.scale_set = False
def set_scale(self,x_ticks,y_max):
+ if self.scale_set:
+ return
self.x_ticks = x_ticks
self.y_max = y_max
self.step_x = float(self.width)/x_ticks
@@ -50,6 +52,11 @@ class Chart(object):
place = Place(self.cx,pl,height-place_height*i-py, width-pl-pr, place_height-2*py)
self.places.append(place)
+ def set_scale(self,place,ticks_x,max_y):
+ self.places[place].set_scale(ticks_x,max_y)
+ self.places[place].scale_set = True
+
+
def draw(self,lst,color=(0.9,0.2,0.2),place=0):
pc = self.places[place]
pc.set_scale(len(lst)-1,max(lst))
diff --git a/pygit/pygit.py b/pygit/pygit.py
index 99fc512..38a5674 100644
--- a/pygit/pygit.py
+++ b/pygit/pygit.py
@@ -129,11 +129,13 @@ def group_by_date(lst):
def stats_sum(lst):
"[Commit] -> dict(lines=?, files=?)"
- r = {'lines': 0, 'files': 0}
+ r = {'lines': 0, 'files': 0,'insertions':0, 'deletions':0}
for cm in lst:
try:
r['lines'] += cm.stats.total['lines']
r['files'] += cm.stats.total['files']
+ r['insertions'] += cm.stats.total['insertions']
+ r['deletions'] += cm.stats.total['deletions']
except ValueError:
pass
return r
@@ -148,7 +150,9 @@ def commits_stats(rid,branch='master'):
stats = [stats_sum(g[1]) for g in grp]
files = [s['files'] for s in stats]
lines = [s['lines'] for s in stats]
- return dates,n_commits,files,lines
+ inss = [s['insertions'] for s in stats]
+ dels = [s['deletions'] for s in stats]
+ return dates,n_commits,files,lines,inss,dels
def commit_stats(rid,cid):
r = open_repo(rid)
diff --git a/pygit/views.py b/pygit/views.py
index 0c2dfa5..c127c36 100644
--- a/pygit/views.py
+++ b/pygit/views.py
@@ -34,11 +34,15 @@ def one_repo(request,rid,branch='master'):
tags = pygit.tags(rid)
cs = pygit.commits(rid,branch)
dirs,files = pygit.root_tree(rid,branch)
- dates,n_commits,files_s,lines = pygit.commits_stats(rid,branch)
+ dates,n_commits,files_s,lines,inss,dels = pygit.commits_stats(rid,branch)
cht = Chart(900,200,n=2)
+# cht.set_scale(0,len(n_commits)-1,max(max(n_commits),max(files_s)))
+ cht.set_scale(1,len(inss)-1,max(inss))
cht.draw(n_commits,place=0,color=(0.9,0.9,0.2))
- cht.draw(files_s,place=1,color=(0.2,0.2,0.9))
- cht.draw(lines,place=1,color=(0.2,0.9,0.2))
+ cht.draw(files_s,place=0,color=(0.3,0.3,0.3))
+ cht.draw(inss,place=1,color=(0.2,0.2,0.9))
+ cht.draw(dels,place=1,color=(0.9,0.2,0.2))
+# cht.draw(lines,place=1,color=(0.2,0.9,0.2))
cht.labels(dates)
chart = cht.finish()
return render_it('repo.html',