如何在累积图中使用 FORMATTED_VALUE?

How to use FORMATTED_VALUE in a cumulated graph?

首先,在 icCube 报告的数据渲染面板中,我在 Value 字段中使用 context.cumulativeCol(); 来创建我的累积图。

现在,由于我的数据格式不太适合我的应用程序(我有诸如“4.547473508864641e-13”之类的值,我希望将其格式化为 0.00),我尝试向该函数添加参数:

var col = context.getColumnIndex(); var measure = context.getMeasures(); var property = "FORMATTED_VALUE"; return context.cumulativeCol(col, measure, property);

但是我无法得到正确的输出。 我应该怎么做?

您不能使用 FORMATTED_VALUE 来格式化在客户端计算的数字,它可用于直接来自服务器的数据。因此,在您的情况下,您需要实现自己的客户端格式设置。您可以使用捆绑到报告中的 mathJS,即:

return math.format(context.cumulativeCol(col), {notation: "fixed", precision: 2})

或使用任何其他 JS 格式化方法,如 .toFixed(2)