Knowledgebase:
Cumulative Sum (Line Chart Widget)
Posted by Daniel Ranisavljevic on 24 March 2022 12:10 pm

Cumulative Sum can be achieved across a sorted category by:

  • adding the value of the current item to the previous item,
  • where the item isn't the first item in the list.

This can be achieved on a widget level for each series with the following script.

widget.on('processresult', (widget, args) => {
  args.result.series.forEach((series) => {
    for (i = 1; i < series.data.length; i++) {
      series.data[i].y += series.data[i - 1].y
    }
  })
})

(0 vote(s))
Helpful
Not helpful

Comments (0)
Copyright © RAPID BI Pty Ltd 2020