多个绘图区域

堆叠图表控件是创建具有多个绘图区域的单个图表的替代方法。 使用 plotMargin 属性确保图表正确排列。

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as wjChart from '@grapecity/wijmo.chart'; import { getData } from './data'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { // create the chart for showing amounts let theChart = new wjChart.FlexChart('#theChart', { itemsSource: getData(), header: 'Sales, Expenses, and Downloads', bindingX: 'country', series: [ { binding: 'sales', name: 'Sales' }, { binding: 'expenses', name: 'Expenses' }, { binding: 'downloads', name: 'Downloads', chartType: 'LineSymbols' } ], }); theChart.palette = getRandomPalette(); //// create a plot area for amounts var p = new wjChart.PlotArea(); p.row = theChart.plotAreas.length; p.name = 'amounts'; p.height = '2*'; theChart.plotAreas.push(p); // create a spacer plot area p = new wjChart.PlotArea(); p.row = theChart.plotAreas.length; p.name = 'spacer'; p.height = 25; theChart.plotAreas.push(p); // create a plot area for quantities p = new wjChart.PlotArea(); p.row = theChart.plotAreas.length; p.name = 'quantities'; p.height = '*'; var axisYQty = new wjChart.Axis(wjChart.Position.Left); axisYQty.plotArea = p; theChart.series[2].axisY = axisYQty; theChart.plotAreas.push(p); } // function getRandomPalette() { let palettes = Object.getOwnPropertyNames(wjChart.Palettes) .filter(prop => typeof wjChart.Palettes[prop] === "object" && prop !== 'prototype'); let rand = Math.floor(Math.random() * palettes.length); // return wjChart.Palettes[palettes[rand]]; } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexChart Multiple Plot Areas</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="chart-holder"> <div id="theChart"></div> </div> </div> </body> </html> // create some random data export function getData() { let countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = []; // for (let i = 0; i < countries.length; i++) { data.push({ country: countries[i], sales: Math.random() * 10000, expenses: Math.random() * 5000, downloads: Math.round(Math.random() * 20000) }); } // return data; } .chart-holder { padding: 15px 10px; margin-bottom: 12px; border: 1px solid rgba(0,0,0,0.2); border-radius: 4px; } .wj-flexchart { border: none; padding: 0; margin: 0; } body { margin-bottom: 24pt; } 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 { DataService } from './app.data'; import * as wjChart from '@grapecity/wijmo.chart'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { data: any[]; palette: any; // constructor(@Inject(DataService) private dataService: DataService) { this.data = dataService.getData(); this.palette = this.getRandomPalette(); } // getRandomPalette() { let palettes = Object.getOwnPropertyNames(wjChart.Palettes) .filter(prop => typeof wjChart.Palettes[prop] === "object" && prop !== 'prototype'); let rand = Math.floor(Math.random() * palettes.length); // return wjChart.Palettes[palettes[rand]]; } } // @NgModule({ imports: [WjChartModule, 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 Plot Areas</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="form-group"> <wj-flex-chart [itemsSource]="data" header="Sales, Expenses, and Downloads" bindingX="country" [palette]="palette"> <wj-flex-chart-series binding="sales" name="Sales"></wj-flex-chart-series> <wj-flex-chart-series binding="expenses" name="Expenses"></wj-flex-chart-series> <wj-flex-chart-series binding="downloads" name="Downloads" chartType="LineSymbols"> <wj-flex-chart-axis wjProperty="axisY" position="Left" [plotArea]="plot"></wj-flex-chart-axis> </wj-flex-chart-series> <wj-flex-chart-plot-area [row]="0" name="amounts" height="2*"></wj-flex-chart-plot-area> <wj-flex-chart-plot-area [row]="1" name="spacer" [height]="25"></wj-flex-chart-plot-area> <wj-flex-chart-plot-area #plot [row]="2" name="quantities" height="*"></wj-flex-chart-plot-area> </wj-flex-chart> </div> </div> import { Injectable } from '@angular/core'; // @Injectable() export class DataService { getData() { let countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = []; // for (let i = 0; i < countries.length; i++) { data.push({ country: countries[i], sales: Math.random() * 10000, expenses: Math.random() * 5000, downloads: Math.round(Math.random() * 20000) }); } // return data; } } .chart-holder { padding: 15px 10px; margin-bottom: 12px; border: 1px solid rgba(0,0,0,0.2); border-radius: 4px; } .wj-flexchart { border: none; padding: 0; margin: 0; } body { margin-bottom: 24pt; } <template> <div class="container-fluid"> <div class="form-group"> <wj-flex-chart :itemsSource="data" header="Sales, Expenses, and Downloads" bindingX="country" :palette="palette" :initialized="initializeChart"> <wj-flex-chart-series binding="sales" name="Sales"></wj-flex-chart-series> <wj-flex-chart-series binding="expenses" name="Expenses"></wj-flex-chart-series> <wj-flex-chart-series binding="downloads" name="Downloads" chartType="LineSymbols"> <wj-flex-chart-axis wjProperty="axisY" position="Left" :plotArea="plot"></wj-flex-chart-axis> </wj-flex-chart-series> <wj-flex-chart-plot-area :row="0" name="amounts" height="2*"></wj-flex-chart-plot-area> <wj-flex-chart-plot-area :row="1" name="spacer" :height="25"></wj-flex-chart-plot-area> </wj-flex-chart> </div> </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 { getData } from './data'; import * as wjChart from '@grapecity/wijmo.chart'; let App = Vue.extend({ name: 'app', data: function () { return { data: getData(), palette: this.getRandomPalette(), plot: null } }, methods: { initializeChart: function(flex) { let p = new wjChart.PlotArea(); p.row = flex.plotAreas.length; p.name = 'quantities'; p.height = '*'; flex.plotAreas.push(p); this.plot = p; }, getRandomPalette: function() { let palettes = Object.getOwnPropertyNames(wjChart.Palettes) .filter(prop => typeof wjChart.Palettes[prop] === "object" && prop !== 'prototype'); let rand = Math.floor(Math.random() * palettes.length); // return wjChart.Palettes[palettes[rand]]; } } }) 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 Multiple Plot Areas</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() { let countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = []; // for (let i = 0; i < countries.length; i++) { data.push({ country: countries[i], sales: Math.random() * 10000, expenses: Math.random() * 5000, downloads: Math.round(Math.random() * 20000) }); } // return data; } import "@grapecity/wijmo.styles/wijmo.css"; import "bootstrap.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 wjcChart from "@grapecity/wijmo.chart"; import { getData } from "./data"; class App extends React.Component { constructor(props) { super(props); this.state = { data: getData(), palette: this.getRandomPalette(), plot: null }; } render() { return <div className="container-fluid"> <div className="form-group"> <wjChart.FlexChart itemsSource={this.state.data} header="Sales, Expenses, and Downloads" bindingX="country" palette={this.state.palette} initialized={this.initializeChart.bind(this)}> <wjChart.FlexChartSeries binding="sales" name="Sales"></wjChart.FlexChartSeries> <wjChart.FlexChartSeries binding="expenses" name="Expenses"></wjChart.FlexChartSeries> <wjChart.FlexChartSeries binding="downloads" name="Downloads" chartType="LineSymbols"> <wjChart.FlexChartAxis wjProperty="axisY" position="Left" plotArea={this.state.plot}></wjChart.FlexChartAxis> </wjChart.FlexChartSeries> <wjChart.FlexChartPlotArea row={0} name="amounts" height="2*"></wjChart.FlexChartPlotArea> <wjChart.FlexChartPlotArea row={1} name="spacer" height={25}></wjChart.FlexChartPlotArea> </wjChart.FlexChart> </div> </div>; } initializeChart(flex) { let p = new wjcChart.PlotArea(); p.row = flex.plotAreas.length; p.name = 'quantities'; p.height = '*'; flex.plotAreas.push(p); this.setState({ plot: p }); } getRandomPalette() { let palettes = Object.getOwnPropertyNames(wjcChart.Palettes) .filter(prop => typeof wjcChart.Palettes[prop] === "object" && prop !== 'prototype'); let rand = Math.floor(Math.random() * palettes.length); // return wjcChart.Palettes[palettes[rand]]; } } 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 Overview</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; } label { margin-right: 3px; } export function getData() { let countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = []; // for (let i = 0; i < countries.length; i++) { data.push({ country: countries[i], sales: Math.random() * 10000, expenses: Math.random() * 5000, downloads: Math.round(Math.random() * 20000) }); } // return data; }