Web Components ピボット グリッド リモート操作
ピボット データがすでにリモート サービスからグループ化および集約されており、クライアントでさらに処理する必要がないシナリオでは、クライアントでのデータ処理をスキップし、データをそのまま直接表示できるようにするカスタムの空のストラテジを使用するように構成できます。
public pivotConfigHierarchy: IgcPivotConfiguration = {
columnStrategy : IgcNoopPivotDimensionsStrategy.instance(),
rowStrategy : IgcNoopPivotDimensionsStrategy.instance(),
}
typescript
次の例は、データがすでに集約されているシナリオの処理方法と、その構造がどのように見えるかを示しています:
export class PivotNoopData extends Array <any > {
public constructor ( ) {
super ();
this .push({
'AllProducts' : 'All' , 'USA' : 1159 , 'Uruguay' : 1274 , 'Bulgaria' : 1012 , 'France' : 1301 , 'Germany' : 570 , 'Austria' : 990 ,
'AllSeller_records' : [
{
'AllSeller' : 'All Sellers' ,
'USA' : 1159 , 'Uruguay' : 1274 , 'Bulgaria' : 1012 , 'France' : 1301 , 'Germany' : 570 , 'Austria' : 990 ,
'AllSeller_records' : [
{ 'SellerName' : 'David' , 'USA' : 293 , 'France' : 240 , 'Austria' : 270 , 'Uruguay' : 130 , 'Bulgaria' : 110 },
{ 'SellerName' : 'Lydia' , 'Germany' : 120 , 'Uruguay' : 68 , 'Austria' : 250 , 'France' : 170 , 'Bulgaria' : 220 },
{ 'SellerName' : 'Stanley' , 'Austria' : 400 , 'Germany' : 240 , 'Bulgaria' : 282 , ' USA' : 330 },
{ 'SellerName' : 'Elisa' , 'USA' : 296 , 'Uruguay' : 530 , 'France' : 430 , 'Germany' : 230 },
{ 'SellerName' : 'John' , 'France' : 361 , 'USA' : 240 , 'Bulgaria' : 190 , 'Uruguay' : 90 },
{ 'SellerName' : 'Larry' , 'Uruguay' : 456 , 'France' : 100 , 'Austria' : 70 , 'Bulgaria' : 210 }
]
}
],
'AllProducts_records' : [
{
'ProductCategory' : 'Accessories' ,
'USA' : 623 ,
'France' : 100 ,
'Austria' : 400 ,
'Bulgaria' : 210 ,
'AllSeller_records' : [
{
'AllSeller' : 'All Sellers' , 'USA' : 623 , 'France' : 100 , 'Austria' : 400 , 'Bulgaria' : 210 ,
'AllSeller_records' : [
{ 'SellerName' : 'David' , 'USA' : 293 },
{ 'SellerName' : 'Stanley' , 'USA' : 330 , 'Austria' : 400 },
{ 'SellerName' : 'Larry' , 'France' : 100 , 'Bulgaria' : 210 }
]
}
]
},
{
'ProductCategory' : 'Bikes' ,
'Uruguay' : 198 ,
'France' : 531 ,
'Germany' : 120 ,
'Austria' : 270 ,
'Bulgaria' : 190 ,
'AllSeller_records' : [
{
'AllSeller' : 'All Sellers' ,
'Uruguay' : 198 ,
'France' : 531 ,
'Germany' : 120 ,
'Austria' : 270 ,
'Bulgaria' : 190 ,
'AllSeller_records' : [
{ 'SellerName' : 'Lydia' , 'Uruguay' : 68 , 'Germany' : 120 , 'France' : 170 },
{ 'SellerName' : 'John' , 'France' : 361 , 'Bulgaria' : 190 },
{ 'SellerName' : 'David' , 'Austria' : 270 , 'Uruguay' : 130 }
]
}
]
},
{
'ProductCategory' : 'Clothing' ,
'USA' : 296 ,
'Uruguay' : 986 ,
'Bulgaria' : 502 ,
'Germany' : 470 ,
'France' : 430 ,
'Austria' : 70 ,
'AllSeller_records' : [
{
'AllSeller' : 'All Sellers' , 'USA' : 296 , 'Uruguay' : 986 , 'Bulgaria' : 502 , 'Germany' : 470 , 'France' : 430 , 'Austria' : 70 ,
'AllSeller_records' : [
{ 'SellerName' : 'Elisa' , 'USA' : 296 , 'Uruguay' : 530 , 'France' : 430 , 'Germany' : 230 },
{ 'SellerName' : 'Lydia' , 'Bulgaria' : 220 },
{ 'SellerName' : 'Larry' , 'Uruguay' : 456 , 'Austria' : 70 },
{ 'SellerName' : 'Stanley' , 'Germany' : 240 , 'Bulgaria' : 282 }
]
}
]
},
{
'ProductCategory' : 'Components' ,
'USA' : 240 ,
'France' : 240 ,
'Austria' : 250 ,
'Bulgaria' : 110 ,
'Uruguay' : 90 ,
'AllSeller_records' : [
{
'AllSeller' : 'All Sellers' ,
'USA' : 240 ,
'France' : 240 ,
'Austria' : 250 ,
'Bulgaria' : 110 ,
'Uruguay' : 90 ,
'AllSeller_records' : [
{ 'SellerName' : 'John' , 'USA' : 240 , 'Uruguay' : 90 },
{ 'SellerName' : 'David' , 'France' : 240 , 'Bulgaria' : 110 },
{ 'SellerName' : 'Lydia' , 'Austria' : 250 }
]
}
]
}
]
});
}
public static getData(): Promise <any > {
return new Promise (resolve => setTimeout (() => {
resolve(new PivotNoopData());
}, 1000 ));
}
}
ts コピー import 'igniteui-webcomponents-grids/grids/combined' ;
import { IgcPivotGridComponent, IgcNoopPivotDimensionsStrategy } from 'igniteui-webcomponents-grids/grids' ;
import "igniteui-webcomponents-grids/grids/themes/light/bootstrap.css" ;
import { PivotNoopData } from './PivotNoopData' ;
export class Sample {
private _pivotConfiguration: any | null = null ;
public get pivotConfiguration (): any {
if (this ._pivotConfiguration == null ) {
const pivotConfiguration: any = {
columnStrategy : IgcNoopPivotDimensionsStrategy.instance(),
rowStrategy : IgcNoopPivotDimensionsStrategy.instance(),
columns : [
{
memberName : 'Country' ,
enabled : true
}
],
rows : [
{
memberFunction : () => 'All' ,
memberName : 'AllProducts' ,
enabled : true ,
childLevel : {
memberFunction : (data: any ) => data.ProductCategory,
memberName : 'ProductCategory' ,
enabled : true
}
},
{
memberName : 'AllSeller' ,
memberFunction : () => 'All Sellers' ,
enabled : true ,
childLevel : {
enabled : true ,
memberName : 'SellerName'
}
}
],
values : [
{
member : 'UnitsSold' ,
aggregate : {
aggregatorName : 'SUM' ,
key : 'sum' ,
label : 'Sum'
},
enabled : true ,
formatter : (value: any ) => value ? value : 0
}
],
filters : null
};
this ._pivotConfiguration = pivotConfiguration;
}
return this ._pivotConfiguration;
}
private _bind: () => void ;
constructor ( ) {
var grid = document .getElementById('grid' ) as IgcPivotGridComponent;
this ._bind = () => {
grid.pivotConfiguration = this .pivotConfiguration;
PivotNoopData.getData().then(value => {
grid.data = value;
});
}
this ._bind();
}
}
new Sample();
ts コピー <!DOCTYPE html >
<html >
<head >
<title > Sample | Ignite UI | Web Components | infragistics</title >
<meta charset ="UTF-8" />
<link rel ="shortcut icon" href ="https://static.infragistics.com/xplatform/images/browsers/wc.png" >
<link rel ="stylesheet" href ="https://fonts.googleapis.com/icon?family=Material+Icons" />
<link rel ="stylesheet" href ="https://fonts.googleapis.com/css?family=Kanit&display=swap" />
<link rel ="stylesheet" href ="https://fonts.googleapis.com/css?family=Titillium Web" />
<link rel ="stylesheet" href ="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" />
<link rel ="stylesheet" href ="/src/index.css" type ="text/css" />
</head >
<body >
<div id ="root" >
<div class ="container sample" >
<div class ="container horizontal" >
<div class ="container vertical" >
<igc-pivot-grid default-expand-state ="true" super-compact-mode ="true" show-pivot-configuration-ui ="false"
height ="100%" name ="grid" id ="grid" >
</igc-pivot-grid >
</div >
</div >
</div >
</div >
<% if (false) { %>
<script src ="src/index.ts" > </script >
<% } %>
</body >
</html >
html コピー
このサンプルが気に入りましたか? 完全な Ignite UI for Web Componentsツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
ユーザーは、ピボット グリッドに既に集計されたデータをフィードすることで、特定のシナリオを実現できます。
データがどのように表示されるかについていくつかの要件があり、ピボット ビューの階層に関するいくつかの詳細があります。たとえば、rows (行) ディメンションで階層を宣言するには、次のようにします:
rows: [
{
memberName : 'AllProducts' ,
memberFunction : () => 'All Products' ,
enabled : true ,
childLevel : {
memberName : 'ProductCategory' ,
enabled : true
}
}
]
typescript
そして、集約された例は次のようになります:
public aggregatedData = [
{
ProductCategory : 'All' , AllProducts : 'All Products' , All : 1000 , 'All-Bulgaria' : 774 , 'All-USA' : 829 , 'All-Uruguay' : 524 , AllProducts_records : [
{ ProductCategory : 'Clothing' , 'All-Bulgaria' : 774 , 'All-USA' : 296 , 'All-Uruguay' : 456 },
{ ProductCategory : 'Bikes' , 'All-Uruguay' : 68 },
{ ProductCategory : 'Accessories' , 'All-USA' : 293 },
{ ProductCategory : 'Components' , 'All-USA' : 240 }
]
}
];
typescript
ピボット グリッドは、ピボット計算を行うために使用するオブジェクト キー フィールドを提供します。
children - 階層構築のために子を格納するフィールド。これは、グループ化された値と、その値に基づくすべての pivotGridRecords からのマップを表します。これは、階層の作成中に何かを行う必要がある非常に特殊なシナリオで利用できます。一般的な使用法のためにこれを変更する必要はありません。
records - 元のデータ レコードへの参照を格納するフィールド。上記の例で見ることができます - AllProducts_records 。このプロパティと同じ名前でデータにフィールドを設定することは避けてください。データ レコードに records プロパティがある場合は、pivotKeys を使用して異なる一意の値を指定できます。
aggregations - 集計値を格納するフィールド。階層の作成中に適用され 、一般的なシナリオでは変更する必要はありません。
level - 階層に基づいてディメンション レベルを格納するフィールド。このプロパティと同じ名前でデータにフィールドを設定することは避けてください。データ レコードに level プロパティがある場合は、pivotKeys を使用して異なる一意の値を指定できます。
columnDimensionSeparator - 一意の列フィールド値を生成するときに使用されるセパレーター。上からの例のダッシュ (- ) - All-Bulgaria です。
rowDimensionSeparator - 一意の行フィールド値を生成するときに使用されるセパレーター。上記の例のアンダースコア (_ ) - AllProducts_records です。records (レコード) と level (レベル フィールド) を作成するときに使用されます。
これらはすべて、PivotConfiguration
の一部である pivotKeys プロパティに格納され、デフォルトのピボット キーを変更するために使用できます。これらのデフォルトは次のとおりです:
export const = {
aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' ,
rowDimensionSeparator : '_' , columnDimensionSeparator : '-'
};
typescript
ColumnStrategy
と RowStrategy
に NoopPivotDimensionsStrategy
を設定すると、データ パイプによって行われるデータのグループ化と集計がスキップされますが、ピボット ビューを期待どおりに描画するには、ピボット グリッドで行、列、値、フィルターの宣言が必要です:
public pivotConfig: IgcPivotConfiguration = {
rows : [
{
memberName : 'AllProducts' ,
memberFunction : () => 'All Products' ,
enabled : true ,
childLevel : {
memberName : 'ProductCategory' ,
enabled : true
}
}
],
columns : [
{
memberName : 'All' ,
enabled : true ,
childLevel : {
memberName : 'Country' ,
enabled : true
}
}
],
values : [
{
member : 'UnitsSold' ,
aggregate : {
aggregator : IgcPivotNumericAggregate.sum,
key : 'sum' ,
label : 'Sum'
},
enabled : true
},
]
}
typescript
データが構成と一致することが重要です。最良の結果を得るには、集計データに追加のフィールドを含めたり、提供されたデータのフィールドを行または列として宣言せずに残したりしないでください。IgcPivotGridComponent
コンポーネントは、pivotConfiguration
に基づいてデータを構築し、それに応じて構成と集約データが一致することが期待されます。
同様に、並べ替えやフィルタリングなどの他のリモート データ操作の場合、関連する空のストラテジ (filterStrategy
、sortStrategy
) を設定することで、データ処理をスキップできます。
<igc-pivot-grid filter-strategy ="noopFilterStrategy" sort-strategy ="noopSortStrategy" >
</igc-pivot-grid >
html
public noopFilterStrategy = NoopFilteringStrategy.instance();
public noopSortStrategy = NoopSortingStrategy.instance();
typescript
API リファレンス
PivotGridComponent
PivotDataSelectorComponent
その他のリソース
コミュニティに参加して新しいアイデアをご提案ください。