I am trying to calculate row and column total for the following dataset. I am using Jsreport
"incidentTypes": {
"Blo": [0,0,1,0,0,0,1,0,0],
"Ma": [0,0,0,1,0,1,2,0,1],
"Ph": [1,1,1,0,1,0,0,1,1]
}
This is the helper function i used to calculate the row total but I am not sure how to calculate the row total
function total(input) {
var sum = input.reduce((acc,value) => acc+value)
return sum
}
and this how i called in in jsreport
{{#each incidentTypes}}
<tr>
<td>{{@key}} </td>
{{#each this}}
<td>{{this}}</td>
{{/each}}
<td>{{total this}}</td>
</tr>