Changeset 100 for trunk

Show
Ignore:
Timestamp:
09/12/08 12:08:53 (4 years ago)
Author:
lgs
Message:

Allow the legend to be placed relative to the bottom or right edge. Patch by Nicolas

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/chart.py

    r99 r100  
    504504            return 
    505505 
     506        surfaceWidth = self.surface.get_width() 
     507        surfaceHeight = self.surface.get_height() 
     508 
     509        # Compute legend dimensions 
    506510        padding = 4 
    507511        bullet = 15 
     
    515519        width = padding + bullet + padding + width + padding 
    516520 
     521        # Compute legend position 
     522        legend = self.options.legend 
     523        if legend.position.right is not None: 
     524            legend.position.left = (surfaceWidth 
     525                                    - legend.position.right 
     526                                    - width) 
     527        if legend.position.bottom is not None: 
     528            legend.position.top = (surfaceHeight 
     529                                   - legend.position.bottom 
     530                                   - height) 
     531 
     532        # Draw the legend 
    517533        cx.save() 
    518534        cx.rectangle(self.options.legend.position.left, 
     
    615631        style={}, 
    616632        hide=False, 
    617         position=Option(top=20, left=40), 
     633        position=Option(top=20, left=40, bottom=None, right=None), 
    618634    ), 
    619635    padding=Option(