ピボットチャート:タイトル

PivotChartは自動的にデータソースからタイトルを生成します。チャートのshowTitleプロパティを使用して、チャートにタイトルを含めるかどうかを決定できます。この例では、表示を切り替えることができるタイトル付きのPivotChartを示しています。

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 ngChart = new wjOlap.PivotEngine({ autoGenerateFields: false, fields: [ { binding: 'buyer', header: '担当者' }, { binding: 'type', header: '分類' }, { binding: 'amount', header: '金額' } ], itemsSource: getData(), valueFields: ['金額'], rowFields: ['担当者', '分類'], }); ngChart.fields.getField('金額').format = 'c0'; // customize field // // show the chart var pivotChart = new wjOlap.PivotChart('#pivotChart', { itemsSource: ngChart, showTitle: true, showLegend: 'Auto' }); // // toggle chart title document.getElementById('showTitle').addEventListener('click', function (e) { pivotChart.showTitle = e.target.checked; }); // } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Grapecity Wijmo OLAP Pivot Chart Title</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 id="pivotChart"></div> <label> タイトルを表示 <input id="showTitle" type="checkbox" checked="checked"> </label> </div> </body> </html> // get the raw data export function getData() { var yr = new Date().getFullYear(); return [{ date: new Date(yr, 0, 1), buyer: '成宮 真紀', type: 'ビデオ', amount: 74 }, { date: new Date(yr, 0, 15), buyer: '成宮 真紀', type: '食品', amount: 235 }, { date: new Date(yr, 0, 17), buyer: '山本 雅治', type: '家電', amount: 20 }, { date: new Date(yr, 0, 21), buyer: '加藤 泰江', type: '本', amount: 125 }, { date: new Date(yr, 1, 2), buyer: '成宮 真紀', type: '食品', amount: 235 }, { date: new Date(yr, 1, 20), buyer: '加藤 泰江', type: '音楽', amount: 20 }, { date: new Date(yr, 1, 25), buyer: '加藤 泰江', type: 'パソコン', amount: 125 }, ]; } .wj-pivotchart { margin: auto; max-width: 600px; } .wj-pivotchart .wj-flexchart { border: none; height: 300px; } body { margin-bottom: 48pt; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as wjOlap from '@grapecity/wijmo.olap'; // import { Component, Inject, enableProdMode, NgModule, ViewChild } 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 { @ViewChild('pivotChart') pivotChart: wjOlap.PivotChart; ngChart: wjOlap.PivotEngine; chartTypes: string[]; showLegendOptions: string[]; // constructor(@Inject(DataService) private dataService: DataService) { this.ngChart = new wjOlap.PivotEngine({ autoGenerateFields: false, fields: [ { binding: 'buyer', header: '担当者' }, { binding: 'type', header: '分類' }, { binding: 'amount', header: '金額' } ], itemsSource: dataService.getData(), // raw data valueFields: ['金額'], // summarize amounts rowFields: ['担当者', '分類'], // by buyer and type }); this.ngChart.fields.getField('金額').format = 'c0'; // this.chartTypes = 'Column,Bar,Line,Area,Pie'.split(','); this.showLegendOptions = 'Auto,Always,Never'.split(','); } // onShowTitleClick(e: MouseEvent) { this.pivotChart.showTitle = (e.target as HTMLInputElement).checked; } } // @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 Chart Title</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"> <wj-pivot-chart #pivotChart [itemsSource]="ngChart" [showTitle]=true [showLegend]="'Auto'"></wj-pivot-chart> <label> タイトルを表示 <input id="showTitle" type="checkbox" checked="checked" (click)="onShowTitleClick($event)"> </label> </div> import { Injectable } from '@angular/core'; export interface DataItem { date: Date; buyer: string; type: string; amount: number; } @Injectable() export class DataService { getData(): DataItem[] { var yr = new Date().getFullYear(); return [{ date: new Date(yr, 0, 1), buyer: '成宮 真紀', type: 'ビデオ', amount: 74 }, { date: new Date(yr, 0, 15), buyer: '成宮 真紀', type: '食品', amount: 235 }, { date: new Date(yr, 0, 17), buyer: '山本 雅治', type: '家電', amount: 20 }, { date: new Date(yr, 0, 21), buyer: '加藤 泰江', type: '本', amount: 125 }, { date: new Date(yr, 1, 2), buyer: '成宮 真紀', type: '食品', amount: 235 }, { date: new Date(yr, 1, 20), buyer: '加藤 泰江', type: '音楽', amount: 20 }, { date: new Date(yr, 1, 25), buyer: '加藤 泰江', type: 'パソコン', amount: 125 }, ]; } } .wj-pivotchart { margin: auto; max-width: 600px; } .wj-pivotchart .wj-flexchart { border: none; height: 300px; } body { margin-bottom: 48pt; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './app.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 = { ngChart: new wjcOlap.PivotEngine({ autoGenerateFields: false, fields: [ { binding: 'buyer', header: '担当者' }, { binding: 'type', header: '分類' }, { binding: 'amount', header: '金額' } ], itemsSource: getData(), valueFields: ['金額'], rowFields: ['担当者', '分類'], }) }; } render() { return <div className="container-fluid"> <Olap.PivotChart showTitle={true} itemsSource={this.state.ngChart} initialized={this.initializePivotChart.bind(this)} showLegend="Auto"> </Olap.PivotChart> <br /> <label> タイトルを表示 <input id="inputShowChartTitle" type="checkbox" onClick={this.onChartTitleClick.bind(this)}> </input> </label> </div>; } initializePivotChart(pivotChart) { this.pivotChart = pivotChart; this.pivotChart.engine.fields.getField('金額').format = 'c0'; document.querySelector("#inputShowChartTitle").checked = true; } onChartTitleClick(e) { this.pivotChart.showTitle = e.target.checked; } } 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>Grapecity Wijmo OLAP Pivot Chart Title</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> .wj-pivotchart { margin: auto; } .wj-pivotchart .wj-flexchart { border: none; height: 300px; } .wj-combobox { margin-left: 10px; } #inputShowChartTitle { margin-left: 10px; vertical-align: middle; } body { margin-bottom: 48pt; } // list of country GDP and populations // https://en.wikipedia.org/wiki/List_of_IMF_ranked_countries_by_GDP export function getData() { var yr = new Date().getFullYear(); return [ { date: new Date(yr, 0, 1), buyer: '成宮 真紀', type: 'ビデオ', amount: 74 }, { date: new Date(yr, 0, 15), buyer: '成宮 真紀', type: '食品', amount: 235 }, { date: new Date(yr, 0, 17), buyer: '山本 雅治', type: '家電', amount: 20 }, { date: new Date(yr, 0, 21), buyer: '加藤 泰江', type: '本', amount: 125 }, { date: new Date(yr, 1, 2), buyer: '成宮 真紀', type: '食品', amount: 235 }, { date: new Date(yr, 1, 20), buyer: '加藤 泰江', type: '音楽', amount: 20 }, { date: new Date(yr, 1, 25), buyer: '加藤 泰江', type: 'パソコン', amount: 125 }, ]; } <template> <div class="container-fluid"> <wj-pivot-chart control="pivotChart" :items-source="ngChart" :show-title="true" show-legend="Auto" :initialized="initializePivotChart"></wj-pivot-chart> <label> タイトルを表示 <input id="chartTitle" type="checkbox" checked="checked" v-on:click="onChartTitleClick"> </label> </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 { ngChart: new wjcOlap.PivotEngine({ autoGenerateFields: false, fields: [ { binding: 'buyer', header: '担当者' }, { binding: 'type', header: '分類' }, { binding: 'amount', header: '金額' } ], itemsSource: getData(), // raw data valueFields: ['金額'], // summarize amounts rowFields: ['担当者', '分類'], // by buyer and type }) }; }, methods: { initializePivotChart: (pivotChart) => { this.pivotChart = pivotChart; this.pivotChart.engine.fields.getField('金額').format = 'c0'; }, onChartTitleClick(e) { this.pivotChart.showTitle = e.target.checked; } } }); new Vue({ render: h => h(App) }).$mount("#app"); </script> <style> .wj-pivotchart { margin: auto; } .wj-pivotchart .wj-flexchart { border: none; height: 300px; } body { margin-bottom: 48pt; } </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 Chart Title</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> export function getData() { var yr = new Date().getFullYear(); return [{ date: new Date(yr, 0, 1), buyer: '成宮 真紀', type: 'ビデオ', amount: 74 }, { date: new Date(yr, 0, 15), buyer: '成宮 真紀', type: '食品', amount: 235 }, { date: new Date(yr, 0, 17), buyer: '山本 雅治', type: '家電', amount: 20 }, { date: new Date(yr, 0, 21), buyer: '加藤 泰江', type: '本', amount: 125 }, { date: new Date(yr, 1, 2), buyer: '成宮 真紀', type: '食品', amount: 235 }, { date: new Date(yr, 1, 20), buyer: '加藤 泰江', type: '音楽', amount: 20 }, { date: new Date(yr, 1, 25), buyer: '加藤 泰江', type: 'パソコン', amount: 125 }, ]; }