【问题标题】:Graphite - Round values / set values precision石墨 - 圆形值/设定值精度
【发布时间】:2016-01-19 16:03:28
【问题描述】:

从平均总结中,我得到需要四舍五入的小数值。更重要的是,舍入值的总和与未舍入的值相同(两者都有 0.5 的情况会导致两个不属于一个 0 和 1)。是否有类似的功能或至少一个圆形功能?

【问题讨论】:

    标签: graphite


    【解决方案1】:

    很遗憾没有这样的功能。 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,它不会显示在菜单中,但可以手动输入。

    【讨论】:

    • 是的,我已经看到了这个问题,但我不确定它为什么被关闭,因为没有对此发表评论。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-29
    • 2019-01-19
    • 2013-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多