Hello,
In the following example, I'm trying to get the sum of the unique column of this dataTable.
However, the aggregation column's value are also applied to the source column, hence the result is not the sum applied on the original data.
var dt = new google.visualization.DataTable(
{
"cols": [{"label": "Your age", "type": "number"}],
"rows": [
{c: [{v: 3}]},
{c: [{v: 5}]}
]
}
);
// Calculate sum
var sumDataTable = google.visualization.data.group(dt,
[
{
'column': 0,
'type': 'number',
'modifier': function () { return 1 }
}
],
[
{
'column': 0,
'type': 'number',
'aggregation': google.visualization.data.sum
}
]
);
// Output 2 instead of 8
console.log(sumDataTable.getValue(0, 1));
// The key column modifier should not modify the column used as value