【发布时间】:2016-01-19 16:03:28
【问题描述】:
从平均总结中,我得到需要四舍五入的小数值。更重要的是,舍入值的总和与未舍入的值相同(两者都有 0.5 的情况会导致两个不属于一个 0 和 1)。是否有类似的功能或至少一个圆形功能?
【问题讨论】:
标签: graphite
从平均总结中,我得到需要四舍五入的小数值。更重要的是,舍入值的总和与未舍入的值相同(两者都有 0.5 的情况会导致两个不属于一个 0 和 1)。是否有类似的功能或至少一个圆形功能?
【问题讨论】:
标签: graphite
很遗憾没有这样的功能。 githubhttps://github.com/graphite-project/graphite-web/issues/1346有问题,但没有解决
编辑
您也可以将该函数添加到文件<GRAPHITE_WEBAPP_DIR>/render/functions.py:
def roundValues(requestContext, seriesList, ndigits):
for series in seriesList:
series.name = "roundValues(%s,%d)" % (series.name, ndigits)
series.pathExpression = series.name
for i,value in enumerate(series):
if value is not None:
series[i] = round(value, ndigits)
return seriesList
# ...
# and to SeriesFunctions - almost at the bottom of file
SeriesFunctions = {
# Combine functions
'sumSeries' : sumSeries,
'sum' : sumSeries,
'roundValues': roundValues,
# ...
}
添加后,删除*.pyc文件,重启uwsgi。您现在有可用的功能roundValues,它不会显示在菜单中,但可以手动输入。
【讨论】: