Changeset 176 for trunk/pycha/bar.py

Show
Ignore:
Timestamp:
03/22/09 03:38:17 (3 years ago)
Author:
lgs
Message:

Fix in the computation of the bar width when there is just one data point and a custom range. Fixes #20

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pycha/bar.py

    r169 r176  
    4040        uniqx = uniqueIndices(stores) 
    4141 
    42         barWidth = 0 
    4342        if len(uniqx) == 1: 
    44             xdelta = 1.0 
    45             barWidth = 1.0 * self.options.barWidthFillFraction 
    46             self.barWidthForSet = barWidth / len(stores) 
    47             self.barMargin = (1.0 - self.options.barWidthFillFraction) / 2 
     43            self.minxdelta = 1.0 
    4844        else: 
    49             xdelta = min([abs(uniqx[j] - uniqx[j-1]) 
    50                           for j in range(1, len(uniqx))]) 
    51             barWidth = xdelta * self.xscale * self.options.barWidthFillFraction 
    52             self.barWidthForSet = barWidth / len(stores) 
    53             self.barMargin = (xdelta * self.xscale 
    54                               * (1.0 - self.options.barWidthFillFraction) / 2) 
    55  
    56         self.minxdelta = xdelta 
     45            self.minxdelta = min([abs(uniqx[j] - uniqx[j-1]) 
     46                                  for j in range(1, len(uniqx))]) 
     47 
     48        k = self.minxdelta * self.xscale 
     49        barWidth = k * self.options.barWidthFillFraction 
     50        self.barWidthForSet = barWidth / len(stores) 
     51        self.barMargin = k * (1.0 - self.options.barWidthFillFraction) / 2 
     52 
    5753        self.bars = [] 
    5854