在 Data Render 部分,小部件中,我们必须定义一个 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
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();