'return bar color for each level'

def level_color(self, value, color):

    if self.barLevelColors:
        for i in range(0, len(self.barLevelColors), 2):
            try:
                if (((self.barLevelColors[i] > 0) and (value >= self.barLevelColors[i])) or ((self.barLevelColors[i] < 0) and (value <= self.barLevelColors[i]))):
                    color = self.barLevelColors[(i + 1)]
            except IndexError:
                pass
    return color
