チャート:複数の円チャート

サンプルは、同じデータソースに基づいて複数の円チャートを作成する方法を示します。

複数の円チャートを作成するには、FlexPie.bindingにカンマ区切りのプロパティをいくつか指定するだけです。

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as chart from '@grapecity/wijmo.chart'; import { getData } from './data'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { let pie = new chart.FlexPie('#chart', { header: '2017年スマートフォン販売シェア', bindingName: 'brand', binding: '2017Q1,2017Q2,2017Q3,2017Q4', titles: ['Q1', 'Q2', 'Q3', 'Q4'], dataLabel: { content: `{value}%`, position: chart.PieLabelPosition.Inside }, tooltip: { content: '<b>{name}</b><br/>{value}%' }, itemsSource: getData(), legend: { position: chart.Position.Bottom }, palette: ['rgba(136, 189, 230, 1)', 'rgba(251, 178, 88,1)', 'rgba(144, 205, 151, 1)', 'rgba(246, 170, 201, 1)', 'rgba(191, 165, 84, 1)', 'rgba(188, 153, 199, 1)'] }); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexChart Multiple Pie Charts</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="chart"></div> </div> </body> </html> // best selling mobile phones brands export function getData() { return [ { 'brand': 'Samsung', '2017Q1': 23.2, '2017Q2': 22.9, '2017Q3': 22.1, '2017Q4': 18.9 }, { 'brand': 'Huawei', '2017Q1': 10.0, '2017Q2': 11.0, '2017Q3': 10.4, '2017Q4': 10.7 }, { 'brand': 'Apple', '2017Q1': 14.7, '2017Q2': 11.8, '2017Q3': 12.4, '2017Q4': 19.6 }, { 'brand': 'Xiaomi', '2017Q1': 4.3, '2017Q2': 6.2, '2017Q3': 7.5, '2017Q4': 7.1 }, { 'brand': 'OPPO', '2017Q1': 7.5, '2017Q2': 8.0, '2017Q3': 8.1, '2017Q4': 6.9 }, { 'brand': 'その他', '2017Q1': 40.2, '2017Q2': 40.1, '2017Q3': 39.6, '2017Q4': 36.8 } ]; } body { margin-bottom: 24px; } .wj-flexchart .wj-data-labels .wj-data-label { font-size: 10pt; fill: white; } .wj-flexchart .wj-legend .wj-label { font-size: 12pt; } .wj-flexchart .wj-label { font-size: 14pt; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import { Component, Inject, enableProdMode, NgModule } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { WjChartModule } from '@grapecity/wijmo.angular2.chart'; import { WjChartAnimationModule } from '@grapecity/wijmo.angular2.chart.animation'; import { DataService } from './app.data'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { data: any[]; // constructor(@Inject(DataService) private dataService: DataService) { this.data = dataService.getData(); } } // @NgModule({ imports: [WjChartModule, WjChartAnimationModule, 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 FlexChart Multiple Pie Charts</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-flex-pie [header]="'2017年スマートフォン販売シェア'" [bindingName]="'brand'" [binding]="'2017Q1,2017Q2,2017Q3,2017Q4'" [itemsSource]="data" [titles]="['Q1','Q2','Q3','Q4']" [palette]="['rgba(136, 189, 230, 1)', 'rgba(251, 178, 88,1)', 'rgba(144, 205, 151, 1)', 'rgba(246, 170, 201, 1)', 'rgba(191, 165, 84, 1)', 'rgba(188, 153, 199, 1)']"> <wj-flex-pie-data-label [position]="'Inside'" [content]="'{value}%'"></wj-flex-pie-data-label> <wj-flex-chart-legend [position]="'Bottom'"> </wj-flex-chart-legend> </wj-flex-pie> </div> import { Injectable } from '@angular/core'; // @Injectable() export class DataService { getData() { return [ { 'brand': 'Samsung', '2017Q1': 23.2, '2017Q2': 22.9, '2017Q3': 22.1, '2017Q4': 18.9 }, { 'brand': 'Huawei', '2017Q1': 10.0, '2017Q2': 11.0, '2017Q3': 10.4, '2017Q4': 10.7 }, { 'brand': 'Apple', '2017Q1': 14.7, '2017Q2': 11.8, '2017Q3': 12.4, '2017Q4': 19.6 }, { 'brand': 'Xiaomi', '2017Q1': 4.3, '2017Q2': 6.2, '2017Q3': 7.5, '2017Q4': 7.1 }, { 'brand': 'OPPO', '2017Q1': 7.5, '2017Q2': 8.0, '2017Q3': 8.1, '2017Q4': 6.9 }, { 'brand': 'その他', '2017Q1': 40.2, '2017Q2': 40.1, '2017Q3': 39.6, '2017Q4': 36.8 } ]; } } body { margin-bottom: 24px; } .wj-flexchart .wj-data-labels .wj-data-label { font-size: 10pt; fill: white; } .wj-flexchart .wj-legend .wj-label { font-size: 12pt; } .wj-flexchart .wj-label { font-size: 14pt; } 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 wjChart from '@grapecity/wijmo.react.chart'; import { getData } from './data'; // class App extends React.Component { constructor(props) { super(props); this.initPie = (sender) => { sender.dataLabel.content = "{value}%"; }; this.state = { data: getData(), titles: ['Q1', 'Q2', 'Q3', 'Q4'], palette: ['rgba(136, 189, 230, 1)', 'rgba(251, 178, 88,1)', 'rgba(144, 205, 151, 1)', 'rgba(246, 170, 201, 1)', 'rgba(191, 165, 84, 1)', 'rgba(188, 153, 199, 1)'] }; } render() { return <div className="container-fluid"> <wjChart.FlexPie header="2017年スマートフォン販売シェア" bindingName="brand" binding="2017Q1,2017Q2,2017Q3,2017Q4" initialized={this.initPie} itemsSource={this.state.data} titles={this.state.titles} palette={this.state.palette}> <wjChart.FlexPieDataLabel position="Inside"></wjChart.FlexPieDataLabel> <wjChart.FlexChartLegend position="Bottom"></wjChart.FlexChartLegend> </wjChart.FlexPie> </div>; } } 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 FlexChart Multiple Pie Charts</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> body { margin-bottom: 24px; } .wj-flexchart .wj-data-labels .wj-data-label { font-size: 10pt; fill: white; } .wj-flexchart .wj-legend .wj-label { font-size: 12pt; } .wj-flexchart .wj-label { font-size: 14pt; } export function getData() { return [ { 'brand': 'Samsung', '2017Q1': 23.2, '2017Q2': 22.9, '2017Q3': 22.1, '2017Q4': 18.9 }, { 'brand': 'Huawei', '2017Q1': 10.0, '2017Q2': 11.0, '2017Q3': 10.4, '2017Q4': 10.7 }, { 'brand': 'Apple', '2017Q1': 14.7, '2017Q2': 11.8, '2017Q3': 12.4, '2017Q4': 19.6 }, { 'brand': 'Xiaomi', '2017Q1': 4.3, '2017Q2': 6.2, '2017Q3': 7.5, '2017Q4': 7.1 }, { 'brand': 'OPPO', '2017Q1': 7.5, '2017Q2': 8.0, '2017Q3': 8.1, '2017Q4': 6.9 }, { 'brand': 'その他', '2017Q1': 40.2, '2017Q2': 40.1, '2017Q3': 39.6, '2017Q4': 36.8 } ]; } <template> <div class="container-fluid"> <wj-flex-pie header="2017年スマートフォン販売シェア" bindingName="brand" binding="2017Q1,2017Q2,2017Q3,2017Q4" :itemsSource="data" :titles="['Q1','Q2','Q3','Q4']" :palette="['rgba(136, 189, 230, 1)', 'rgba(251, 178, 88,1)', 'rgba(144, 205, 151, 1)', 'rgba(246, 170, 201, 1)', 'rgba(191, 165, 84, 1)', 'rgba(188, 153, 199, 1)']"> <wj-flex-pie-data-label position="Inside" content="{value}%"></wj-flex-pie-data-label> <wj-flex-chart-legend position="Bottom"> </wj-flex-chart-legend> </wj-flex-pie> </div> </template> <script> import '@grapecity/wijmo.styles/wijmo.css'; import 'bootstrap.css'; import Vue from 'vue'; import '@grapecity/wijmo.vue2.chart'; import { getData } from './data'; // new Vue({ el: '#app', data: { data: getData() } }); </script> <style> body { margin-bottom: 24px; } .container-fluid .wj-flexchart .wj-data-labels .wj-data-label { font-size: 10pt; fill: white; } .container-fluid .wj-flexchart .wj-legend .wj-label { font-size: 12pt; } .container-fluid .wj-flexchart .wj-label { font-size: 14pt; } </style> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexChart Multiple Pie Charts</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> // best selling mobile phones brands export function getData() { return [ { 'brand': 'Samsung', '2017Q1': 23.2, '2017Q2': 22.9, '2017Q3': 22.1, '2017Q4': 18.9 }, { 'brand': 'Huawei', '2017Q1': 10.0, '2017Q2': 11.0, '2017Q3': 10.4, '2017Q4': 10.7 }, { 'brand': 'Apple', '2017Q1': 14.7, '2017Q2': 11.8, '2017Q3': 12.4, '2017Q4': 19.6 }, { 'brand': 'Xiaomi', '2017Q1': 4.3, '2017Q2': 6.2, '2017Q3': 7.5, '2017Q4': 7.1 }, { 'brand': 'OPPO', '2017Q1': 7.5, '2017Q2': 8.0, '2017Q3': 8.1, '2017Q4': 6.9 }, { 'brand': 'その他', '2017Q1': 40.2, '2017Q2': 40.1, '2017Q3': 39.6, '2017Q4': 36.8 } ] }