Logo Search packages:      
Sourcecode: hamster-applet version File versions

def hamster::charting::Chart::_get_factors (   self,
  data 
) [private]

get's max value out of data and calculates each record's factor
   against it

Definition at line 281 of file charting.py.

00281                                 :
        """get's max value out of data and calculates each record's factor
           against it"""
        max_value = 0
        self.there_are_floats = False
        self.there_are_colors = False
        self.there_are_backgrounds = False
        
        for i in range(len(data)):
            max_value = max(max_value, data[i][1])
            if isinstance(data[i][1], float):
                self.there_are_floats = True #we need to know for the scale labels
                
            if len(data[i]) > 3 and data[i][2] != None:
                self.there_are_colors = True
                
            if len(data[i]) > 4 and data[i][3] != None:
                self.there_are_backgrounds = True
                
        
        res = []
        for i in range(len(data)):
            factor = data[i][1] / float(max_value) if max_value > 0 else 0
            
            res.append({"label": data[i][0],
                        "value": data[i][1],
                        "color": data[i][2] if len(data[i]) > 2 else None,
                        "background": data[i][3] if len(data[i]) > 3 else None,
                        "factor": factor
                        })
        
        return res, max_value
    

    def _draw_bar(self, context, x, y, w, h, color):


Generated by  Doxygen 1.6.0   Back to index