

@staticmethod
def normalize_series_by_unit(series):
    "Transform series' values into a more human readable form:\n        1) Determine the data point with the maximum value\n        2) Decide the unit appropriate for this value (normalize it)\n        3) Convert other values to this new unit, if necessary\n        "
    if (not series):
        return series
    source_unit = target_unit = series[0]['unit']
    if (not units.is_supported(source_unit)):
        return series
    maximum = max([d['y'] for point in series for d in point['data']])
    unit = units.normalize(maximum, source_unit)[1]
    if units.is_larger(unit, target_unit):
        target_unit = unit
        for (i, point) in enumerate(series[:]):
            if (point['unit'] != target_unit):
                series[i]['unit'] = target_unit
                for (j, d) in enumerate(point['data'][:]):
                    series[i]['data'][j]['y'] = units.convert(d['y'], source_unit, target_unit, fmt=True)[0]
    return series

dataset/ETHPy150Open CiscoSystems/avos/openstack_dashboard/dashboards/admin/metering/views.py SamplesView.normalize_series_by_unit/original