条件付き書式

このサンプルは、itemFormatterを使用して各点を条件付きスタイルを設定した散布図を示しています。

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() { // create the chart let theChart = new chart.FlexChart('#theChart', { chartType: 'Scatter', axisY: { axisLine: true }, series: [{ name: '系列', itemsSource: getData(120, -100, 24), bindingX: 'x', binding: 'y' }], itemFormatter: (engine, ht, defaultRenderer) => { if (ht.x < 0) { engine.stroke = 'red'; engine.fill = 'rgba(255,0,0,0.7)'; } defaultRenderer(); }, palette: chart.Palettes.modern }); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexChart Scatter with Conditional Formatting</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="theChart"></div> </div> </body> </html> export function getData(cnt, a, b) { let arr = [], x = -5 * cnt / 2; // for (let i = 0; i < cnt; i++) { let rnd = Math.random() * cnt - cnt / 2; // arr.push({ x: x, y: a + x * (b + rnd) + rnd }); // x += .5 + Math.random() * 10; } // return arr; } .wj-flexchart { height: 300px; margin: 10px 0; } body { margin-bottom: 24pt; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as chart from '@grapecity/wijmo.chart'; 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'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { data: any[]; // constructor(@Inject(DataService) private dataService: DataService) { this.data = dataService.getData(120, -100, 24); } // customFormatter(engine: chart.IRenderEngine, ht: chart.HitTestInfo, defaultRenderer: () => void) { if (ht.x < 0) { engine.stroke = 'red'; engine.fill = 'rgba(255,0,0,0.7)'; } defaultRenderer(); } } // @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 Scatter with Conditional Formatting</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 [chartType]="'Scatter'" [itemFormatter]="customFormatter"> <wj-flex-chart-axis wjProperty="axisY" [axisLine]="true"> </wj-flex-chart-axis> <wj-flex-chart-axis wjProperty="axisX" [axisLine]="true"> </wj-flex-chart-axis> <wj-flex-chart-series [name]="'系列'" [itemsSource]="data" [bindingX]="'x'" [binding]="'y'"> </wj-flex-chart-series> </wj-flex-chart> </div> import { Injectable } from '@angular/core'; // @Injectable() export class DataService { getData(cnt: number, a: number, b: number) { let arr = [], x = -5 * cnt / 2; // for (let i = 0; i < cnt; i++) { let rnd = Math.random() * cnt - cnt / 2; // arr.push({ x: x, y: a + x * (b + rnd) + rnd }); // x += .5 + Math.random() * 10; } // return arr; } } .wj-flexchart { height: 300px; margin: 10px 0; } body { margin-bottom: 24pt; } 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.state = { data: getData(120, -100, 24) }; } render() { return <div className="container-fluid"> <wjChart.FlexChart chartType="Scatter" itemFormatter={this.customFormatter}> <wjChart.FlexChartAxis wjProperty="axisY" axisLine={true}> </wjChart.FlexChartAxis> <wjChart.FlexChartAxis wjProperty="axisX" axisLine={true}> </wjChart.FlexChartAxis> <wjChart.FlexChartSeries name="系列" itemsSource={this.state.data} bindingX="x" binding="y"> </wjChart.FlexChartSeries> </wjChart.FlexChart> </div>; } customFormatter(engine, ht, defaultRenderer) { if (ht.x < 0) { engine.stroke = 'red'; engine.fill = 'rgba(255,0,0,0.7)'; } defaultRenderer(); } } 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> .wj-flexchart { height: 300px; margin: 10px 0; } body { margin-bottom: 24pt; } export function getData(cnt, a, b) { let arr = [], x = -5 * cnt / 2; // for (let i = 0; i < cnt; i++) { let rnd = Math.random() * cnt - cnt / 2; // arr.push({ x: x, y: a + x * (b + rnd) + rnd }); // x += .5 + Math.random() * 10; } // return arr; } <template> <div class="container-fluid"> <wj-flex-chart chartType="Scatter" :itemFormatter="customFormatter"> <wj-flex-chart-axis wjProperty="axisY" :axisLine=true> </wj-flex-chart-axis> <wj-flex-chart-axis wjProperty="axisX" :axisLine=true> </wj-flex-chart-axis> <wj-flex-chart-series name="系列" :itemsSource="data" bindingX="x" binding="y"> </wj-flex-chart-series> </wj-flex-chart> </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(120, -100, 24) }, methods: { customFormatter(engine, ht, defaultRenderer) { if (ht.x < 0) { engine.stroke = 'red'; engine.fill = 'rgba(255,0,0,0.7)'; } defaultRenderer(); } } }); </script> <style> .container-fluid .wj-flexchart { height: 300px; margin: 10px 0; } 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 FlexChart Scatter with Conditional Formatting</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(cnt, a, b) { let arr = [], x = -5 * cnt / 2; // for (let i = 0; i < cnt; i++) { let rnd = Math.random() * cnt - cnt / 2; // arr.push({ x: x, y: a + x * (b + rnd) + rnd }); // x += .5 + Math.random() * 10; } // return arr; }