Angular リニア ゲージの概要
Ignite UI for Angular リニア ゲージ コンポーネントを使用すると、リニア ゲージの形式でデータを視覚化できます。IgxLinearGaugeComponent
は、スケールおよび 1 つ以上の範囲と比較した値のシンプルで簡潔なビューを提供します。1 つのスケール、1 セットの目盛り、および 1 セットのラベルをサポートします。このコンポーネントには、アニメーション化されたトランジションのサポートも組み込まれており、アニメーションでは、transitionDuration
プロパティの設定で簡単にカスタマイズできます。また構成可能な向きや方向、視覚要素やツールチップなどがサポートされます。
Angular リニア ゲージの例
以下のサンプルは、同じ IgxLinearGaugeComponent
でいくつかのプロパティを設定して全く異なるゲージにする方法を示します。
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { CommonModule } from "@angular/common" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { IgxLinearGaugeModule } from "igniteui-angular-gauges" ;
import { IgxButtonModule } from "igniteui-angular" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
],
imports : [
BrowserModule,
BrowserAnimationsModule,
CommonModule,
FormsModule,
IgxLinearGaugeModule,
IgxButtonModule
],
providers : [],
schemas : []
})
export class AppModule {}
ts コピー import { AfterViewInit, Component, ViewChild } from "@angular/core" ;
import { IgxLinearGaugeComponent } from "igniteui-angular-gauges" ;
import { IgxLinearGraphRangeComponent } from "igniteui-angular-gauges" ;
import { LinearGraphNeedleShape } from "igniteui-angular-gauges" ;
@Component ({
standalone : false ,
selector : "app-root" ,
styleUrls : ["./app.component.scss" ],
templateUrl : "./app.component.html"
})
export class AppComponent implements AfterViewInit {
@ViewChild ("linearGauge" , { static : true })
public linearGauge: IgxLinearGaugeComponent;
private shouldAnimate: boolean = false ;
public ngAfterViewInit(): void {
this .AnimateToGauge3();
}
public AnimateToGauge3(): void {
if (this .shouldAnimate){
this .linearGauge.transitionDuration = 500 ;
}
this .linearGauge.minimumValue = 0 ;
this .linearGauge.maximumValue = 100 ;
this .linearGauge.value = 50 ;
this .linearGauge.interval = 10 ;
this .linearGauge.labelInterval = 10 ;
this .linearGauge.labelExtent = 0.05 ;
this .linearGauge.isNeedleDraggingEnabled = true ;
this .linearGauge.needleShape = LinearGraphNeedleShape.Needle;
this .linearGauge.needleBrush = "#79797a" ;
this .linearGauge.needleOutline = "#ffffffff" ;
this .linearGauge.needleStrokeThickness = 1 ;
this .linearGauge.needleOuterExtent = 0.9 ;
this .linearGauge.needleInnerExtent = 0.3 ;
this .linearGauge.minorTickCount = 5 ;
this .linearGauge.minorTickEndExtent = 0.10 ;
this .linearGauge.minorTickStartExtent = 0.20 ;
this .linearGauge.minorTickStrokeThickness = 1 ;
this .linearGauge.tickStartExtent = 0.25 ;
this .linearGauge.tickEndExtent = 0.05 ;
this .linearGauge.tickStrokeThickness = 2 ;
const range1 = new IgxLinearGraphRangeComponent();
range1.startValue = 0 ;
range1.endValue = 30 ;
const range2 = new IgxLinearGraphRangeComponent();
range2.startValue = 30 ;
range2.endValue = 70 ;
const range3 = new IgxLinearGraphRangeComponent();
range3.startValue = 70 ;
range3.endValue = 100 ;
this .linearGauge.rangeBrushes = [ "#9FB328" , "#438C47" , "#3F51B5" ];
this .linearGauge.rangeOutlines = [ "#9FB328" , "#438C47" , "#3F51B5" ];
this .linearGauge.ranges.clear();
this .linearGauge.ranges.add(range1);
this .linearGauge.ranges.add(range2);
this .linearGauge.ranges.add(range3);
for (let i = 0 ; i < this .linearGauge.ranges.count; i++) {
const range = this .linearGauge.ranges.item(i);
range.innerStartExtent = 0.075 ;
range.innerEndExtent = 0.075 ;
range.outerStartExtent = 0.65 ;
range.outerEndExtent = 0.65 ;
}
this .linearGauge.scaleStrokeThickness = 0 ;
this .linearGauge.scaleBrush = "#ffffff" ;
this .linearGauge.scaleOutline = "#dbdbdb" ;
this .linearGauge.scaleInnerExtent = 0.075 ;
this .linearGauge.scaleOuterExtent = 0.85 ;
this .linearGauge.scaleStartExtent = 0.05 ;
this .linearGauge.scaleEndExtent = 0.95 ;
this .linearGauge.backingBrush = "#ffffff" ;
this .linearGauge.backingOutline = "#d1d1d1" ;
this .linearGauge.backingStrokeThickness = 0 ;
this .shouldAnimate = true ;
}
public AnimateToGauge2(): void {
if (this .shouldAnimate) {
this .linearGauge.transitionDuration = 500 ;
}
this .linearGauge.minimumValue = 100 ;
this .linearGauge.maximumValue = 200 ;
this .linearGauge.value = 150 ;
this .linearGauge.interval = 20 ;
this .linearGauge.labelInterval = 20 ;
this .linearGauge.labelExtent = 0.05 ;
this .linearGauge.isNeedleDraggingEnabled = true ;
this .linearGauge.needleShape = LinearGraphNeedleShape.Triangle;
this .linearGauge.needleBrush = "#79797a" ;
this .linearGauge.needleOutline = "#ffffffff" ;
this .linearGauge.needleStrokeThickness = 1 ;
this .linearGauge.needleOuterExtent = 0.9 ;
this .linearGauge.needleInnerExtent = 0.3 ;
this .linearGauge.minorTickCount = 4 ;
this .linearGauge.minorTickEndExtent = 0.10 ;
this .linearGauge.minorTickStartExtent = 0.20 ;
this .linearGauge.minorTickStrokeThickness = 1 ;
this .linearGauge.tickStartExtent = 0.25 ;
this .linearGauge.tickEndExtent = 0.05 ;
this .linearGauge.tickStrokeThickness = 2 ;
const range1 = new IgxLinearGraphRangeComponent();
range1.startValue = 100 ;
range1.endValue = 125 ;
const range2 = new IgxLinearGraphRangeComponent();
range2.startValue = 125 ;
range2.endValue = 150 ;
const range3 = new IgxLinearGraphRangeComponent();
range3.startValue = 150 ;
range3.endValue = 175 ;
const range4 = new IgxLinearGraphRangeComponent();
range4.startValue = 175 ;
range4.endValue = 200 ;
this .linearGauge.rangeBrushes = ["#0078C8" , "#0099FF" , "#21A7FF" , "#4FB9FF" ];
this .linearGauge.rangeOutlines = ["#0078C8" , "#0099FF" , "#21A7FF" , "#4FB9FF" ];
this .linearGauge.ranges.clear();
this .linearGauge.ranges.add(range1);
this .linearGauge.ranges.add(range2);
this .linearGauge.ranges.add(range3);
this .linearGauge.ranges.add(range4);
for (let i = 0 ; i < this .linearGauge.ranges.count; i++) {
const range = this .linearGauge.ranges.item(i);
range.innerStartExtent = 0.075 ;
range.innerEndExtent = 0.075 ;
range.outerStartExtent = 0.65 ;
range.outerEndExtent = 0.65 ;
}
this .linearGauge.scaleStrokeThickness = 0 ;
this .linearGauge.scaleBrush = "#ffffff" ;
this .linearGauge.scaleOutline = "#dbdbdb" ;
this .linearGauge.scaleInnerExtent = 0.075 ;
this .linearGauge.scaleOuterExtent = 0.85 ;
this .linearGauge.scaleStartExtent = 0.05 ;
this .linearGauge.scaleEndExtent = 0.95 ;
this .linearGauge.backingBrush = "#ffffff" ;
this .linearGauge.backingOutline = "#d1d1d1" ;
this .linearGauge.backingStrokeThickness = 0 ;
this .shouldAnimate = true ;
}
public AnimateToGauge1(): void {
if (this .shouldAnimate) {
this .linearGauge.transitionDuration = 500 ;
}
this .linearGauge.minimumValue = 0 ;
this .linearGauge.maximumValue = 80 ;
this .linearGauge.value = 60 ;
this .linearGauge.interval = 20 ;
this .linearGauge.labelInterval = 20 ;
this .linearGauge.labelExtent = 0.05 ;
this .linearGauge.isNeedleDraggingEnabled = true ;
this .linearGauge.needleShape = LinearGraphNeedleShape.Trapezoid;
this .linearGauge.needleBrush = "#79797a" ;
this .linearGauge.needleOutline = "#ffffffff" ;
this .linearGauge.needleStrokeThickness = 1 ;
this .linearGauge.needleOuterExtent = 0.9 ;
this .linearGauge.needleInnerExtent = 0.3 ;
this .linearGauge.minorTickCount = 5 ;
this .linearGauge.minorTickEndExtent = 0.10 ;
this .linearGauge.minorTickStartExtent = 0.20 ;
this .linearGauge.minorTickStrokeThickness = 1 ;
this .linearGauge.tickStartExtent = 0.25 ;
this .linearGauge.tickEndExtent = 0.05 ;
this .linearGauge.tickStrokeThickness = 2 ;
const range1 = new IgxLinearGraphRangeComponent();
range1.startValue = 0 ;
range1.endValue = 40 ;
const range2 = new IgxLinearGraphRangeComponent();
range2.startValue = 40 ;
range2.endValue = 80 ;
this .linearGauge.rangeBrushes = [ "#a4bd29" , "#F86232" ];
this .linearGauge.rangeOutlines = [ "#a4bd29" , "#F86232" ];
this .linearGauge.ranges.clear();
this .linearGauge.ranges.add(range1);
this .linearGauge.ranges.add(range2);
for (let i = 0 ; i < this .linearGauge.ranges.count; i++) {
const range = this .linearGauge.ranges.item(i);
range.innerStartExtent = 0.075 ;
range.innerEndExtent = 0.075 ;
range.outerStartExtent = 0.65 ;
range.outerEndExtent = 0.65 ;
}
this .linearGauge.scaleStrokeThickness = 0 ;
this .linearGauge.scaleBrush = "#ffffff" ;
this .linearGauge.scaleOutline = "#dbdbdb" ;
this .linearGauge.scaleInnerExtent = 0.075 ;
this .linearGauge.scaleOuterExtent = 0.85 ;
this .linearGauge.scaleStartExtent = 0.05 ;
this .linearGauge.scaleEndExtent = 0.95 ;
this .linearGauge.backingBrush = "#ffffff" ;
this .linearGauge.backingOutline = "#d1d1d1" ;
this .linearGauge.backingStrokeThickness = 0 ;
this .shouldAnimate = true ;
}
}
ts コピー <div class ="container vertical" >
<div class ="options horizontal" >
<button (click )="AnimateToGauge1()"
class ="options-button" > Animation #1</button >
<button (click )="AnimateToGauge2()"
class ="options-button" > Animation #2</button >
<button (click )="AnimateToGauge3()"
class ="options-button" > Animation #3</button >
</div >
<div class ="container" >
<igx-linear-gauge
#linearGauge
height ="80px"
width ="400px"
minimumValue =0
maximumValue =100
value =50
interval =10
labelInterval =10
labelExtent =0.02
minorTickEndExtent =0.10,
minorTickStartExtent =0.20,
tickStartExtent =0.25,
tickEndExtent =0.05,
tickStrokeThickness =2,
needleShape ="Needle"
needleBrush ="#79797a"
needleOutline ="#79797a"
scaleStrokeThickness =0
scaleBrush ="#ffffff"
scaleOutline ="#d3d3d3"
backingBrush ="#ffffff"
backingOutline ="#d1d1d1"
backingStrokeThickness =0 >
</igx-linear-gauge >
</div >
</div >
html コピー
このサンプルが気に入りましたか? 完全な Ignite UI for Angularツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
依存関係
Angular gauge コンポーネントをインストールするときに core パッケージもインストールする必要があります。
npm install --save igniteui-angular-core
npm install --save igniteui-angular-gauges
cmd
モジュールの要件
IgxLinearGaugeComponent
を作成するには、以下のモジュールが必要です。
import { IgxLinearGaugeModule } from 'igniteui-angular-gauges' ;
@NgModule ({
imports : [
IgxLinearGaugeModule
]
})
export class AppModule {}
ts
使用方法
以下のコードは針およびスケールで 3 つの比較範囲を含むリニア ゲージを作成する方法を紹介します。
<igx-linear-gauge width ="700px"
height ="30px"
minimumValue ="5"
maximumValue ="55"
value ="43" >
<igx-linear-graph-range startValue ="0"
endValue ="15"
brush ="red" >
</igx-linear-graph-range >
<igx-linear-graph-range startValue ="15"
endValue ="30"
brush ="yellow" >
</igx-linear-graph-range >
<igx-linear-graph-range startValue ="30"
endValue ="55"
brush ="green" >
</igx-linear-graph-range >
</igx-linear-gauge >
html
針
これは、コンポーネントで表示されるプライマリ メジャーでバーで可視化されます。あるいは以下で示す図形のほとんどすべてをカスタマイズすることもできます。
<igx-linear-gauge
height ="80px" width ="400px"
minimumValue =0
maximumValue =100 interval =10
value =50
isNeedleDraggingEnabled =true
needleShape ="Custom"
needleBrush ="DodgerBlue"
needleOutline ="DodgerBlue"
needleStrokeThickness =1
needleBreadth =15
needleInnerExtent =0.35
needleOuterExtent =0.65
needleOuterPointExtent =0.8
needleInnerPointExtent =0.325
needleInnerPointWidth =0
needleOuterPointWidth =0.3
needleInnerBaseWidth =0
needleOuterBaseWidth =0.07 >
</igx-linear-gauge >
html
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { CommonModule } from "@angular/common" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { IgxLinearGaugeModule } from "igniteui-angular-gauges" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
],
imports : [
BrowserModule,
BrowserAnimationsModule,
CommonModule,
FormsModule,
IgxLinearGaugeModule
],
providers : [],
schemas : []
})
export class AppModule {}
ts コピー import { Component, ViewChild } from "@angular/core" ;
import { IgxLinearGaugeComponent } from "igniteui-angular-gauges" ;
@Component ({
standalone : false ,
selector : "app-root" ,
styleUrls : ["./app.component.scss" ],
templateUrl : "./app.component.html"
})
export class AppComponent {
@ViewChild ("linearGauge" , { static : true })
public linearGauge: IgxLinearGaugeComponent;
}
ts コピー <div class ="container vertical" >
<igx-linear-gauge
#linearGauge
height ="80px" width ="400px"
minimumValue =0 value =50
maximumValue =100 interval =10
isNeedleDraggingEnabled =true
needleShape ="Custom"
needleBrush ="DodgerBlue"
needleOutline ="DodgerBlue"
needleStrokeThickness =1
needleBreadth =15
needleInnerExtent =0.35
needleOuterExtent =0.65
needleOuterPointExtent =0.8
needleInnerPointExtent =0.325
needleInnerPointWidth =0
needleOuterPointWidth =0.3
needleInnerBaseWidth =0
needleOuterBaseWidth =0.07
>
</igx-linear-gauge >
</div >
html コピー
針のハイライト
リニア ゲージを変更して、2 番目の針を表示できます。これにより、メイン針の value
の不透明度が低く表示されます。これを有効にするには、まず highlightValueDisplayMode
を Overlay に設定し、次に highlightValue
を適用します。
<igx-linear-gauge
#linearGauge
height ="80px"
width ="400px"
value =70
minimumValue =0
maximumValue =100
interval =10
labelInterval =10
labelExtent =0.025
labelsPreTerminal =0
labelsPostInitial =0
needleBrush ="Blue"
highlightValueDisplayMode ="Overlay"
highlightValue =25
isHighlightNeedleDraggingEnabled =true >
</igx-linear-gauge >
html
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { CommonModule } from "@angular/common" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { IgxLinearGaugeModule } from "igniteui-angular-gauges" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
],
imports : [
BrowserModule,
BrowserAnimationsModule,
CommonModule,
FormsModule,
IgxLinearGaugeModule
],
providers : [],
schemas : []
})
export class AppModule {}
ts コピー import { Component, ViewChild } from "@angular/core" ;
import { IgxLinearGaugeComponent } from "igniteui-angular-gauges" ;
@Component ({
standalone : false ,
selector : "app-root" ,
styleUrls : ["./app.component.scss" ],
templateUrl : "./app.component.html"
})
export class AppComponent {
@ViewChild ("linearGauge" , { static : true })
public linearGauge: IgxLinearGaugeComponent;
}
ts コピー <div class ="container vertical" >
<igx-linear-gauge
#linearGauge
height ="80px"
width ="400px"
value =70
minimumValue =0
maximumValue =100
interval =10
labelInterval =10
labelExtent =0.025
labelsPreTerminal =0
labelsPostInitial =0
needleBrush ="Blue"
highlightValueDisplayMode ="Overlay"
highlightValue =25
isHighlightNeedleDraggingEnabled =true >
</igx-linear-gauge >
</div >
html コピー
範囲
範囲はスケールで指定した値の範囲をハイライト表示する視覚的な要素です。その目的は、パフォーマンス バー メジャーの質的状態を視覚で伝えると同時に、その状態をレベルとして示すことにあります。
<igx-linear-gauge
height ="80px" width ="400px"
minimumValue =0 value =50
maximumValue =100 interval =10
rangeBrushes ="#a4bd29, #F86232"
rangeOutlines ="#a4bd29, #F86232" >
<igx-linear-graph-range
startValue =0 endValue =50
innerStartExtent =0.075 innerEndExtent =0.075
outerStartExtent =0.25 outerEndExtent =0.4 >
</igx-linear-graph-range >
<igx-linear-graph-range
startValue =50 endValue =100
innerStartExtent =0.075 innerEndExtent =0.075
outerStartExtent =0.4 outerEndExtent =0.55 >
</igx-linear-graph-range >
</igx-linear-gauge >
html
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { CommonModule } from "@angular/common" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { IgxLinearGaugeModule } from "igniteui-angular-gauges" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
],
imports : [
BrowserModule,
BrowserAnimationsModule,
CommonModule,
FormsModule,
IgxLinearGaugeModule
],
providers : [],
schemas : []
})
export class AppModule {}
ts コピー import { Component, ViewChild } from "@angular/core" ;
import { IgxLinearGaugeComponent } from "igniteui-angular-gauges" ;
@Component ({
standalone : false ,
selector : "app-root" ,
styleUrls : ["./app.component.scss" ],
templateUrl : "./app.component.html"
})
export class AppComponent {
@ViewChild ("linearGauge" , { static : true })
public linearGauge: IgxLinearGaugeComponent;
}
ts コピー <div class ="container vertical" >
<igx-linear-gauge
#linearGauge
height ="80px" width ="400px"
minimumValue =0 value =50
maximumValue =100 interval =10
rangeBrushes ="#a4bd29, #F86232"
rangeOutlines ="#a4bd29, #F86232" >
<igx-linear-graph-range
startValue =0 endValue =50
innerStartExtent =0.075 innerEndExtent =0.075
outerStartExtent =0.25 outerEndExtent =0.4 >
</igx-linear-graph-range >
<igx-linear-graph-range
startValue =50 endValue =100
innerStartExtent =0.075 innerEndExtent =0.075
outerStartExtent =0.4 outerEndExtent =0.55 >
</igx-linear-graph-range >
</igx-linear-gauge >
</div >
html コピー
目盛
目盛は、リニア ゲージを読み取りやすくするために、目盛の間隔でスケールを分割して見せる役割を果たします。
主目盛 - 主目盛は、スケールの主要な区切りとして使用されます。表示間隔、範囲、およびスタイルは、対応するプロパティを設定し制御できます。
補助目盛 - 補助目盛は主目盛を補助し、スケールの数値を読み取りやすくするために追加して使用します。主目盛と同じ方法でカスタマイズできます。
<igx-linear-gauge
height ="80px" width ="400px"
minimumValue =0 value =50
maximumValue =100
interval =10
tickBrush ="DodgerBlue"
ticksPreTerminal =0
ticksPostInitial =0
tickStrokeThickness =2
tickStartExtent =0.25
tickEndExtent =0.05
minorTickCount =4
minorTickBrush ="DarkViolet"
minorTickEndExtent =0.05
minorTickStartExtent =0.15
minorTickStrokeThickness =1 >
</igx-linear-gauge >
html
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { CommonModule } from "@angular/common" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { IgxLinearGaugeModule } from "igniteui-angular-gauges" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
],
imports : [
BrowserModule,
BrowserAnimationsModule,
CommonModule,
FormsModule,
IgxLinearGaugeModule
],
providers : [],
schemas : []
})
export class AppModule {}
ts コピー import { Component, ViewChild } from "@angular/core" ;
import { IgxLinearGaugeComponent } from "igniteui-angular-gauges" ;
@Component ({
standalone : false ,
selector : "app-root" ,
styleUrls : ["./app.component.scss" ],
templateUrl : "./app.component.html"
})
export class AppComponent {
@ViewChild ("linearGauge" , { static : true })
public linearGauge: IgxLinearGaugeComponent;
}
ts コピー <div class ="container vertical" >
<igx-linear-gauge
#linearGauge
height ="80px" width ="400px"
minimumValue =0 value =50
maximumValue =100 interval =10
tickBrush ="DodgerBlue"
ticksPreTerminal =0
ticksPostInitial =0
tickStrokeThickness =2
tickStartExtent =0.25
tickEndExtent =0.05
minorTickCount =4
minorTickBrush ="DarkViolet"
minorTickEndExtent =0.05
minorTickStartExtent =0.15
minorTickStrokeThickness =1 >
</igx-linear-gauge >
</div >
html コピー
ラベル
ラベルはスケールのメジャーを示します。
<igx-linear-gauge
height ="80px" width ="400px"
minimumValue =0 value =50
maximumValue =100 interval =10
labelInterval =10
labelExtent =0.025
labelsPreTerminal =0
labelsPostInitial =0
fontBrush ="DodgerBlue"
font ="11px Verdana" >
</igx-linear-gauge >
html
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { CommonModule } from "@angular/common" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { IgxLinearGaugeModule } from "igniteui-angular-gauges" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
],
imports : [
BrowserModule,
BrowserAnimationsModule,
CommonModule,
FormsModule,
IgxLinearGaugeModule
],
providers : [],
schemas : []
})
export class AppModule {}
ts コピー import { Component, ViewChild } from "@angular/core" ;
import { IgxLinearGaugeComponent } from "igniteui-angular-gauges" ;
@Component ({
standalone : false ,
selector : "app-root" ,
styleUrls : ["./app.component.scss" ],
templateUrl : "./app.component.html"
})
export class AppComponent {
@ViewChild ("linearGauge" , { static : true })
public linearGauge: IgxLinearGaugeComponent;
}
ts コピー <div class ="container vertical" >
<igx-linear-gauge
#linearGauge
height ="80px" width ="400px"
minimumValue =0 value =50
maximumValue =100 interval =10
labelInterval =10
labelExtent =0.025
labelsPreTerminal =0
labelsPostInitial =0
fontBrush ="DodgerBlue"
font ="11px Verdana"
>
</igx-linear-gauge >
</div >
html コピー
バッキング
バッキング要素はブレット グラフ コントロールの背景と境界線を表します。常に最初に描画される要素でラベルやメモリなどの残りの要素は互いにオーバーレイします。
<igx-linear-gauge
height ="80px" width ="400px"
minimumValue =0 value =50
maximumValue =100 interval =10
backingBrush ="#bddcfc"
backingOutline ="DodgerBlue"
backingStrokeThickness =4
backingInnerExtent =0
backingOuterExtent =1 >
</igx-linear-gauge >
html
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { CommonModule } from "@angular/common" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { IgxLinearGaugeModule } from "igniteui-angular-gauges" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
],
imports : [
BrowserModule,
BrowserAnimationsModule,
CommonModule,
FormsModule,
IgxLinearGaugeModule
],
providers : [],
schemas : []
})
export class AppModule {}
ts コピー import { Component, ViewChild } from "@angular/core" ;
import { IgxLinearGaugeComponent } from "igniteui-angular-gauges" ;
@Component ({
standalone : false ,
selector : "app-root" ,
styleUrls : ["./app.component.scss" ],
templateUrl : "./app.component.html"
})
export class AppComponent {
@ViewChild ("linearGauge" , { static : true })
public linearGauge: IgxLinearGaugeComponent;
}
ts コピー <div class ="container vertical" >
<igx-linear-gauge
#linearGauge
height ="80px" width ="400px"
minimumValue =0 value =50
maximumValue =100 interval =10
backingBrush ="#bddcfc"
backingOutline ="DodgerBlue"
backingStrokeThickness =4
backingInnerExtent =0
backingOuterExtent =1 >
</igx-linear-gauge >
</div >
html コピー
スケール
スケールはゲージで値の全範囲をハイライト表示する視覚的な要素です。外観やスケールの図形のカスタマイズ、更にスケールを反転 (isScaleInverted
プロパティを使用) させて、すべてのラベルを左から右ではなく、右から左へ描画することもできます。
<igx-linear-gauge
height ="80px" width ="400px"
minimumValue =0 value =50
maximumValue =100 interval =10
isScaleInverted =false
scaleBrush ="DodgerBlue"
scaleOutline ="DarkViolet"
scaleStrokeThickness =1
scaleInnerExtent =0.05
scaleOuterExtent =0.65
scaleStartExtent =0.05
scaleEndExtent =0.95 >
</igx-linear-gauge >
html
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { CommonModule } from "@angular/common" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { IgxLinearGaugeModule } from "igniteui-angular-gauges" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
],
imports : [
BrowserModule,
BrowserAnimationsModule,
CommonModule,
FormsModule,
IgxLinearGaugeModule
],
providers : [],
schemas : []
})
export class AppModule {}
ts コピー import { Component, ViewChild } from "@angular/core" ;
import { IgxLinearGaugeComponent } from "igniteui-angular-gauges" ;
@Component ({
standalone : false ,
selector : "app-root" ,
styleUrls : ["./app.component.scss" ],
templateUrl : "./app.component.html"
})
export class AppComponent {
@ViewChild ("linearGauge" , { static : true })
public linearGauge: IgxLinearGaugeComponent;
}
ts コピー <div class ="container vertical" >
<igx-linear-gauge
#linearGauge
height ="80px" width ="400px"
minimumValue =0 value =50
maximumValue =100 interval =10
isScaleInverted =false
scaleBrush ="DodgerBlue"
scaleOutline ="Red"
scaleStrokeThickness =2
scaleInnerExtent =0.05
scaleOuterExtent =0.65
scaleStartExtent =0.05
scaleEndExtent =0.95 >
</igx-linear-gauge >
</div >
html コピー
まとめ
上記すべてのコード スニペットを以下のコード ブロックにまとめています。プロジェクトに簡単にコピーしてブレットグラフのすべての機能を再現できます。
<igx-linear-gauge
height ="80px" width ="400px"
minimumValue =0
maximumValue =100
labelInterval =10
labelExtent =0.025
labelsPreTerminal =0
labelsPostInitial =0
fontBrush ="Black"
font ="11px Verdana"
interval =10
tickBrush ="Black"
ticksPreTerminal =0
ticksPostInitial =0
tickStrokeThickness =2
tickStartExtent =0.25
tickEndExtent =0.05
minorTickCount =4
minorTickBrush ="Black"
minorTickEndExtent =0.05
minorTickStartExtent =0.15
minorTickStrokeThickness =1
value =50
isNeedleDraggingEnabled =true
needleShape ="Custom"
needleBrush ="Black"
needleOutline ="Black"
needleStrokeThickness =1
needleBreadth =15
needleInnerExtent =0.35
needleOuterExtent =0.65
needleOuterPointExtent =0.8
needleInnerPointExtent =0.325
needleInnerPointWidth =0
needleOuterPointWidth =0.3
needleInnerBaseWidth =0
needleOuterBaseWidth =0.07
isScaleInverted =false
scaleBrush ="Gray"
scaleOutline ="Gray"
scaleStrokeThickness =1
scaleInnerExtent =0.05
scaleOuterExtent =0.65
scaleStartExtent =0.05
scaleEndExtent =0.95
backingBrush ="#cecece"
backingOutline ="#cecece"
backingStrokeThickness =4
backingInnerExtent =0
backingOuterExtent =1
rangeBrushes ="#C62828, #F96232, #FF9800"
rangeOutlines ="#C62828, #F96232, #FF9800" >
<igx-linear-graph-range
startValue =0 endValue =50
innerStartExtent =0.075 innerEndExtent =0.075
outerStartExtent =0.25 outerEndExtent =0.4 >
</igx-linear-graph-range >
<igx-linear-graph-range
startValue =50 endValue =100
innerStartExtent =0.075 innerEndExtent =0.075
outerStartExtent =0.4 outerEndExtent =0.55 >
</igx-linear-graph-range >
</igx-linear-gauge >
html
API リファレンス
以下は上記のセクションで説明した API メンバーのリストです。
その他のリソース
その他のゲージ タイプの詳細については、以下のトピックを参照してください。