我在阿斯加兰先生的回答sample fiddle here的帮助下创建了in this question。在这里,我将数据表转换为,
var distinctValues = data.getDistinctValues(3);
var viewColumns = [0, 1];
var groupColumns = [];
// build column arrays for the view and grouping
for (var i = 0; i < distinctValues.length; i++) {
viewColumns.push({
type: 'number',
label: distinctValues[i],
calc: (function (x) {
return function (dt, row) {
return (dt.getValue(row, 3) == x) ? 1 : 0;
}
})(distinctValues[i])
});
groupColumns.push({
column: i+2,
type: 'number',
//label: distinctValues[i],
aggregation: google.visualization.data.sum
});
}
但是如果我使用data.getDistinctValues(3);
方法,则不同的值将按升序排序为April, February, January, March
。那么如何禁用排序,我可以将列的顺序作为January, February, March, April
?