近似曲線

サンプルは近似曲線を含む散布図を示しています。

wijmo.chart.analyticsモジュールには、Seriesクラスの拡張クラスが含まれ、近似曲線、移動平均線、エラーバー、箱ひげ図、ウォーターフォール、および関数プロットを含むデータに関する追加情報を提供します。

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as chart from '@grapecity/wijmo.chart'; import * as analytics from '@grapecity/wijmo.chart.analytics'; import { getData } from './data'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { // create the chart let theChart = new chart.FlexChart('#theChart', { itemsSource: getData(), chartType: 'Scatter', bindingX: 'x', series: [ { name: 'データ', binding: 'y' } ] }); // // create a TrendLine and add it to the chart theChart.series.push(new analytics.TrendLine({ name: '近似曲線', binding: 'y', fitType: analytics.TrendLineFitType.Polynomial, order: 2, style: { stroke: 'darkred', strokeWidth: 3 } })); // // create a MovingAverage and add it to the chart theChart.series.push(new analytics.MovingAverage({ name: '移動平均線', binding: 'y', period: 6, style: { stroke: 'orange', strokeWidth: 3 } })); } <!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 Trendline</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() { let arr = [], cnt = 50, a = Math.random(), b = 0.2 + Math.random(); // for (let i = 1; i < cnt; i++) { arr.push({ x: i, y: a + i * b + i * (Math.random() - 0.5) }); } // return arr; } .wj-flexchart { height: 250px; margin: 10px 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 { WjChartAnalyticsModule } from '@grapecity/wijmo.angular2.chart.analytics'; 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, WjChartAnalyticsModule, 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 Trendline</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'" [bindingX]="'x'" [itemsSource]="data"> <wj-flex-chart-series [name]="'データ'" [binding]="'y'"> </wj-flex-chart-series> <wj-flex-chart-trend-line [name]="'近似曲線'" [binding]="'y'" [fitType]="'Polynomial'" [order]="2" [style]="{ stroke: 'darkred', strokeWidth: 3 }"></wj-flex-chart-trend-line> <wj-flex-chart-moving-average [name]="'移動平均線'" [binding]="'y'" [period]="6" [style]="{ stroke: 'orange', strokeWidth: 3 }"></wj-flex-chart-moving-average> </wj-flex-chart> </div> import { Injectable } from '@angular/core'; // @Injectable() export class DataService { getData() { let arr = [], cnt = 50, a = Math.random(), b = 0.2 + Math.random(); // for (let i = 1; i < cnt; i++) { arr.push({ x: i, y: a + i * b + i * (Math.random() - 0.5) }); } // return arr; } } .wj-flexchart { height: 250px; 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 * as wjChartAnalytics from '@grapecity/wijmo.react.chart.analytics'; import { getData } from './data'; // class App extends React.Component { constructor(props) { super(props); this.state = { data: getData() }; } render() { return <div className="container-fluid"> <wjChart.FlexChart chartType="Scatter" bindingX="x" itemsSource={this.state.data}> <wjChart.FlexChartSeries name="データ" binding="y"> </wjChart.FlexChartSeries> <wjChartAnalytics.FlexChartTrendLine name="近似曲線" binding="y" fitType="Polynomial" order={2} style={{ stroke: 'darkred', strokeWidth: 3 }}></wjChartAnalytics.FlexChartTrendLine> <wjChartAnalytics.FlexChartMovingAverage name="移動平均線" binding="y" period={6} style={{ stroke: 'orange', strokeWidth: 3 }}></wjChartAnalytics.FlexChartMovingAverage> </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>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: 250px; margin: 10px 0; } body { margin-bottom: 24pt; } export function getData() { let arr = [], cnt = 50, a = Math.random(), b = 0.2 + Math.random(); // for (let i = 1; i < cnt; i++) { arr.push({ x: i, y: a + i * b + i * (Math.random() - 0.5) }); } // return arr; } <template> <div class="container-fluid"> <wj-flex-chart chartType="Scatter" bindingX="x" :itemsSource="data"> <wj-flex-chart-series name="データ" binding="y"> </wj-flex-chart-series> <wj-flex-chart-trend-line name="近似曲線" binding="y" fitType="Polynomial" :order=2 :style="{ stroke: 'darkred', strokeWidth: 3 }"></wj-flex-chart-trend-line> <wj-flex-chart-moving-average name="移動平均線" binding="y" :period=6 :style="{ stroke: 'orange', strokeWidth: 3 }"></wj-flex-chart-moving-average> </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 '@grapecity/wijmo.vue2.chart.analytics'; import { getData } from './data'; // new Vue({ el: '#app', data: { data: getData() } }); </script> <style> .container-fluid .wj-flexchart { height: 250px; 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 Trendline</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 arr = [], cnt = 50, a = Math.random(), b = 0.2 + Math.random(); // for (let i = 1; i < cnt; i++) { arr.push({ x: i, y: a + i * b + i * (Math.random() - 0.5) }); } // return arr; }