Add more columns to DPS graphs
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import math
|
||||
|
||||
|
||||
def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=False):
|
||||
def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=False, unitName=None):
|
||||
"""
|
||||
Add suffix to value, transform value to match new suffix and round it.
|
||||
|
||||
@@ -12,6 +12,7 @@ def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=Fal
|
||||
highest -- highest order for suffixizing for numbers |num| > 1
|
||||
currency -- if currency, billion suffix will be B instead of G
|
||||
forceSign -- if True, positive numbers are signed too
|
||||
unitName -- if specified, will be formatted into a string
|
||||
"""
|
||||
if val is None:
|
||||
return ""
|
||||
@@ -89,7 +90,10 @@ def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=Fal
|
||||
mantissa = roundToPrec(mantissa, prec)
|
||||
sign = "+" if forceSign is True and mantissa > 0 else ""
|
||||
# Round mantissa and add suffix
|
||||
result = "{0}{1}{2}".format(sign, mantissa, suffix)
|
||||
if unitName is None:
|
||||
result = "{}{}{}".format(sign, mantissa, suffix)
|
||||
else:
|
||||
result = "{}{} {}{}".format(sign, mantissa, suffix, unitName)
|
||||
return result
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user