admin管理员组文章数量:1405631
Any method that can get sum
, avg
, count
of data at a column in google chart table
? I want to show metadata
of that table out of the table.
Any method that can get sum
, avg
, count
of data at a column in google chart table
? I want to show metadata
of that table out of the table.
2 Answers
Reset to default 3Alternatively, if you have a DataTable you manually input, you can do the same as follows:
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['x', 'Cats'],
['A', 1],
['B', 2],
['C', 4],
['D', 8],
['E', 7],
['F', 7],
['G', 8],
['H', 4],
['I', 2],
['J', 3.5],
['K', 3],
['L', 3.5],
['M', 1],
['N', 1]
]);
// Create an Array to hold column data
var tmpColumn = new Array();
// Add each data value to the array with push()
for(var i = 0; i < data.getNumberOfColumns(); ++i) {
tmpColumn.push(data.getValue(i, 1));
}
// Use built-in Google Functions on the array
alert(google.visualization.data.avg(tmpColumn));
alert(google.visualization.data.sum(tmpColumn));
alert(google.visualization.data.count(tmpColumn));
}
Perhaps you are looking for something like this:
var query = new google.visualization.Query(DATA_SOURCE_URL);
query.setQuery('select dept, sum(salary) group by dept');
query.send(handleQueryResponse);
DATA_SOURCE_URL
can correspond to a Google Chart Data Source URL.
From: https://developers.google./chart/interactive/docs/querylanguage
本文标签: javascriptGet sum of column in google chart tableStack Overflow
版权声明:本文标题:javascript - Get sum of column in google chart table - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744337433a2601274.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论