Row and Column Fields (Dimensions)

The PivotEngine has several field collections exposed as properties. rowFields and columnFields contain fields used as "dimensions". The PivotEngine uses the dimension fields to break up the data into groups, and ensures each dimension field appears only once in the view.

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({ itemsSource: getData(1000), valueFields: ['Amount'], rowFields: ['Buyer', 'Type'] // summarize amounts }); var amountField = ngPanel.fields.getField('Amount'); amountField.format = 'c0'; // customize field // // clone the date fields to show quarters var yearField = ngPanel.fields.getField('Date'); yearField.header = 'Year'; yearField.format = 'yyyy'; // var quarterField = new wjOlap.PivotField(ngPanel, 'date', 'Quarter'); 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> Drag and drop fields to build views: </p> <div id="pivotPanel"></div> </div> <div class="col-xs-7"> <p> Summary for the current view definition: </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 = 'Mom,Dad,Kelly,Sheldon'.split(','), types = 'Food,Clothes,Fuel,Books,Sports,Music'.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({ itemsSource: dataService.getData(1000), // raw data valueFields: ['Amount'], // summarize amounts rowFields: ['Buyer', 'Type'] // summarize amounts }); this.ngPanel.fields.getField('Amount').format = 'c0'; // var yearField = this.ngPanel.fields.getField('Date'); yearField.header = 'Year'; yearField.format = 'yyyy'; // var quarterField = new wjOlap.PivotField(this.ngPanel, 'date', 'Quarter'); 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> Drag and drop fields to build views: </p> <wj-pivot-panel [itemsSource]="ngPanel"></wj-pivot-panel> </div> <div class="col-xs-7"> <p> Summary for the current view definition: </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 = 'Mom,Dad,Kelly,Sheldon'.split(','), types = 'Food,Clothes,Fuel,Books,Sports,Music'.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; } <template> <div class="container-fluid"> <div class="row"> <div class="col-xs-5"> <p> Drag and drop fields to build views: </p> <wj-pivot-panel id="sample-panel" :items-source="ngPanel"></wj-pivot-panel> </div> <div class="col-xs-7"> <p> Summary for the current view definition: </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({ itemsSource: getData(1000), // raw data valueFields: ['Amount'], // summarize amounts rowFields: ['Buyer', 'Type'] // summarize amounts }) }; }, mounted: function() { this.ngPanel.fields.getField('Amount').format = 'c0'; let yearField = this.ngPanel.fields.getField('Date'); yearField.header = 'Year'; yearField.format = 'yyyy'; let quarterField = new wjcOlap.PivotField(this.ngPanel, 'date', 'Quarter'); 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 = 'Mom,Dad,Kelly,Sheldon'.split(','), types = 'Food,Clothes,Fuel,Books,Sports,Music'.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)]; } 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({ itemsSource: getData(1000), valueFields: ['Amount'], rowFields: ['Buyer', 'Type'] // summarize amounts }) }; } render() { return (<div className="container-fluid"> <div className="row"> <div className="col-xs-5"> <p> Drag and drop fields to build views: </p> <Olap.PivotPanel id="sample-panel" itemsSource={this.state.ngPanel}></Olap.PivotPanel> </div> <div className="col-xs-7"> <p> Summary for the current view definition: </p> <Olap.PivotGrid itemsSource={this.state.ngPanel}></Olap.PivotGrid> </div> </div> </div>); } componentDidMount() { this.state.ngPanel.fields.getField('Amount').format = 'c0'; let yearField = this.state.ngPanel.fields.getField('Date'); yearField.header = 'Year'; yearField.format = 'yyyy'; let quarterField = new wjcOlap.PivotField(this.state.ngPanel, 'date', 'Quarter'); 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 = 'Mom,Dad,Kelly,Sheldon'.split(','), types = 'Food,Clothes,Fuel,Books,Sports,Music'.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)]; }