[{"id":"b66f8b1e-cc14-4e89-9679-abd5687d283d","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"569bb90a-ea68-46c6-96f1-ab151c120714","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"5eb52f08-2d1a-4362-9ffc-4871bdc10f3f","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"341dd607-b97d-4d70-bde2-53acda6b6c95","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"05349273-414f-4208-9ea2-c4fc8f4ea2cb","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"86089f76-b778-4d52-821e-6f27de3df613","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"b81e4fd6-1fc5-43a0-a258-b6e16a5cbec6","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"8aa8ce31-43e4-438e-951f-241608435260","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"37343f41-6ec2-4c7e-b21d-2cc18d5ce1e0","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"5915e52f-64f8-4146-b8bd-81bead6324a3","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"836ba889-af9e-460d-a4cc-c24d922795f2","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"4ae14b06-bb68-4394-a210-a46b8f028346","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"d8f42066-e9dc-4411-bdcf-43b1a203370c","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"7ef86f16-b1a0-49f7-9592-612b9be02b25","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"b29c7775-a9a4-451e-a1b5-01d19ed5ca5e","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"e56f3989-8f81-46af-90fa-a4813eeb976f","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"2526c963-f170-45a8-923e-91b0712a9810","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"24575cf0-501a-44f9-8426-c40f8f4b5552","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"1a6f8d7f-acd6-42be-8c4f-f464c6218381","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"82b176fd-5cab-498c-909e-8fa7d29c38d8","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"1708b3a9-4f37-44a8-8f0e-f9a2d2e5d940","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"c9ac246e-29fb-4bc4-8231-8439795bb590","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"94f2a5c3-2539-436a-af75-23fbbd1a3957","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"d99594f4-2d40-4df4-9419-ba2ca6aa3f7f","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"fd66e72d-0f10-4f57-9807-6db26290ab2e","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"8f344863-503d-4bc3-a594-3815e7d55f5c","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"9be82601-de9d-4c18-948a-23ab6f4dd431","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"6495f3c0-b463-47e0-b08a-ca949672211e","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"b4bede08-3f08-4839-ba4a-abc7ac195bde","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"4afcdfc0-3ff5-4f2b-a223-f8fc042a5bbe","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"422062c4-fa40-4771-a86f-008efe6d86e5","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"d87e8013-86a7-4840-8d25-6f62e14eb4ac","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"a6acedfd-4043-4c64-a5d1-aec3326df9e7","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"dbdc0b24-06c4-48b9-8d6c-7455119dc773","tags":[{"product":null,"links":null,"id":"9e117e35-984a-4c14-95ca-ef0ec7b9fb60","name":"\u65B0\u589E","color":"DarkGreen","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"a3856849-954a-4cfc-96a6-382e530d3638","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]},{"id":"4a39306b-ffa5-433d-80a3-28e41f929b72","tags":[{"product":null,"links":null,"id":"a2f84374-4a3f-4d22-96fd-765e9de495bf","name":"\u66F4\u65B0","color":"Coral","productId":"098be112-50ec-44e4-b746-6bc8bf76af97"}]}]
您可以将某些筛选应用于数据透视表,以便在隐藏其余数据的同时仅查看所需信息。
当需要筛选行或列的数据时,您可以应用行和列字段筛选。下图显示了应用于数据透视表的筛选,以仅显示东部地区的数量。
以下示例代码显示了如何筛选 Region 列以仅显示东部地区的数据。
// 添加筛选字段
myPivotTable.add("OrderDate", "OrderDate", GC.Spread.Pivot.PivotTableFieldType.filterField);
let itemList = ["East"];
myPivotTable.labelFilter("Region", { textItem: { list: itemList, isAll: false } });
值筛选可用于根据汇总值(如总和、计数、最大值、最小值、平均值等)筛选数据透视表中基于值的字段。下图显示了应用于数据透视表的值筛选,以显示值大于 2000 的类别列的“数量总和”。
以下示例代码显示了如何应用值筛选来显示大于 2000 的“数量总和”。
// 添加筛选字段
myPivotTable.add("OrderDate", "OrderDate", GC.Spread.Pivot.PivotTableFieldType.filterField);
// 使用 FilterInfo 对大于 2000 的“数量总和”应用值筛选
let valueFilter = { condition: { conType: GC.Pivot.PivotConditionType.value, val: [2000], operator: 2 }, conditionByName: "Sum of quantity" };
myPivotTable.valueFilter("Category", valueFilter);
标签筛选可用于筛选行标签项。它根据要筛选的字段的数据类型提供不同的选项。例如,对于字符串或数字数据类型,提供的选项是等于、不等于、开始于、包含、大于等。而对于日期数据类型,提供的选项是之前、之后、明天、下周等。以下示例演示如何将标签筛选应用于“区域”列字段以显示以“S”开头的城市。
以下示例代码显示了如何为以“S”开头的城市应用标签筛选。
// 添加筛选字段
myPivotTable.add("OrderDate", "OrderDate", GC.Spread.Pivot.PivotTableFieldType.filterField);
// 对以“S”开头的“城市”名称应用标签筛选,使用 FilterInfo
let labelFilter = { condition: { conType: GC.Pivot.PivotConditionType.caption, val: 'S', operator: 2 } };
myPivotTable.labelFilter("City", labelFilter);
您还可以使用手动筛选代替为标签筛选定义条件。下图显示了应用于显示“泽西”和“西雅图”城市数据的手动筛选。
以下代码示例显示了如何应用手动筛选。
// 添加手动筛选
let parent = { textItem: { list: ["Jersey", "Seattle"], isAll: false } };
myPivotTable.labelFilter("City", parent);
您还可以通过将allowMultipleFiltersPerField选项设置为 true来选择同时应用手动和基于条件的标签筛选。以下示例演示如何在数据透视表中应用多个筛选。
以下示例显示如何在数据透视表中应用多个筛选。
myPivotTable.options.allowMultipleFiltersPerField = true;
// 当设置allowMultipleFiltersPerField 时,两个筛选即都生效
var labelFilter = {
textItem: { list: ["Jersey", "San Francisco"], isAll: false },
condition: { conType: GC.Pivot.PivotConditionType.caption, operator: GC.Pivot.PivotCaptionFilterOperator.beginsWith, val: 'S' }
};
myPivotTable.labelFilter("City", labelFilter);
日期类型筛选可用于指定应用于数据透视表的日期类型项目的标准。下图显示了应用于数据透视表以显示季度数据的日期类型筛选。
以下示例代码显示了如何应用日期类型筛选。
let groupInfo = {
originFieldName: "OrderDate",
dateGroups: [
{ by: GC.Pivot.DateGroupType.quarters },
{ by: GC.Pivot.DateGroupType.years }]
};
myPivotTable.group(groupInfo);
myPivotTable.add("OrderDate", "Qtr", GC.Spread.Pivot.PivotTableFieldType.columnField);
// 使用 FilterInfo 应用标签筛选
let labelFilter = { condition: { conType: GC.Pivot.PivotConditionType.date, val: [], operator: GC.Pivot.PivotDateFilterOperator.Q1 } };
myPivotTable.labelFilter("Qtr", labelFilter);
您还可以在日期筛选中应用以下内置日期::
除了上述选项,您还可以通过将 isParallel属性设置为 true 来使用并行日期筛选。 并行日期筛选允许您获取与实际期间相对应的前一个或即将到来的日期(取决于数据透视表中的数据)中的相同期间。 例如,假设今天是 2021 年 11 月 23 日,数据透视表包含 2021 年 9 月 1 日到 2021 年 12 月 31 日的数据。
Month to Date:
并行>Month to Date筛选:
以下示例代码显示了如何应用dateToDate筛选.
function DateToDateFilter() {
var condition = {
conType: GC.Pivot.PivotConditionType.month,
operator: GC.Pivot.PivotDateFilterOperator.dateToDate,
val: [new Date(2021, 7, 15), new Date(2022, 6, 20)],
isParallel: false,
isDynamicEndDate: true,
by: GC.Pivot.PivotAdvancedDateFilterBy.month
};
var filterInfo = {
condition
};
myPivotTable.labelFilter("OrderDate", filterInfo);
}
通过创建筛选信息来应用上述筛选。下表描述了可用于创建筛选信息的条件:
条件 | 类型 | 操作员 | 值 | 条件名称 | 类型 | isWholeDay |
---|---|---|---|---|---|---|
GC.Pivot.IPivotCaptionConditionFilterInfo | GC.Pivot.PivotConditionType.caption | GC.Pivot.PivotCaptionFilterOperator | Array. |
/ |
/ |
/ |
GC.Pivot.IPivotDateConditionFilterInfo | GC.Pivot.PivotConditionType.date | GC.Pivot.PivotDateFilterOperator | Array. |
/ |
/ |
boolean |
GC.Pivot.IPivotTop10ConditionFilterInfo | GC.Pivot.PivotConditionType.top10 | GC.Pivot.PivotTop10FilterOperator | number | / |
GC.Pivot.PivotTop10FilterType | / |
GC.Pivot.IPivotValueConditionInfo | GC.Pivot.PivotConditionType.value | GC.Pivot.PivotValueFilterOperator | Array. |
string | / |
/ |
您可以使用showFilter选项隐藏数据透视表中的筛选按钮。
以下示例代码显示了如何隐藏筛选按钮。
// 将 showFilter 设置为 false
myPivotTable.options.showFilter = false;
您可以通过单击数据透视表中的任何行或列标题来使用“筛选”对话框。它提供了各种排序和筛选选项。您还可以从筛选对话框的列表框中选择所需的项目。下图显示了筛选对话框。
筛选对话框还提供了一个搜索框,可让您方便地应用筛选设置。
您可以输入不区分大小写的搜索词,还可以使用“Add current selection to filter”选项将所选项目与以前的筛选信息合并。如果未选中,则当前选择将覆盖先前的筛选信息。
它还允许您使用正则表达式字符进行搜索,例如'?', '*' 和'~'下图所示其他符号.