Changeset 139 for trunk/pycha

Show
Ignore:
Timestamp:
01/31/09 03:07:13 (3 years ago)
Author:
lgs
Message:

Index the ticks by xval and not name. This fixes a broken example

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pycha/pie.py

    r110 r139  
    6060        self.xticks = [] 
    6161        if self.options.axis.x.ticks: 
    62             lookup = dict([(slice.name, slice) for slice in self.slices]) 
     62            lookup = dict([(slice.xval, slice) for slice in self.slices]) 
    6363            for tick in self.options.axis.x.ticks: 
    6464                if not isinstance(tick, Option): 
    6565                    tick = Option(tick) 
    66                 slice = lookup[tick.v] 
     66                slice = lookup.get(tick.v, None) 
    6767                label = tick.label or str(tick.v) 
    68                 if slice: 
     68                if slice is not None: 
    6969                    label += ' (%.1f%%)' % (slice.fraction * 100) 
    7070                    self.xticks.append((tick.v, label)) 
     
    7272            for slice in self.slices: 
    7373                label = '%s (%.1f%%)' % (slice.name, slice.fraction * 100) 
    74                 self.xticks.append((slice.name, label)) 
     74                self.xticks.append((slice.xval, label)) 
    7575 
    7676    def _renderBackground(self, cx): 
     
    130130 
    131131        self.xlabels = [] 
    132         lookup = dict([(slice.name, slice) for slice in self.slices]) 
     132        lookup = dict([(slice.xval, slice) for slice in self.slices]) 
    133133 
    134134        cx.set_source_rgb(*hex2rgb(self.options.axis.labelColor))