Changeset 127 for trunk

Show
Ignore:
Timestamp:
10/29/08 16:27:49 (4 years ago)
Author:
lgs
Message:

Add svg support by changing the way we compute the surface dimensions

Location:
trunk
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/chart.py

    r111 r127  
    7272        self.options.merge(options) 
    7373 
     74    def getSurfaceSize(self): 
     75        cx = cairo.Context(self.surface) 
     76        x, y, w, h = cx.clip_extents() 
     77        return w, h 
     78 
    7479    def reset(self): 
    7580        """Resets options and datasets. 
     
    178183 
    179184        # calculate area data 
    180         width = (self.surface.get_width() 
     185        surface_width, surface_height = self.getSurfaceSize() 
     186        width = (surface_width 
    181187                 - self.options.padding.left - self.options.padding.right) 
    182         height = (self.surface.get_height() 
     188        height = (surface_height 
    183189                  - self.options.padding.top - self.options.padding.bottom) 
    184190 
     
    507513            return 
    508514 
    509         surfaceWidth = self.surface.get_width() 
    510         surfaceHeight = self.surface.get_height() 
     515        surface_width, surface_height = self.getSurfaceSize() 
    511516 
    512517        # Compute legend dimensions 
     
    525530        legend = self.options.legend 
    526531        if legend.position.right is not None: 
    527             legend.position.left = (surfaceWidth 
     532            legend.position.left = (surface_width 
    528533                                    - legend.position.right 
    529534                                    - width) 
    530535        if legend.position.bottom is not None: 
    531             legend.position.top = (surfaceHeight 
     536            legend.position.top = (surface_height 
    532537                                   - legend.position.bottom 
    533538                                   - height)