def compute_data_and_classes(values, data_filter=None):
    """
    Returns a list of dict in the form [{'value': val, 'class': 'success']]
    :param values: Values to process. Min and max are assigned corresponding classes.
    :param data_filter: If not None, applied on all values before output
    :return: processed array of dict
    """
    output_values = []
    values = [v if v is not None else 0 for v in values]
    max_value = max(values)
    min_value = min(values)

    for idx, value in enumerate(values):
        val = {}
        if value == min_value and value != max_value:
            val['class'] = 'danger'
        elif value == max_value and value != min_value:
            val['class'] = 'success'
        else:
            val['class'] = ''

        val['value'] = data_filter(value) if data_filter else value

        output_values.append(val)

    return output_values