'return the legend'

def build_legend(self, barColors):

    if hasattr(self.legend, 'split'):
        self.legend = self.legend.split(',')
    legend = '<table    border=0    cellspacing=0    cellpadding=0><tr>'
    legend += (('<td    style="' + self.__cssLEGENDBG) + '">')
    legend += '<table    border=0    cellspacing=4    cellpadding=0>'
    i = 0
    for color in barColors:
        if (len(self.legend) >= (i + 1)):
            text = ((hasattr(self.legend[i], 'strip') and self.legend[i].strip()) or str(self.legend[i]))
        else:
            text = ''
        legend += '<tr>'
        legend += (('<td>' + self.build_bar('', self.barWidth, self.barWidth, color)) + '</td>')
        legend += (((('<td    style="' + self.__cssLEGEND) + '"    nowrap>') + text) + '</td>')
        legend += '</tr>'
        i += 1
    legend += '</table></td></tr></table>'
    return legend
