2016-01-19 42 views
2

從總結與平均我得到的分數值,我需要四捨五入。更重要的是,四捨五入的數值總和與未舍入的數值相同(兩者均爲0.5會導致兩個數值不在一個0和1中)。是否有這樣的功能或至少一個循環功能?石墨圓形值/設定值精度

回答

2

不幸的是,沒有這樣的功能。有在github https://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,它不會出現在菜單中,但手動輸入它將起作用。

+0

是的,我看到了這個問題,但我不確定它爲什麼關閉,因爲沒有對此發表評論。謝謝。 – Filu