ピボットパネル:行列フィールド(次元)

PivotEngineには、プロパティとして公開されているいくつかのフィールドコレクションがあります。rowFieldsおよびcolumnFieldsには、「次元」として使用されるフィールドが含まれています。PivotEngineは、次元フィールドを使用してデータをグループに分割し、各次元フィールドがビューに一度だけ表示されるようにします。

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as wjOlap from '@grapecity/wijmo.olap'; import { getData } from './data'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { // // initialize pivot engine var ngPanel = new wjOlap.PivotEngine({ autoGenerateFields: false, fields: [ { binding: 'date', header: '日付' }, { binding: 'buyer', header: '担当者' }, { binding: 'type', header: '分類' }, { binding: 'amount', header: '金額' } ], itemsSource: getData(1000), valueFields: ['金額'], rowFields: ['担当者', '分類'] // summarize amounts }); var amountField = ngPanel.fields.getField('金額'); amountField.format = 'c0'; // customize field // // clone the date fields to show quarters var yearField = ngPanel.fields.getField('日付'); yearField.header = '年'; yearField.format = 'yyyy'; // var quarterField = new wjOlap.PivotField(ngPanel, 'date', '四半期'); quarterField.format = '"Q"q'; ngPanel.fields.splice(1, 0, quarterField); // // show pivot panel var pivotPanel = new wjOlap.PivotPanel('#pivotPanel', { itemsSource: ngPanel }); // // show summary var pivotPanelGrid = new wjOlap.PivotGrid('#pivotPanelGrid', { itemsSource: ngPanel }); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Grapecity Wijmo OLAP Pivot Panel Row Column Fields</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div class="container-fluid"> <div class="row"> <div class="col-xs-5"> <p> フィールドをドラッグしてビューを作成: </p> <div id="pivotPanel"></div> </div> <div class="col-xs-7"> <p> 現在のビュー定義の要約: </p> <div id="pivotPanelGrid"></div> </div> </div> </div> </body> </html> import * as wjCore from '@grapecity/wijmo'; // get the raw data // get the raw data export function getData(cnt) { var today = new Date(), buyers = '成宮 真紀,山本 雅治,加藤 泰江,川村 匡'.split(','), types = '音楽,ビデオ,本,家電,パソコン,食品'.split(','), data = []; for (var i = 0; i < cnt; i++) { data.push({ date: wjCore.DateTime.addDays(today, -Math.random() * 365 * 3), buyer: randomItem(buyers), type: randomItem(types), amount: 20 + Math.random() * 1000 }); } return data; } function randomItem(arr) { return arr[Math.floor(Math.random() * arr.length)]; } .wj-pivotpanel { background: #eee; box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23); } .wj-pivotpanel .wj-flexgrid { background: inherit; } .wj-pivotpanel [wj-part=d-rows], .wj-pivotpanel [wj-part=d-cols] { background: gold; } body { margin-bottom: 24pt; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as wjOlap from '@grapecity/wijmo.olap'; // import { Component, Inject, enableProdMode, NgModule } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { WjOlapModule } from '@grapecity/wijmo.angular2.olap'; import { DataService } from './app.data'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { ngPanel: wjOlap.PivotEngine; // constructor(@Inject(DataService) private dataService: DataService) { this.ngPanel = new wjOlap.PivotEngine({ autoGenerateFields: false, fields: [ { binding: 'date', header: '日付' }, { binding: 'buyer', header: '担当者' }, { binding: 'type', header: '分類' }, { binding: 'amount', header: '金額' } ], itemsSource: dataService.getData(1000), // raw data valueFields: ['金額'], // summarize amounts rowFields: ['担当者', '分類'] // summarize amounts }); this.ngPanel.fields.getField('金額').format = 'c0'; // var yearField = this.ngPanel.fields.getField('日付'); yearField.header = '年'; yearField.format = 'yyyy'; // var quarterField = new wjOlap.PivotField(this.ngPanel, 'date', '四半期'); quarterField.format = '"Q"q'; this.ngPanel.fields.splice(1, 0, quarterField); } } // @NgModule({ imports: [WjOlapModule, BrowserModule], declarations: [AppComponent], providers: [DataService], bootstrap: [AppComponent] }) export class AppModule { } // enableProdMode(); // Bootstrap application with hash style navigation and global services. platformBrowserDynamic().bootstrapModule(AppModule); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Grapecity Wijmo OLAP Pivot Panel Row Column Fields</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Polyfills --> <script src="node_modules/core-js/client/shim.min.js"></script> <script src="node_modules/zone.js/dist/zone.min.js"></script> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.js"></script> <script src="systemjs.config.js"></script> <script> // workaround to load 'rxjs/operators' from the rxjs bundle System.import('rxjs').then(function (m) { System.set(SystemJS.resolveSync('rxjs/operators'), System.newModule(m.operators)); System.import('./src/app.component'); }); </script> </head> <body> <app-component></app-component> </body> </html> <div class="container-fluid"> <div class="row"> <div class="col-xs-5"> <p> フィールドをドラッグしてビューを作成: </p> <wj-pivot-panel [itemsSource]="ngPanel"></wj-pivot-panel> </div> <div class="col-xs-7"> <p> 現在のビュー定義の要約: </p> <wj-pivot-grid [itemsSource]="ngPanel"></wj-pivot-grid> </div> </div> </div> import * as wjCore from '@grapecity/wijmo'; import { Injectable } from '@angular/core'; export interface DataItem { date: Date; buyer: string; type: string; amount: number; } function randomItem(arr: string[]) { return arr[Math.floor(Math.random() * arr.length)]; } @Injectable() export class DataService { getData(cnt: number): DataItem[] { var today = new Date(), buyers = '成宮 真紀,山本 雅治,加藤 泰江,川村 匡'.split(','), types = '音楽,ビデオ,本,家電,パソコン,食品'.split(','), data = []; for (var i = 0; i < cnt; i++) { data.push({ date: wjCore.DateTime.addDays(today, -Math.random() * 365 * 3), buyer: randomItem(buyers), type: randomItem(types), amount: 20 + Math.random() * 1000 }); } return data; } } .wj-pivotpanel { background: #eee; box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23); } .wj-pivotpanel .wj-flexgrid { background: inherit; } .wj-pivotpanel [wj-part=d-rows], .wj-pivotpanel [wj-part=d-cols] { background: gold; } body { margin-bottom: 24pt; } import './app.css'; import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; // import * as React from 'react'; import * as ReactDOM from 'react-dom'; // import * as Olap from '@grapecity/wijmo.react.olap'; import * as wjcOlap from '@grapecity/wijmo.olap'; import { getData } from './data'; class App extends React.Component { constructor(props) { super(props); this.state = { ngPanel: new wjcOlap.PivotEngine({ autoGenerateFields: false, fields: [ { binding: 'date', header: '日付' }, { binding: 'buyer', header: '担当者' }, { binding: 'type', header: '分類' }, { binding: 'amount', header: '金額' } ], itemsSource: getData(1000), valueFields: ['金額'], rowFields: ['担当者', '分類'] // summarize amounts }) }; } render() { return (<div className="container-fluid"> <div className="row"> <div className="col-xs-5"> <p> フィールドをドラッグしてビューを作成: </p> <Olap.PivotPanel id="sample-panel" itemsSource={this.state.ngPanel}></Olap.PivotPanel> </div> <div className="col-xs-7"> <p> 現在のビュー定義の要約: </p> <Olap.PivotGrid itemsSource={this.state.ngPanel}></Olap.PivotGrid> </div> </div> </div>); } componentDidMount() { this.state.ngPanel.fields.getField('金額').format = 'c0'; let yearField = this.state.ngPanel.fields.getField('日付'); yearField.header = '年'; yearField.format = 'yyyy'; let quarterField = new wjcOlap.PivotField(this.state.ngPanel, 'date', '四半期'); quarterField.format = '"Q"q'; this.state.ngPanel.fields.splice(1, 0, quarterField); } } ReactDOM.render(<App />, document.getElementById('app')); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>AutoComplete</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div id="app"></div> </body> </html> #sample-panel { background: #eee; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23); } #sample-panel .wj-flexgrid { background: inherit; } #sample-panel [wj-part=d-rows], #sample-panel [wj-part=d-cols] { background: gold; } body { margin-bottom: 24pt; } import * as wjcCore from '@grapecity/wijmo'; export function getData(cnt) { var today = new Date(), buyers = '成宮 真紀,山本 雅治,加藤 泰江,川村 匡'.split(','), types = '音楽,ビデオ,本,家電,パソコン,食品'.split(','), data = []; for (var i = 0; i < cnt; i++) { data.push({ date: wjcCore.DateTime.addDays(today, -Math.random() * 365 * 3), buyer: randomItem(buyers), type: randomItem(types), amount: 20 + Math.random() * 1000 }); } return data; } function randomItem(arr) { return arr[Math.floor(Math.random() * arr.length)]; } <template> <div class="container-fluid"> <div class="row"> <div class="col-xs-5"> <p> フィールドをドラッグしてビューを作成: </p> <wj-pivot-panel id="sample-panel" :items-source="ngPanel"></wj-pivot-panel> </div> <div class="col-xs-7"> <p> 現在のビュー定義の要約: </p> <wj-pivot-grid :items-source="ngPanel"></wj-pivot-grid> </div> </div> </div> </template> <script> import '@grapecity/wijmo.styles/wijmo.css'; import 'bootstrap.css'; import Vue from 'vue'; import '@grapecity/wijmo.vue2.olap'; import * as wjcOlap from '@grapecity/wijmo.olap'; import { getData } from './data' let App = Vue.extend({ name: "app", data: function() { return { ngPanel: new wjcOlap.PivotEngine({ autoGenerateFields: false, fields: [ { binding: 'date', header: '日付' }, { binding: 'buyer', header: '担当者' }, { binding: 'type', header: '分類' }, { binding: 'amount', header: '金額' } ], itemsSource: getData(1000), // raw data valueFields: ['金額'], // summarize amounts rowFields: ['担当者', '分類'] // summarize amounts }) }; }, mounted: function() { this.ngPanel.fields.getField('金額').format = 'c0'; let yearField = this.ngPanel.fields.getField('日付'); yearField.header = '年'; yearField.format = 'yyyy'; let quarterField = new wjcOlap.PivotField(this.ngPanel, 'date', '四半期'); quarterField.format = '"Q"q'; this.ngPanel.fields.splice(1, 0, quarterField); } }); new Vue({ render: h => h(App) }).$mount("#app"); </script> <style> #sample-panel { background: #eee; box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23); } #sample-panel .wj-flexgrid { background: inherit; } #sample-panel [wj-part=d-rows], #sample-panel [wj-part=d-cols] { background: gold; } body { margin-bottom: 24pt; } </style> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Grapecity Wijmo OLAP Pivot Panel Row Column Fields</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app.vue'); </script> </head> <body> <div id="app"> </div> </body> </html> import * as wjcCore from '@grapecity/wijmo'; export function getData(cnt) { var today = new Date(), buyers = '成宮 真紀,山本 雅治,加藤 泰江,川村 匡'.split(','), types = '音楽,ビデオ,本,家電,パソコン,食品'.split(','), data = []; for (var i = 0; i < cnt; i++) { data.push({ date: wjcCore.DateTime.addDays(today, -Math.random() * 365 * 3), buyer: randomItem(buyers), type: randomItem(types), amount: 20 + Math.random() * 1000 }); } return data; } function randomItem(arr) { return arr[Math.floor(Math.random() * arr.length)]; }