<s> """<STR_LIT>""" <EOL> import copy <EOL> import warnings <EOL> from mapreduce . lib . graphy import common <EOL> from mapreduce . lib . graphy import util <EOL> class BarsStyle ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , color ) : <EOL> self . color = color <EOL> class BarChartStyle ( object ) : <EOL> """<STR_LIT>""" <EOL> _DEFAULT_GROUP_GAP = <NUM_LIT:8> <EOL> _DEFAULT_BAR_GAP = <NUM_LIT:4> <EOL> def __init__ ( self , bar_thickness = None , <EOL> bar_gap = _DEFAULT_BAR_GAP , group_gap = _DEFAULT_GROUP_GAP , <EOL> use_fractional_gap_spacing = False ) : <EOL> """<STR_LIT>""" <EOL> self . bar_thickness = bar_thickness <EOL> self . bar_gap = bar_gap <EOL> self . group_gap = group_gap <EOL> self . use_fractional_gap_spacing = use_fractional_gap_spacing <EOL> class BarStyle ( BarChartStyle ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> warnings . warn ( '<STR_LIT>' , <EOL> DeprecationWarning , stacklevel = <NUM_LIT:2> ) <EOL> super ( BarStyle , self ) . __init__ ( * args , ** kwargs ) <EOL> class BarChart ( common . BaseChart ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , points = None ) : <EOL> """<STR_LIT>""" <EOL> super ( BarChart , self ) . __init__ ( ) <EOL> if points is not None : <EOL> self . AddBars ( points ) <EOL> self . vertical = True <EOL> self . stacked = False <EOL> self . style = BarChartStyle ( None , None , None ) <EOL> def AddBars ( self , points , label = None , color = None ) : <EOL> """<STR_LIT>""" <EOL> if label is not None and util . _IsColor ( label ) : <EOL> warnings . warn ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> DeprecationWarning , stacklevel = <NUM_LIT:2> ) <EOL> style = BarsStyle ( color ) <EOL> series = common . DataSeries ( points , label = label , style = style ) <EOL> self . data . append ( series ) <EOL> return series <EOL> def GetDependentAxes ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . vertical : <EOL> return ( self . _axes [ common . AxisPosition . LEFT ] + <EOL> self . _axes [ common . AxisPosition . RIGHT ] ) <EOL> else : <EOL> return ( self . _axes [ common . AxisPosition . TOP ] + <EOL> self . _axes [ common . AxisPosition . BOTTOM ] ) <EOL> def GetIndependentAxes ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . vertical : <EOL> return ( self . _axes [ common . AxisPosition . TOP ] + <EOL> self . _axes [ common . AxisPosition . BOTTOM ] ) <EOL> else : <EOL> return ( self . _axes [ common . AxisPosition . LEFT ] + <EOL> self . _axes [ common . AxisPosition . RIGHT ] ) <EOL> def GetDependentAxis ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . vertical : <EOL> return self . left <EOL> else : <EOL> return self . bottom <EOL> def GetIndependentAxis ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . vertical : <EOL> return self . bottom <EOL> else : <EOL> return self . left <EOL> def GetMinMaxValues ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . stacked : <EOL> return super ( BarChart , self ) . GetMinMaxValues ( ) <EOL> if not self . data : <EOL> return None , None <EOL> num_bars = max ( len ( series . data ) for series in self . data ) <EOL> positives = [ <NUM_LIT:0> for i in xrange ( <NUM_LIT:0> , num_bars ) ] <EOL> negatives = list ( positives ) <EOL> for series in self . data : <EOL> for i , point in enumerate ( series . data ) : <EOL> if point : <EOL> if point > <NUM_LIT:0> : <EOL> positives [ i ] += point <EOL> else : <EOL> negatives [ i ] += point <EOL> min_value = min ( min ( positives ) , min ( negatives ) ) <EOL> max_value = max ( max ( positives ) , max ( negatives ) ) <EOL> return min_value , max_value </s>
