'Lookup the fact label from the timeplot options of resource
@param resource: the resource (S3Resource)
@param method: the aggregation method (string)
@param base: the base field selector (string)
@param slope: the slope field selector (string)
@param interval: the interval expression (string)'

@classmethod
def lookup_label(cls, resource, method, base, slope=None, interval=None):

    fact_opts = None
    if resource:
        config = resource.get_config('timeplot_options')
        if config:
            fact_opts = config.get('fact')
    label = None
    if fact_opts:
        parse = cls.parse
        for opt in fact_opts:
            if isinstance(opt, tuple):
                (title, facts) = opt
            else:
                (title, facts) = (None, opt)
            facts = parse(facts)
            match = None
            for fact in facts:
                if ((fact.method == method) and (fact.base == base) and (fact.slope == slope) and (fact.interval == interval)):
                    match = fact
                    break
            if match:
                if fact.label:
                    label = fact.label
                elif (len(facts) == 1):
                    label = title
            if label:
                break
    return label
