Browse Source

Fixed some bugs with Vertical Bar rendering

pull/8/head
jaraco 17 years ago
parent
commit
a70b0c5ec8
  1. 10
      lib/SVG/Bar.py
  2. 2
      lib/SVG/__init__.py

10
lib/SVG/Bar.py

@ -27,7 +27,7 @@ class Bar( Graph ):
# return max( map( lambda set: max( set['data'] ), self.data ) ) # return max( map( lambda set: max( set['data'] ), self.data ) )
def data_min( self ): def data_min( self ):
if not self.min_scale_value is None: return self.min_scale_value if not getattr(self, 'min_scale_value') is None: return self.min_scale_value
min_value = min( chain( *map( lambda set: set['data'], self.data ) ) ) min_value = min( chain( *map( lambda set: set['data'], self.data ) ) )
min_value = min( min_value, 0 ) min_value = min( min_value, 0 )
return min_value return min_value
@ -205,7 +205,7 @@ class VerticalBar( Bar ):
def draw_data( self ): def draw_data( self ):
min_value = self.data_min() min_value = self.data_min()
unit_size = (float(self.graph_height) - self.font_size*2*self.top_font) unit_size = (float(self.graph_height) - self.font_size*2*self.top_font)
unit_size /= ( max( self.get_y_labels() ) - min( self.get_y_labels() ) ) unit_size /= ( self.data_max() - self.data_min() )
bar_gap = 0 bar_gap = 0
if self.bar_gap: if self.bar_gap:
@ -232,11 +232,11 @@ class VerticalBar( Bar ):
# -ve -ve value.abs - 0 # -ve -ve value.abs - 0
value = dataset['data'][field_count] value = dataset['data'][field_count]
left = self.get_field_width() * self.field_count left = self.get_field_width() * field_count
length = ( abs(value) - max( min_value, 0 ) ) * unit_size length = ( abs(value) - max( min_value, 0 ) ) * unit_size
# top is 0 if value is negative # top is 0 if value is negative
top = bottom - (( min(value,0) - min_value ) * unit_size ) top = bottom - (( max(value,0) - min_value ) * unit_size )
if self.stack == 'side': if self.stack == 'side':
left += self.bar_width * dataset_count left += self.bar_width * dataset_count
@ -245,7 +245,7 @@ class VerticalBar( Bar ):
'y': str(top), 'y': str(top),
'width': str(bar_width), 'width': str(bar_width),
'height': str(length), 'height': str(length),
'class': 'fill%s' % dataset_count+1, 'class': 'fill%s' % (dataset_count+1),
} ) } )
self.graph.appendChild( rect ) self.graph.appendChild( rect )

2
lib/SVG/__init__.py

@ -74,7 +74,7 @@ Copyright © 2008 Jason R. Coombs
show_x_guidelines= False show_x_guidelines= False
show_y_guidelines= True show_y_guidelines= True
show_data_values= True show_data_values= True
min_scale_value= 0 min_scale_value= None
show_x_labels= True show_x_labels= True
stagger_x_labels= False stagger_x_labels= False
rotate_x_labels= False rotate_x_labels= False

Loading…
Cancel
Save