我正在尝试隐藏列以查找行中包含null或零值的记录,为此我使用的是filter方法实现。但由于某些原因,过滤功能没有调用。
以下是数据样本,
[
{
"cs": 1000,
"DateTime": "02/06/2015",
"subject": "lect",
"math": 1777.655,
"politics": 0.88
},
{
"cs": null,
"DateTime": "02/07/2015",
"subject": "lect",
"math": 344,
"politics": 0.99
},
{
"cs": null,
"DateTime": "02/08/2015",
"subject": "lect",
"math": 920.304,
"politics": 0.777
},
这是我的自定义聚合器功能和可枢转配置,其中调用过滤器。
pivotUI配置
.pivotUI( {
rows: ["subject"],
cols: ["DateTime"],
aggregators: {
"math": successRate,
"politics": successRate2,
"cs":successRate3
},
hiddenAttributes: ['Date'],
})
自定义聚合器功能
var successRate3 = function() {
return function() {
return {
sumSuccesses: "",
sumTrials: 0,
push: function(record) {
if (!isNaN(parseFloat(record['cs'])) && record['cs'] !== null) {
this.sumSuccesses = parseFloat(record['cs']);
}
},
value: function() { return this.sumSuccesses },
format: function(x) { return x; },
filter: function(record){ return record["cs"] > 0; },
rendererName: "TABLE",
numInputs: 0
};
};
};