ゲージ:スタイル

ゲージコントロールの外観は、主にCSSで定義されています。外観をカスタマイズするには、デフォルトのテーマのCSSルールを新しいCSSファイルにコピーし、必要に応じて変更します。

このサンプルでは、ゲージを使用してパネルの色を編集します。

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as wjCore from '@grapecity/wijmo'; import * as wjGauge from '@grapecity/wijmo.gauge'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { // color being edited let theColor = new wjCore.Color('grey'), thePanel = document.getElementById('thePanel'), updateColor = () => { thePanel.style.background = theColor.toString(); }; // updateColor(); // // create the gauges let red = new wjGauge.LinearGauge('#red', { value: theColor.r, valueChanged: (s) => { theColor.r = s.value; updateColor(); } }); initGauge(red, 'red'); // let green = new wjGauge.LinearGauge('#green', { value: theColor.g, valueChanged: (s) => { theColor.g = s.value; updateColor(); } }); initGauge(green, 'green'); // let blue = new wjGauge.LinearGauge('#blue', { value: theColor.b, valueChanged: (s) => { theColor.b = s.value; updateColor(); } }); initGauge(blue, 'blue'); } // function initGauge(g, color) { g.isReadOnly = false; g.thumbSize = 10; g.hasShadow = false; g.min = 0; g.max = 255; g.step = 5; g.showTicks = true; g.tickSpacing = 25; g.face.thickness = 0.2; g.pointer.thickness = 0.3; g.pointer.color = color; g.hostElement.style.color = color; } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Gauge Styling</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="thePanel"></div> <div id="red"></div> <div id="green"></div> <div id="blue"></div> </div> </body> </html> #thePanel { width: 70%; margin: 20px auto; height: 100px; box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23); } .wj-gauge { width: 70%; margin: 20px auto; } .wj-gauge .wj-ticks { stroke: f0f0f0; stroke-width: 2px; } .wj-gauge .wj-face path { fill: #f0f0f0; stroke: #e0e0e0; } .wj-gauge.wj-state-focused circle.wj-pointer { stroke-width: 8px; stroke: currentColor; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as wijmo from '@grapecity/wijmo'; import * as gauge from '@grapecity/wijmo.gauge'; // import { Component, enableProdMode, NgModule } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { FormsModule} from '@angular/forms'; import { BrowserModule } from '@angular/platform-browser'; import { WjGaugeModule } from '@grapecity/wijmo.angular2.gauge'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { color = new wijmo.Color('grey'); // initGauge(g: gauge.RadialGauge, color: string) { g.isReadOnly = false; g.thumbSize = 10; g.hasShadow = false; g.min = 0; g.max = 255; g.step = 5; g.showTicks = true; g.tickSpacing = 25; g.face.thickness = 0.2; g.pointer.thickness = 0.3; g.pointer.color = color; g.hostElement.style.color = color; } } // @NgModule({ imports: [WjGaugeModule, BrowserModule, FormsModule], declarations: [AppComponent], 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>Gauge Styling</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 id="thePanel" [style.background]='color.toString()'></div> <wj-linear-gauge #red [(value)]="color.r" (initialized)="initGauge(red, 'red')"> </wj-linear-gauge> <wj-linear-gauge #green [(value)]="color.g" (initialized)="initGauge(green, 'green')"> </wj-linear-gauge> <wj-linear-gauge #blue [(value)]="color.b" (initialized)="initGauge(blue, 'blue')"> </wj-linear-gauge> </div> #thePanel { width: 70%; margin: 20px auto; height: 100px; box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23); } .wj-gauge { width: 70%; margin: 20px auto; } .wj-gauge .wj-ticks { stroke: f0f0f0; stroke-width: 2px; } .wj-gauge .wj-face path { fill: #f0f0f0; stroke: #e0e0e0; } .wj-gauge.wj-state-focused circle.wj-pointer { stroke-width: 8px; stroke: currentColor; } import './app.css'; import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; // import * as React from 'react'; import * as ReactDOM from 'react-dom'; // import * as wjGauge from '@grapecity/wijmo.react.gauge'; import * as wijmo from '@grapecity/wijmo'; class App extends React.Component { constructor(props) { super(props); this.theColor = new wijmo.Color('grey'); this._rgb = { r: null, g: null, b: null }; this.state = { theColor: this.theColor, red: this.theColor.r, green: this.theColor.g, blue: this.theColor.b }; } render() { return (<div className="container-fluid"> <div id="thePanel" style={{ background: this.state.theColor.toString() }}></div> <wjGauge.LinearGauge id="red" value={this.state.red} initialized={(s) => this.initGauge(s, "r")} valueChanged={() => this.updateColor("r")}> </wjGauge.LinearGauge> <wjGauge.LinearGauge id="green" value={this.state.green} initialized={(s) => this.initGauge(s, "g")} valueChanged={() => this.updateColor("g")}> </wjGauge.LinearGauge> <wjGauge.LinearGauge id="blue" value={this.state.blue} initialized={(s) => this.initGauge(s, "b")} valueChanged={() => this.updateColor("b")}> </wjGauge.LinearGauge> </div>); } updateColor(type) { this.theColor[type] = this._rgb[type].value; this.setState({ theColor: this.theColor, red: this.theColor.r, green: this.theColor.g, blue: this.theColor.b }); } initGauge(s, type) { this._rgb[type] = s; let g = s, color = s.hostElement.id; g.isReadOnly = false; g.thumbSize = 10; g.hasShadow = false; g.min = 0; g.max = 255; g.step = 5; g.showTicks = true; g.tickSpacing = 25; g.face.thickness = 0.2; g.pointer.thickness = 0.3; g.pointer.color = color; g.hostElement.style.color = color; } } 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>Gauge Styling</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> #thePanel { width: 70%; margin: 20px auto; height: 100px; box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23); } .container-fluid .wj-gauge { width: 70%; margin: 20px auto; } .container-fluid .wj-gauge .wj-ticks { stroke: f0f0f0; stroke-width: 2px; } .container-fluid .wj-gauge .wj-face path { fill: #f0f0f0; stroke: #e0e0e0; } .container-fluid .wj-gauge.wj-state-focused circle.wj-pointer { stroke-width: 8px; stroke: currentColor; } <template> <div class="container-fluid"> <div id="thePanel" v-bind:style="{background: theColor.toString()}"></div> <wj-linear-gauge id="red" :value="color.red" :initialized="initGauge" :valueChanged="updateColor"> </wj-linear-gauge> <wj-linear-gauge id="green" :value="color.green" :initialized="initGauge" :valueChanged="updateColor"> </wj-linear-gauge> <wj-linear-gauge id="blue" :value="color.blue" :initialized="initGauge" :valueChanged="updateColor"> </wj-linear-gauge> </div> </template> <script> import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import 'src/app.css'; import Vue from 'vue'; import * as wijmo from '@grapecity/wijmo'; import '@grapecity/wijmo.vue2.gauge'; let App = Vue.extend({ name: 'app', data: function(){ let theColor = new wijmo.Color('grey'); return { theColor: theColor, color: { red: theColor.r, green: theColor.g, blue: theColor.b } } }, methods: { updateColor: function(s,e){ let rgb = { red: 'r', green: 'g', blue: 'b' } this.theColor[rgb[s.hostElement.id]] = s.value; }, initGauge: function(s,e) { let g = s, color = s.hostElement.id; g.isReadOnly = false; g.thumbSize = 10; g.hasShadow = false; g.min = 0; g.max = 255; g.step = 5; g.showTicks = true; g.tickSpacing = 25; g.face.thickness = 0.2; g.pointer.thickness = 0.3; g.pointer.color = color; g.hostElement.style.color = color; } } }) new Vue({ render: h => h(App) }).$mount('#app'); </script> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Gauge Styling</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>