[bug] modifier in google.visualization.data.group modify the whole column, not only the new one

26 views
Skip to first unread message

Jean-Rémi Delteil

unread,
Dec 6, 2017, 6:00:39 AM12/6/17
to Google Visualization API
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
Reply all
Reply to author
Forward
0 new messages