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
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/47aa28f3-ff6b-492f-9988-c883ee4217eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.