diff --git a/pygit/chart.py b/pygit/chart.py
index 855defd..9056317 100644
--- a/pygit/chart.py
+++ b/pygit/chart.py
@@ -17,6 +17,7 @@ class Place(object):
self.width = width
self.height = height
self.scale_set = False
+ self.dg = []
def set_scale(self,x_ticks,y_max):
if self.scale_set:
@@ -42,20 +43,19 @@ class Chart(object):
self.height = height
self.surf = cairo.ImageSurface(cairo.FORMAT_ARGB32,width,height)
self.cx = cairo.Context(self.surf)
- place_height = float(self.height)/n
+ self.place_height = float(self.height)/n
self.places = []
self.cx.set_source_rgb(1,1,1)
self.cx.rectangle(0,0,width,height)
self.cx.fill()
for i in range(n):
- place = Place(self.cx,pl,height-place_height*i-py, width-pl-pr, place_height-2*py)
+ place = Place(self.cx,pl,height-self.place_height*i-py, width-pl-pr, self.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))
@@ -65,6 +65,7 @@ class Chart(object):
for i in range(len(lst)):
pc.line_to(i,lst[i])
pc.cx.stroke()
+ pc.dg.append((color,pc.y_max))
def labels(self,lst):
step_x = float(self.width-pl-pr)/(len(lst)-1)
@@ -82,6 +83,21 @@ class Chart(object):
cur_x += step_x
cur_x = pl
self.cx.set_source_rgb(0.2,0.2,0.2)
+ for i in range(len(self.places)):
+ place = self.places[i]
+ if place.scale_set:
+ self.cx.move_to(self.width-pr+5,self.height-(i+1)*self.place_height+py)
+ self.cx.show_text(str(place.y_max))
+ else:
+ cur_y = self.height-(i+1)*self.place_height+py
+ for j in range(len(place.dg)):
+ color,y_max = place.dg[j]
+ self.cx.set_source_rgb(*color)
+ self.cx.move_to(self.width-pr+5,cur_y)
+ self.cx.show_text(str(y_max))
+ cur_y += 15
+
+ self.cx.set_source_rgb(0.2,0.2,0.2)
for i in range(len(lst)):
label = lst[i]
self.cx.move_to(cur_x, int(self.height-py/2))