Changeset 77 for trunk

Show
Ignore:
Timestamp:
03/20/08 13:03:40 (4 years ago)
Author:
lgs
Message:

Do not end the line at the end of the graph area if that dataset have fewer points. Fixes #4

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/line.py

    r75 r77  
    4343        def preparePath(storeName): 
    4444            cx.new_path() 
    45             cx.move_to(self.area.x, self.area.y + self.area.h) 
     45            firstPoint = True 
     46            lastX = None 
     47            if self.options.shouldFill: 
     48                # Go to the (0,0) coordinate to start drawing the area 
     49                cx.move_to(self.area.x, self.area.y + self.area.h) 
     50 
    4651            for point in self.points: 
    4752                if point.name == storeName: 
     53                    if not self.options.shouldFill and firstPoint: 
     54                        # starts the first point of the line 
     55                        cx.move_to(point.x * self.area.w + self.area.x, 
     56                                   point.y * self.area.h + self.area.y) 
     57                        firstPoint = False 
     58                        continue 
    4859                    cx.line_to(point.x * self.area.w + self.area.x, 
    4960                               point.y * self.area.h + self.area.y) 
    50             cx.line_to(self.area.w + self.area.x, self.area.h + self.area.y) 
    51             cx.line_to(self.area.x, self.area.y + self.area.h) 
     61                    # we remember the last X coordinate to close the area 
     62                    # properly. See bug #4 
     63                    lastX = point.x 
    5264 
    5365            if self.options.shouldFill: 
     66                # Close the path to the start point 
     67                cx.line_to(lastX * self.area.w + self.area.x, 
     68                           self.area.h + self.area.y) 
     69                cx.line_to(self.area.x, self.area.y + self.area.h) 
    5470                cx.close_path() 
    5571            else: