Changeset 176 for trunk/pycha

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

Location:
trunk/pycha
Files:
2 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 
  • trunk/pycha/stackedbar.py

    r164 r176  
    5353        uniqx = uniqueIndices(stores) 
    5454 
    55         barWidth = 0 
    5655        if len(uniqx) == 1: 
    57             xdelta = 1.0 
    58             self.barWidth = 1.0 * self.options.barWidthFillFraction 
    59             self.barMargin = (1.0 - self.options.barWidthFillFraction) / 2 
     56            self.minxdelta = 1.0 
    6057        else: 
    61             xdelta = min([abs(uniqx[j] - uniqx[j-1]) 
    62                           for j in range(1, len(uniqx))]) 
    63             self.barWidth = (xdelta * self.xscale 
    64                              * self.options.barWidthFillFraction) 
    65             self.barMargin = (xdelta * self.xscale 
    66                               * (1.0 - self.options.barWidthFillFraction) / 2) 
     58            self.minxdelta = min([abs(uniqx[j] - uniqx[j-1]) 
     59                                  for j in range(1, len(uniqx))]) 
    6760 
    68         self.minxdelta = xdelta 
     61        k = self.minxdelta * self.xscale 
     62        self.barWidth = k * self.options.barWidthFillFraction 
     63        self.barMargin = k * (1.0 - self.options.barWidthFillFraction) / 2 
     64 
    6965        self.bars = [] 
    7066