以下是我的生成数据透视表的脚本:
var derivers = $.pivotUtilities.derivers;
var renderers = $.extend($.pivotUtilities.renderers, $.pivotUtilities.c3_renderers);
$('#output').pivotUI(
[{
Line: 'X',
Party: 'AB'
}, {
Line: 'X',
Party: 'CD'
}, {
Line: 'Y',
Party: 'EF'
}, {
Line: 'Y',
Party: 'AB'
}, {
Line: 'X',
Party: 'GH'
}, {
Line: 'Y',
Party: 'IJ'
}, {
Line: 'X',
Party: 'AB'
}], {
renderers: renderers,
rows: ['Line'],
cols: ['Party']
});
我想预过滤仅载入“ AB”的Party列。用户可以选择所有项目。但是在加载数据透视表时,我会喜欢预先过滤Party列。
您能告诉我该怎么做吗?
最佳答案
您可以将包含/排除用作枢轴功能的选项。这些将对象作为输入,键为列名,值为已过滤属性的数组。
以下是指向JSfiddle的链接:-
https://jsfiddle.net/ab3kwcnp/1/
$('#output').pivotUI([
{country: "USA", city: "Boston"},
{country: "USA", city: "NYC"},
{country: "UK", city: "London"},
],
{
rows: ["country"],
cols: ["city"],
inclusions: {country:["USA"]}
});