3

I have an icCube serial chart that displays a measure for a list of items, ordered from large to small.

I would like to use to display the cumulative total without using MDX, but using the function expression builder. Unfortunately I can not get it to work I I probably do something wrong in the syntax.

Does someone know how to make a javascript construction to get the cumulative value.

For example. the MDX result gives:

  • item1 10
  • item2 6
  • item3 2

I would like the widget to present the data as:

  • item1 10
  • item2 16 ( 10 + 6 )
  • item3 18 ( 10 + 6 + 2 )

And - please - pure javascript on the value definition in the graph using functions from the library.

ic3
  • 7,917
  • 14
  • 67
  • 115
Arthur
  • 1,692
  • 10
  • 14

1 Answers1

2

In the Data Render part, the widget, we've to define a javascript function as value field. We'll add the function to directly calculate cumulative , but for we can use :

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

Update for icCube v 6.2 (4285)

icCube 6.2 introduced new cumulative functions:

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

With this new functions new value for a Value property should be:

return context.cumulativeRow();
Artem Lopatiy
  • 948
  • 5
  • 15
ic3
  • 7,917
  • 14
  • 67
  • 115