gpt4 book ai didi

iccube-reporting - icCube - 图表中的累计总数

转载 作者:行者123 更新时间:2023-12-02 05:23:26 24 4
gpt4 key购买 nike

我有一个 icCube 序列图表,它显示项目列表的度量,按从大到小的顺序排列。

我想在不使用 MDX 的情况下显示累积总计,但使用函数表达式生成器。不幸的是,我无法让它工作,我可能在语法中做错了什么。

有人知道如何构建 JavaScript 来获取累积值吗?

例如。 MDX 结果给出:

  • 项目1 10
  • 项目2 6
  • 项目3 2

我希望小部件将数据呈现为:

  • 项目1 10
  • 项目2 16 ( 10 + 6 )
  • 项目3 18 ( 10 + 6 + 2 )

并且 - 请 - 使用库中的函数对图表中的值定义进行纯 JavaScript。

最佳答案

在数据渲染部分(小部件)中,我们必须将 JavaScript 函数定义为值字段。我们将添加函数来直接计算累积,但我们可以使用:

var ri = context.rowIndex;  // current row Index
var cumVal = 0;
var isNotNull = false; // we've to add an ic3Add that supports nulls/empty
for ( var row = 0 ; row <= ri; row++ ) { // all former including this
var cellVal = context.getValue(row);
cumVal += cellVal || 0 ; // handle 'empty'
isNotNull = isNotNull || cellVal;
}
// the job is done
if (isNotNull)
return cumVal;
else
return

enter image description here

icCube v 6.2 (4285) 更新

icCube 6.2引入了新的累积函数:

cumulativeRow(row:CtxCoord, measure?:CtxCoord, property?:string):number
cumulativeCol(column:CtxCoord, measure?:CtxCoord, property?:string):number
cumulativeTable(row:CtxCoord, column:CtxCoord, measure?:CtxCoord, property?:string):number

使用这个新函数,Value 属性的新值应该是:

return context.cumulativeRow();

关于iccube-reporting - icCube - 图表中的累计总数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44004905/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com