チャート:積み上げチャート

このサンプルは、縦棒チャートを90度回転した積み上げ横棒チャートを示しています。

デフォルトでは、Y軸上の項目はチャートの下部から始まるため、最初の項目は下部に表示され、最後の項目は上部に表示されます。

Y軸を逆にすると、項目はの一番上から始まります。これは、より自然な順序です。

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as chart from '@grapecity/wijmo.chart'; import * as animation from '@grapecity/wijmo.chart.animation'; import { getData } from './data'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { let barchart = new chart.FlexChart('#chart', { header: '各国のGDP', chartType: chart.ChartType.Bar, legend: { position: chart.Position.Bottom }, bindingX: 'year', series: [{ binding: 'US', name: 'アメリカ' }, { binding: 'China', name: '中国' }, { binding: 'Japan', name: '日本' }, { binding: 'Germany', name: 'ドイツ' }, { binding: 'UK', name: 'イギリス' }, { binding: 'France', name: 'フランス' }, { binding: 'India', name: 'インド' }, { binding: 'Italy', name: 'イタリア' }], stacking: chart.Stacking.Stacked, axisY: { reversed: true }, itemsSource: getData(), palette: [ 'rgba(70,107,176,1)', 'rgba(200,180,34,1)', 'rgba(20,136,110,1)', 'rgba(181,72,54,1)', 'rgba(110,89,68,1)', 'rgba(139,56,114,1)', 'rgba(115,178,43,1)', 'rgba(184,115,32,1)', 'rgba(20,20,20,1)' ] }); // let ani = new animation.ChartAnimation(barchart); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexChart Stacked Bar</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> // list of country GDP // https://en.wikipedia.org/wiki/List_of_IMF_ranked_countries_by_GDP export function getData() { return [ { 'year': '2014', 'US': 17348075, 'China': 10356508, 'Japan': 4602367, 'Germany': 3874437, 'UK': 2950039, 'France': 2833687, 'India': 2051228, 'Italy': 2147744 }, { 'year': '2015', 'US': 18036650, 'China': 11181556, 'Japan': 4124211, 'Germany': 3365293, 'UK': 2858482, 'France': 2420163, 'India': 2073002, 'Italy': 1815759 }, { 'year': '2016', 'US': 18624450, 'China': 11232110, 'Japan': 4936540, 'Germany': 3479230, 'UK': 2629190, 'France': 2466470, 'India': 2263790, 'Italy': 1850740 } ]; } body { margin-bottom: 24px; } 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 Stacked Bar</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-chart [header]="'各国のGDP'" [chartType]="'Bar'" [bindingX]="'year'" [stacking]="'Stacked'" [itemsSource]="data" [palette]="['rgba(70,107,176,1)', 'rgba(200,180,34,1)', 'rgba(20,136,110,1)', 'rgba(181,72,54,1)', 'rgba(110,89,68,1)', 'rgba(139,56,114,1)', 'rgba(115,178,43,1)', 'rgba(184,115,32,1)', 'rgba(20,20,20,1)']"> <wj-flex-chart-legend [position]="'Bottom'"> </wj-flex-chart-legend> <wj-flex-chart-series [name]="'アメリカ'" [binding]="'US'"> </wj-flex-chart-series> <wj-flex-chart-series [name]="'中国'" [binding]="'China'"> </wj-flex-chart-series> <wj-flex-chart-series [name]="'日本'" [binding]="'Japan'"> </wj-flex-chart-series> <wj-flex-chart-series [name]="'ドイツ'" [binding]="'Germany'"> </wj-flex-chart-series> <wj-flex-chart-series [name]="'イギリス'" [binding]="'UK'"> </wj-flex-chart-series> <wj-flex-chart-series [name]="'フランス'" [binding]="'France'"> </wj-flex-chart-series> <wj-flex-chart-series [name]="'インド'" [binding]="'India'"> </wj-flex-chart-series> <wj-flex-chart-series [name]="'イタリア'" [binding]="'Italy'"> </wj-flex-chart-series> <wj-flex-chart-axis [wjProperty]="'axisY'" [reversed]="true"> </wj-flex-chart-axis> <wj-flex-chart-animation></wj-flex-chart-animation> </wj-flex-chart> </div> import { Injectable } from '@angular/core'; // @Injectable() export class DataService { // list of country GDP // https://en.wikipedia.org/wiki/List_of_IMF_ranked_countries_by_GDP getData() { return [ { 'year': '2014', 'US': 17348075, 'China': 10356508, 'Japan': 4602367, 'Germany': 3874437, 'UK': 2950039, 'France': 2833687, 'India': 2051228, 'Italy': 2147744 }, { 'year': '2015', 'US': 18036650, 'China': 11181556, 'Japan': 4124211, 'Germany': 3365293, 'UK': 2858482, 'France': 2420163, 'India': 2073002, 'Italy': 1815759 }, { 'year': '2016', 'US': 18624450, 'China': 11232110, 'Japan': 4936540, 'Germany': 3479230, 'UK': 2629190, 'France': 2466470, 'India': 2263790, 'Italy': 1850740 } ]; } } body { margin-bottom: 24px; } 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 * as wjChartAnimate from '@grapecity/wijmo.react.chart.animation'; import { getData } from './data'; // class App extends React.Component { constructor(props) { super(props); this.state = { data: getData(), palette: [ 'rgba(70,107,176,1)', 'rgba(200,180,34,1)', 'rgba(20,136,110,1)', 'rgba(181,72,54,1)', 'rgba(110,89,68,1)', 'rgba(139,56,114,1)', 'rgba(115,178,43,1)', 'rgba(184,115,32,1)', 'rgba(20,20,20,1)' ] }; } ; render() { return <div className="container-fluid"> <wjChart.FlexChart header="各国のGDP" chartType="Bar" bindingX="year" stacking="Stacked" itemsSource={this.state.data} palette={this.state.palette}> <wjChart.FlexChartLegend position="Bottom"></wjChart.FlexChartLegend> <wjChart.FlexChartSeries name="アメリカ" binding="US"></wjChart.FlexChartSeries> <wjChart.FlexChartSeries name="中国" binding="China"></wjChart.FlexChartSeries> <wjChart.FlexChartSeries name="日本" binding="Japan"></wjChart.FlexChartSeries> <wjChart.FlexChartSeries name="ドイツ" binding="Germany"></wjChart.FlexChartSeries> <wjChart.FlexChartSeries name="イギリス" binding="UK"></wjChart.FlexChartSeries> <wjChart.FlexChartSeries name="フランス" binding="France"></wjChart.FlexChartSeries> <wjChart.FlexChartSeries name="インド" binding="India"></wjChart.FlexChartSeries> <wjChart.FlexChartSeries name="イタリア" binding="Italy"></wjChart.FlexChartSeries> <wjChart.FlexChartAxis wjProperty="axisY" reversed={true}></wjChart.FlexChartAxis> <wjChartAnimate.FlexChartAnimation></wjChartAnimate.FlexChartAnimation> </wjChart.FlexChart> </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 Stacked Bar</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; } // list of country GDP // https://en.wikipedia.org/wiki/List_of_IMF_ranked_countries_by_GDP export function getData() { return [ { 'year': '2014', 'US': 17348075, 'China': 10356508, 'Japan': 4602367, 'Germany': 3874437, 'UK': 2950039, 'France': 2833687, 'India': 2051228, 'Italy': 2147744 }, { 'year': '2015', 'US': 18036650, 'China': 11181556, 'Japan': 4124211, 'Germany': 3365293, 'UK': 2858482, 'France': 2420163, 'India': 2073002, 'Italy': 1815759 }, { 'year': '2016', 'US': 18624450, 'China': 11232110, 'Japan': 4936540, 'Germany': 3479230, 'UK': 2629190, 'France': 2466470, 'India': 2263790, 'Italy': 1850740 } ]; } <template> <div class="container-fluid"> <wj-flex-chart header="各国のGDP" chartType="Bar" bindingX="year" stacking="Stacked" :itemsSource="data" :palette="['rgba(70,107,176,1)', 'rgba(200,180,34,1)', 'rgba(20,136,110,1)', 'rgba(181,72,54,1)', 'rgba(110,89,68,1)', 'rgba(139,56,114,1)', 'rgba(115,178,43,1)', 'rgba(184,115,32,1)', 'rgba(20,20,20,1)']"> <wj-flex-chart-legend position="Bottom"></wj-flex-chart-legend> <wj-flex-chart-series name="アメリカ" binding="US"></wj-flex-chart-series> <wj-flex-chart-series name="中国" binding="China"></wj-flex-chart-series> <wj-flex-chart-series name="日本" binding="Japan"></wj-flex-chart-series> <wj-flex-chart-series name="ドイツ" binding="Germany"></wj-flex-chart-series> <wj-flex-chart-series name="イギリス" binding="UK"></wj-flex-chart-series> <wj-flex-chart-series name="フランス" binding="France"></wj-flex-chart-series> <wj-flex-chart-series name="インド" binding="India"></wj-flex-chart-series> <wj-flex-chart-series name="イタリア" binding="Italy"></wj-flex-chart-series> <wj-flex-chart-axis wjProperty="axisY" :reversed="true"></wj-flex-chart-axis> <wj-flex-chart-animation></wj-flex-chart-animation> </wj-flex-chart> </div> </template> <script> import "@grapecity/wijmo.styles/wijmo.css"; import 'bootstrap.css'; import Vue from 'vue'; import '@grapecity/wijmo.vue2.core'; import '@grapecity/wijmo.vue2.chart'; import '@grapecity/wijmo.vue2.chart.animation'; import { getData } from './data'; let App = Vue.extend({ name: 'app', data: function () { return { data: getData() } } }) new Vue({ render: h => h(App) }).$mount('#app'); </script> <style> body { margin-bottom: 24px; } label { margin-right: 3px; } </style> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexChart Stacked Bar</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> // list of country GDP // https://en.wikipedia.org/wiki/List_of_IMF_ranked_countries_by_GDP export function getData() { return [ { 'year': '2014', 'US': 17348075, 'China': 10356508, 'Japan': 4602367, 'Germany': 3874437, 'UK': 2950039, 'France': 2833687, 'India': 2051228, 'Italy': 2147744 }, { 'year': '2015', 'US': 18036650, 'China': 11181556, 'Japan': 4124211, 'Germany': 3365293, 'UK': 2858482, 'France': 2420163, 'India': 2073002, 'Italy': 1815759 }, { 'year': '2016', 'US': 18624450, 'China': 11232110, 'Japan': 4936540, 'Germany': 3479230, 'UK': 2629190, 'France': 2466470, 'India': 2263790, 'Italy': 1850740 } ]; }