React ラジアル ゲージの概要
React Radial Gauge コンポーネントは、針、目盛り、範囲、ラベルなどの視覚要素をサポートし、定義済みの図形やスケールを表示できます。IgrRadialGauge
には、アニメーション化されたトランジションのサポートも組み込まれています。アニメーションは、transitionDuration
プロパティの設定で簡単にカスタマイズできます。
React ラジアル ゲージの例
以下のサンプルは、同じ IgrRadialGauge
でいくつかのプロパティを設定して全く異なるゲージにする方法を示します。
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { SweepDirection } from "@infragistics/igniteui-react-core";
import { IgrRadialGauge } from "@infragistics/igniteui-react-gauges";
import { IgrRadialGaugeModule } from "@infragistics/igniteui-react-gauges";
import { IgrRadialGaugeRange } from "@infragistics/igniteui-react-gauges";
import { RadialGaugeBackingShape } from "@infragistics/igniteui-react-gauges";
import { RadialGaugeNeedleShape } from "@infragistics/igniteui-react-gauges";
import { RadialGaugePivotShape } from "@infragistics/igniteui-react-gauges";
import { RadialGaugeScaleOversweepShape } from "@infragistics/igniteui-react-gauges";
IgrRadialGaugeModule.register();
export default class RadialGaugeAnimation extends React.Component {
public gauge: IgrRadialGauge;
private shouldAnimate : boolean = false;
constructor(props: any) {
super(props);
this.onGaugeRef = this.onGaugeRef.bind(this);
this.onAnimateToGauge1 = this.onAnimateToGauge1.bind(this);
this.onAnimateToGauge2 = this.onAnimateToGauge2.bind(this);
this.onAnimateToGauge3 = this.onAnimateToGauge3.bind(this);
this.onAnimateToGauge4 = this.onAnimateToGauge4.bind(this);
}
public onGaugeRef(component: IgrRadialGauge) {
if (!component) { return; }
this.gauge = component;
this.onAnimateToGauge3(null);
}
public render(): JSX.Element {
return (
<div className="container sample">
<div className="options horizontal">
<button onClick={this.onAnimateToGauge1} className="options-button">Gauge Animation #1</button>
<button onClick={this.onAnimateToGauge2} className="options-button">Gauge Animation #2</button>
<button onClick={this.onAnimateToGauge3} className="options-button">Gauge Animation #3</button>
<button onClick={this.onAnimateToGauge4} className="options-button">Gauge Animation #4</button>
</div>
<IgrRadialGauge
ref={this.onGaugeRef}
height="calc(100% - 50px)"
width="100%"
value={25}
interval={5}
minimumValue={0}
maximumValue={50}
labelInterval={5}
labelExtent={0.71}
minorTickCount={4}
minorTickEndExtent={.625}
minorTickStartExtent={.6}
minorTickStrokeThickness={1}
minorTickBrush = "#79797a"
tickStartExtent={.6}
tickEndExtent={.65}
tickStrokeThickness={2}
tickBrush="#79797a"
needleShape="Triangle"
needleEndWidthRatio={0.03}
needleStartWidthRatio={0.05}
needlePivotShape="CircleOverlay"
needlePivotWidthRatio={0.15}
needleBaseFeatureWidthRatio={0.15}
needleBrush="#79797a"
needleOutline="#79797a"
needlePivotBrush="#79797a"
needlePivotOutline="#79797a"
isNeedleDraggingEnabled={true}
backingBrush="#fcfcfc"
backingOutline="#d6d6d6"
backingStrokeThickness={5}
scaleStartAngle={120}
scaleEndAngle={60}
scaleBrush="#d6d6d6"
rangeBrushes="#F86232, #DC3F76, #7446B9"
rangeOutlines="#F86232, #DC3F76, #7446B9" />
</div>
);
}
public onAnimateToGauge4 = (e: any) => {
if (!this.gauge) { return; }
if(this.shouldAnimate){
this.gauge.transitionDuration = 1000;
}
this.gauge.minimumValue = 0;
this.gauge.maximumValue = 50;
this.gauge.value = 25;
this.gauge.interval = 5;
this.gauge.labelInterval = 5;
this.gauge.labelExtent = 0.71;
this.gauge.font = "15px Verdana,Arial";
this.gauge.isNeedleDraggingEnabled = true;
this.gauge.needleEndExtent = 0.5;
this.gauge.needleShape = RadialGaugeNeedleShape.Triangle;
this.gauge.needleEndWidthRatio = 0.03;
this.gauge.needleStartWidthRatio = 0.05;
this.gauge.needlePivotShape = RadialGaugePivotShape.CircleOverlay;
this.gauge.needlePivotWidthRatio = 0.15;
this.gauge.needleBaseFeatureWidthRatio = 0.15;
this.gauge.needleBrush = "#79797a";
this.gauge.needleOutline = "#79797a";
this.gauge.needlePivotBrush = "#79797a";
this.gauge.needlePivotOutline = "#79797a";
this.gauge.minorTickCount = 4;
this.gauge.minorTickEndExtent = 0.625;
this.gauge.minorTickStartExtent = 0.6;
this.gauge.minorTickStrokeThickness = 1;
this.gauge.minorTickBrush = "#79797a";
this.gauge.tickStartExtent = 0.6;
this.gauge.tickEndExtent = 0.65;
this.gauge.tickStrokeThickness = 2;
this.gauge.tickBrush = "#79797a";
this.gauge.scaleStartAngle = 120;
this.gauge.scaleEndAngle = 60;
this.gauge.scaleBrush = "#d6d6d6";
this.gauge.scaleOversweepShape = RadialGaugeScaleOversweepShape.Fitted;
this.gauge.scaleSweepDirection = SweepDirection.Clockwise;
this.gauge.scaleEndExtent = 0.57;
this.gauge.scaleStartExtent = 0.5;
this.gauge.backingBrush = "#fcfcfc";
this.gauge.backingOutline = "#d6d6d6";
this.gauge.backingStrokeThickness = 5;
this.gauge.backingShape = RadialGaugeBackingShape.Circular;
const range1 = new IgrRadialGaugeRange({});
range1.startValue = 5;
range1.endValue = 15;
const range2 = new IgrRadialGaugeRange({});
range2.startValue = 15;
range2.endValue = 35;
const range3 = new IgrRadialGaugeRange({});
range3.startValue = 35;
range3.endValue = 45;
this.gauge.rangeBrushes = [ "#F86232", "#DC3F76", "#7446B9"];
this.gauge.rangeOutlines = [ "#F86232", "#DC3F76", "#7446B9"];
this.gauge.ranges.clear();
this.gauge.ranges.add(range1);
this.gauge.ranges.add(range2);
this.gauge.ranges.add(range3);
for (let i = 0; i < this.gauge.ranges.count; i++) {
const range = this.gauge.ranges.item(i);
range.innerStartExtent = 0.5;
range.innerEndExtent = 0.5;
range.outerStartExtent = 0.57;
range.outerEndExtent = 0.57;
}
this.shouldAnimate = true;
}
// semi radial gauge
public onAnimateToGauge3 = (e: any) => {
if (!this.gauge) { return; }
if(this.shouldAnimate){
this.gauge.transitionDuration = 1000;
}
this.gauge.minimumValue = 0;
this.gauge.maximumValue = 80;
this.gauge.value = 10;
this.gauge.interval = 10;
this.gauge.labelExtent = 0.6;
this.gauge.labelInterval = 10;
this.gauge.font = "15px Verdana,Arial";
this.gauge.scaleStartAngle = 135;
this.gauge.scaleEndAngle = 45;
this.gauge.scaleBrush = "#0b8fed";
this.gauge.scaleOversweepShape = RadialGaugeScaleOversweepShape.Auto;
this.gauge.scaleSweepDirection = SweepDirection.Clockwise;
this.gauge.scaleEndExtent = 0.825;
this.gauge.scaleStartExtent = 0.775;
this.gauge.minorTickStartExtent = 0.7;
this.gauge.minorTickEndExtent = 0.75;
this.gauge.tickStartExtent = 0.675;
this.gauge.tickEndExtent = 0.75;
this.gauge.backingShape = RadialGaugeBackingShape.Fitted;
this.gauge.backingBrush = "#fcfcfc";
this.gauge.backingOutline = "#d6d6d6";
this.gauge.backingOversweep = 5;
this.gauge.backingCornerRadius = 10;
this.gauge.backingOuterExtent = 0.9;
this.gauge.needleShape = RadialGaugeNeedleShape.NeedleWithBulb;
this.gauge.needlePivotShape = RadialGaugePivotShape.CircleOverlay;
this.gauge.needleEndExtent = 0.5;
this.gauge.needlePointFeatureExtent = 0.3;
this.gauge.needlePivotWidthRatio = 0.2;
this.gauge.needleBrush = "#9f9fa0";
this.gauge.needleOutline = "#9f9fa0";
this.gauge.needlePivotBrush = "#9f9fa0";
this.gauge.needlePivotOutline = "#9f9fa0";
this.gauge.tickBrush = "rgba(51, 51, 51, 1)";
this.gauge.minorTickBrush = "rgba(73, 73, 73, 1)";
this.gauge.minorTickCount = 6;
this.gauge.ranges.clear();
this.shouldAnimate = true;
}
public onAnimateToGauge2 = (e: any) => {
if (!this.gauge) { return; }
if(this.shouldAnimate){
this.gauge.transitionDuration = 1000;
}
this.gauge.minimumValue = 100;
this.gauge.maximumValue = 200;
this.gauge.value = 125;
this.gauge.scaleStartAngle = 180;
this.gauge.scaleEndAngle = 0;
this.gauge.scaleBrush = "transparent";
this.gauge.scaleSweepDirection = SweepDirection.Clockwise;
this.gauge.backingOutline = "white";
this.gauge.backingBrush = "white";
this.gauge.backingShape = RadialGaugeBackingShape.Fitted;
this.gauge.needleEndExtent = 0.8;
this.gauge.needleShape = RadialGaugeNeedleShape.Triangle;
this.gauge.needlePivotShape = RadialGaugePivotShape.Circle;
this.gauge.needlePivotWidthRatio = 0.1;
this.gauge.needleBrush = "#79797a";
this.gauge.needleOutline = "#79797a";
this.gauge.tickBrush = "transparent";
this.gauge.minorTickBrush = "transparent";
this.gauge.labelInterval = 50;
this.gauge.labelExtent = 0.935;
this.gauge.font = "13px Verdana,Arial";
const range1 = new IgrRadialGaugeRange({});
range1.startValue = 100;
range1.endValue = 150;
const range2 = new IgrRadialGaugeRange({});
range2.startValue = 150;
range2.endValue = 200;
this.gauge.rangeBrushes = [ "#32f845", "#bf32f8" ];
this.gauge.rangeOutlines = [ "#32f845", "#bf32f8" ];
this.gauge.ranges.clear();
this.gauge.ranges.add(range1);
this.gauge.ranges.add(range2);
for (let i = 0; i < this.gauge.ranges.count; i++) {
const range = this.gauge.ranges.item(i);
range.innerStartExtent = 0.3;
range.innerEndExtent = 0.3;
range.outerStartExtent = 0.9;
range.outerEndExtent = 0.9;
}
this.shouldAnimate = true;
}
// quatre radial gauge
public onAnimateToGauge1 = (e: any) => {
if (!this.gauge) { return; }
if(this.shouldAnimate){
this.gauge.transitionDuration = 1000;
}
this.gauge.minimumValue = 0;
this.gauge.maximumValue = 10;
this.gauge.value = 7.5;
this.gauge.scaleStartAngle = 180;
this.gauge.scaleEndAngle = 270;
this.gauge.scaleBrush = "transparent";
this.gauge.scaleSweepDirection = SweepDirection.Clockwise;
this.gauge.backingOutline = "white";
this.gauge.backingBrush = "white";
this.gauge.backingShape = RadialGaugeBackingShape.Fitted;
this.gauge.needleEndExtent = 0.8;
this.gauge.needleShape = RadialGaugeNeedleShape.Triangle;
this.gauge.needlePivotShape = RadialGaugePivotShape.Circle;
this.gauge.needlePivotWidthRatio = 0.1;
this.gauge.needleBrush = "#79797a";
this.gauge.needleOutline = "#79797a";
this.gauge.tickBrush = "transparent";
this.gauge.minorTickBrush = "transparent";
this.gauge.labelInterval = 5;
this.gauge.labelExtent = 0.915;
this.gauge.font = "15px Verdana,Arial";
const range1 = new IgrRadialGaugeRange({});
range1.startValue = 0;
range1.endValue = 5;
const range2 = new IgrRadialGaugeRange({});
range2.startValue = 5;
range2.endValue = 10;
this.gauge.rangeBrushes = [ "#a4bd29", "#F86232" ];
this.gauge.rangeOutlines = [ "#a4bd29", "#F86232" ];
this.gauge.ranges.clear();
this.gauge.ranges.add(range1);
this.gauge.ranges.add(range2);
for (let i = 0; i < this.gauge.ranges.count; i++) {
const range = this.gauge.ranges.item(i);
range.innerStartExtent = 0.3;
range.innerEndExtent = 0.3;
range.outerStartExtent = 0.9;
range.outerEndExtent = 0.9;
}
this.shouldAnimate = true;
}
}
// rendering above class to the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<RadialGaugeAnimation/>);
tsx
このサンプルが気に入りましたか? 完全な Ignite UI for Reactツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
依存関係
gauge コンポーネントをインストールするときに core パッケージもインストールする必要があります。
npm install --save igniteui-react-core
npm install --save igniteui-react-gauges
cmd
モジュールの要件
IgrRadialGauge
を作成するには、以下のモジュールが必要です。
import { IgrRadialGaugeModule } from 'igniteui-react-gauges';
IgrRadialGaugeModule.register();
ts
使用方法
以下のコードは針およびスケールで 3 つの比較範囲を含むラジアル ゲージを作成する方法を紹介します。
<IgrRadialGauge height="400px" width="400px"
value={25}
interval={5}
minimumValue={0}
maximumValue={100}>
<IgrRadialGaugeRange startValue={0}
endValue={30}
brush="red"/>
<IgrRadialGaugeRange startValue={30}
endValue={60}
brush="yellow"/>
<IgrRadialGaugeRange startValue={60}
endValue={100}
brush="green"/>
</IgrRadialGauge>
tsx
バッキング
ゲージには、スケールの後ろ側に描かれた背景図形があり、図形はゲージの背景として動作します。
バッキング要素はラジアル ゲージ コントロールの背景と境界線を表します。常に最初に描画される要素で針、ラベルやメモリなどの残りの要素はその上のオーバーレイです。
バッキングは、円形またはフィットにできます。円形の場合は 360 度の円形のゲージが作成されますが、一方フィット図形の場合は scaleStartAngle
および scaleEndAngle
プロパティで円弧部分が塗りつぶされます。これには、backingShape
プロパティを設定します。
<IgrRadialGauge
backingShape="Fitted"
backingBrush="#fcfcfc"
backingOutline="DodgerBlue"
backingOversweep={5}
backingCornerRadius={10}
backingStrokeThickness={5}
backingOuterExtent={0.8}
backingInnerExtent={0.15}
scaleStartAngle={135} scaleEndAngle={45}
height="300px" width="300px"
minimumValue={0} value={50}
maximumValue={80} interval={10} />
tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrRadialGauge } from "@infragistics/igniteui-react-gauges";
import { IgrRadialGaugeModule } from "@infragistics/igniteui-react-gauges";
IgrRadialGaugeModule.register();
export default class RadialGaugeBacking extends React.Component<any, any> {
constructor(props: any) {
super(props);
this.state = { componentVisible: true }
}
public render(): JSX.Element {
return (
<div className="container sample">
<IgrRadialGauge
backingShape="Fitted"
backingBrush="#fcfcfc"
backingOutline="DodgerBlue"
backingOversweep={5}
backingCornerRadius={10}
backingStrokeThickness={5}
backingOuterExtent={0.8}
backingInnerExtent={0.15}
scaleStartAngle={135}
scaleEndAngle={45}
scaleBrush="#dddddd"
height="100%"
width="100%"
minimumValue={0} value={50}
maximumValue={80} interval={10} />
</div>
);
}
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<RadialGaugeBacking/>);
tsx
スケール
スケールは視覚要素で、minimumValue
と maximumValue
値を設定してゲージの値範囲全体をハイライト表示できます。バッキングとともにゲージの全体的な図形を定義します。scaleStartAngle
と scaleEndAngle
プロパティは、スケールの円弧の境界線を定義します。scaleSweepDirection
プロパティが、スケールが時計回りまたは反時計回りのどちらの方向に動くかを指定します。scaleBrush
、scaleStartExtent
、scaleEndExtent
プロパティを設定してスケールの外観をカスタマイズできます。
<IgrRadialGauge
scaleStartAngle={135}
scaleEndAngle={45}
scaleBrush="DodgerBlue"
scaleSweepDirection="Clockwise"
scaleOversweep={1}
scaleOversweepShape="Fitted"
scaleStartExtent={0.45}
scaleEndExtent={0.575}
height="300px" width="300px"
minimumValue={0} value={50}
maximumValue={80} interval={10} />
tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrRadialGauge } from "@infragistics/igniteui-react-gauges";
import { IgrRadialGaugeModule } from "@infragistics/igniteui-react-gauges";
IgrRadialGaugeModule.register();
export default class RadialGaugeScale extends React.Component<any, any> {
constructor(props: any) {
super(props);
this.state = { componentVisible: true }
}
public render(): JSX.Element {
return (
<div className="container sample">
<IgrRadialGauge
scaleStartAngle={135}
scaleEndAngle={45}
scaleBrush="DodgerBlue"
scaleSweepDirection="Clockwise"
scaleOversweep={1}
scaleOversweepShape="Fitted"
scaleStartExtent={0.45}
scaleEndExtent={0.575}
height="100%"
width="100%"
minimumValue={0} value={50}
maximumValue={80} interval={10} />
</div>
);
}
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<RadialGaugeScale/>);
tsx
ラベルとタイトル
ゲージ ラベルは minimumValue
と maximumValue
の値の間で指定された間隔で数値を表示する視覚要素です。0 はゲージ中央、1 はゲージ バッキングの外側範囲を表す labelExtent
プロパティで小数を使用してラベルの配置を設定できます。fontBrush
や font
など、さまざまなスタイル プロパティを設定してラベルをカスタマイズできます。
これらの針のラベルにはそれぞれ、titleExtent
、titleAngle
、SubtitleFontSize
、highlightLabelBrush
など、フォント、角度、ブラシ、ゲージの中心からの距離を変更するために適用できるさまざまなスタイル属性があります。
<IgrRadialGauge
labelExtent={0.65}
labelInterval={10}
font="11px Verdana"
fontBrush="DodgerBlue"
height="300px" width="300px"
minimumValue={0} value={50}
maximumValue={80} interval={10} />
tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrRadialGauge } from "@infragistics/igniteui-react-gauges";
import { IgrRadialGaugeModule } from "@infragistics/igniteui-react-gauges";
IgrRadialGaugeModule.register();
export default class RadialGaugeLabels extends React.Component<any, any> {
constructor(props: any) {
super(props);
this.state = { componentVisible: true }
}
public render(): JSX.Element {
return (
<div className="container sample">
<IgrRadialGauge
titleDisplaysValue="true"
subtitleText="MPH"
scaleStartAngle={135}
scaleEndAngle={45}
scaleBrush="#dddddd"
height="100%"
width="100%"
minimumValue={0} value={50}
maximumValue={80} interval={10} />
</div>
);
}
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<RadialGaugeLabels/>);
tsx
タイトルとサブタイトル
titleText
プロパティと subtitleText
プロパティが使用可能であり、どちらも針のカスタム テキストを表示するために使用できます。あるいは、titleDisplaysValue
と subtitleDisplaysValue
を true に設定すると、針の値が表示され、titleText
と subtitleText
がオーバーライドされます。したがって、タイトルにカスタム テキストを使用しながらサブタイトルで値を表示したり、その逆を行ったりすることができます。
以下に説明するように針のハイライトが表示されている場合は、highlightLabelText
を介してカスタム テキストを表示できます。それ以外の場合は、highlightLabelDisplaysValue
を有効にしてその値を表示できます。
<IgrRadialGauge
titleText="Global Sales"
subtitleText="2024"
/>
tsx
オプティカル スケーリング
ラジアル ゲージのラベルとタイトルにより、スケーリングを変更できます。これを有効にするには、まず opticalScalingEnabled
を true に設定します。次に、ラベルが 100% のオプティカル スケーリングを持つサイズを管理する opticalScalingSize
を設定できます。ゲージのサイズが大きくなると、ラベルのフォントも大きくなります。たとえば、このプロパティが 500 に設定され、ゲージのピクセル単位のサイズが 2 倍の 1000 になると、ラベルのフォント サイズは 200% 大きくなります。
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrRadialGauge } from "@infragistics/igniteui-react-gauges";
import { IgrRadialGaugeModule } from "@infragistics/igniteui-react-gauges";
IgrRadialGaugeModule.register();
export default class RadialGaugeOpticalScaling extends React.Component<any, any> {
public gauge: IgrRadialGauge;
constructor(props: any) {
super(props);
this.onGaugeRef = this.onGaugeRef.bind(this);
this.state = { componentVisible: true,
toggleOpticalScaling: true,
gaugeSize: "100%",
sliderVal: "100"}
}
public onGaugeRef(component: IgrRadialGauge) {
if (!component) { return; }
this.gauge = component;
}
public render(): JSX.Element {
return (
<div className="container sample center">
<div className="options horizontal">
<label className="options-label">Optical Scaling: </label>
<label className="options-label"><input type="checkbox"
checked={this.state.toggleOpticalScaling}
onChange={this.onOpticalScalingChanged}/> Resize Gauge: </label>
<input className="options-slider" type="range" min={25} max={100} step={5} value={this.state.sliderVal}
onChange={this.onGaugeSizeChanged} />
</div>
<IgrRadialGauge
ref={this.onGaugeRef}
height={this.state.gaugeSize}
width={this.state.gaugeSize}
titleDisplaysValue="true"
subtitleText="MPG"
minimumValue="0" value="50"
maximumValue="80" interval="10"
titleExtent={0.5}
subtitleExtent={0.65}
opticalScalingEnabled={this.state.toggleOpticalScaling}
opticalScalingSize="500" />
</div>
);
}
public onOpticalScalingChanged = (e: any) => {
const isEnabled = e.target.checked;
this.setState( {crosshairsVisible: isEnabled} );
if (isEnabled) {
this.setState({toggleOpticalScaling: true})
}
else {
this.setState({toggleOpticalScaling: false})
}
}
public onGaugeSizeChanged = (e: any) => {
let num: number = parseInt(e.target.value);
this.setState({sliderVal: num.toString(), gaugeSize: num.toString() + "%"});
}
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<RadialGaugeOpticalScaling/>);
tsx
目盛
目盛は、ラジアル ゲージの中央から放射状に表示される細い線です。目盛には、主目盛および副目盛の 2 種類があり、主目盛りは minimumValue
と maximumValue
の間の interval
に表示されます。また minorTickCount
プロパティは、隣接する 2 つの主目盛間の副目盛の数を指定します。目盛りの長さは、tickStartExtent
、tickEndExtent
、minorTickStartExtent
、minorTickEndExtent
に少数値 (0 から 1 の間) を設定して制御できます。
<IgrRadialGauge
tickStartExtent={0.45}
tickEndExtent={0.575}
tickStrokeThickness={2}
tickBrush="DodgerBlue"
minorTickCount={4}
minorTickEndExtent={0.5}
minorTickStartExtent={0.575}
minorTickStrokeThickness={1}
minorTickBrush="DarkViolet"
height="300px" width="300px"
minimumValue={0} value={50}
maximumValue={80} interval={10}/>
tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrRadialGauge } from "@infragistics/igniteui-react-gauges";
import { IgrRadialGaugeModule } from "@infragistics/igniteui-react-gauges";
IgrRadialGaugeModule.register();
export default class RadialGaugeTickmarks extends React.Component<any, any> {
constructor(props: any) {
super(props);
this.state = { componentVisible: true }
}
public render(): JSX.Element {
return (
<div className="container sample">
<IgrRadialGauge
tickStartExtent={0.5}
tickEndExtent={0.57}
tickStrokeThickness={2}
tickBrush="DodgerBlue"
minorTickCount={4}
minorTickEndExtent={0.520}
minorTickStartExtent={0.57}
minorTickStrokeThickness={1}
minorTickBrush="DarkViolet"
height="100%"
width="100%"
minimumValue={0} value={50}
maximumValue={80} interval={10} />
</div>
);
}
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<RadialGaugeTickmarks/>);
tsx
範囲
範囲に minimumValue
や maximumValue
プロパティで指定した連続値の境界をハイライト表示します。開始値と終了値を指定してゲージに複数の範囲を追加でき、各範囲には、brush
や outline
などのカスタマイズ プロパティがあります。または、rangeBrushes
や rangeOutlines
プロパティを範囲の色リストに設定することもできます。
<IgrRadialGauge
height="300px" width="300px"
minimumValue={0} value={50}
maximumValue={80} interval={10}
rangeBrushes ="red, yellow, green"
rangeOutlines="red, yellow, green">
<IgrRadialGaugeRange
startValue={1} endValue={10} brush="yellow" />
<IgrRadialGaugeRange
startValue={10} endValue={25} brush="green" />
<IgrRadialGaugeRange
startValue={25} endValue={40} brush="red" />
<IgrRadialGaugeRange
startValue={40} endValue={80} brush="yellow" />
</IgrRadialGauge>
tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrRadialGauge } from "@infragistics/igniteui-react-gauges";
import { IgrRadialGaugeRange } from "@infragistics/igniteui-react-gauges";
import { IgrRadialGaugeModule } from "@infragistics/igniteui-react-gauges";
IgrRadialGaugeModule.register();
export default class RadialGaugeRanges extends React.Component<any, any> {
constructor(props: any) {
super(props);
this.state = { componentVisible: true }
}
public render(): JSX.Element {
return (
<div className="container sample">
<IgrRadialGauge
height="100%"
width="100%"
minimumValue={0} value={50}
maximumValue={80} interval={10}
rangeBrushes ="#a4bd29, #F86232"
rangeOutlines="#a4bd29, #F86232" >
<IgrRadialGaugeRange name="range1"
startValue={10} endValue={25}
innerStartExtent={0.50} innerEndExtent={0.50}
outerStartExtent={0.57} outerEndExtent={0.57} />
<IgrRadialGaugeRange name="range2"
startValue={25} endValue={40}
innerStartExtent={0.50} innerEndExtent={0.50}
outerStartExtent={0.57} outerEndExtent={0.57} />
</IgrRadialGauge>
</div>
);
}
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<RadialGaugeRanges/>);
tsx
針
ゲージ針は、ゲージの設定値を示す視覚要素です。針は、あらかじめ定義されたいくつかの図形の中から選択でき、ピボット図形をゲージの中心に配置できます。またピボット図形は、事前に定義された図形の 1 つを使用します。オーバーレイとアンダーレイを含むピボット図形には、図形に適用する別のピボット ブラシがあります。
サポートされている針の形とキャップは、needleShape
と needlePivotShape
プロパティで設定します。
ゲージのインタラクティブ モードを有効 (isNeedleDraggingEnabled
プロパティを使用) にするとユーザーは minimumValue
と maximumValue
の値間で針をドラッグして値を変更できるようになります。
<IgrRadialGauge
value={50}
isNeedleDraggingEnabled={true}
isNeedleDraggingConstrained={true}
needleShape="NeedleWithBulb"
needleBrush="DodgerBlue"
needleOutline="DodgerBlue"
needleEndExtent={0.475}
needleStrokeThickness={1}
needlePivotShape="CircleOverlay"
needlePivotBrush="#9f9fa0"
needlePivotOutline="#9f9fa0"
needlePivotWidthRatio={0.2}
needlePivotStrokeThickness={1}
height="300px" width="300px"
minimumValue={0}
maximumValue={80} interval={10} />
tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrRadialGauge } from "@infragistics/igniteui-react-gauges";
import { IgrRadialGaugeModule } from "@infragistics/igniteui-react-gauges";
IgrRadialGaugeModule.register();
export default class RadialGaugeNeedle extends React.Component<any, any> {
constructor(props: any) {
super(props);
this.state = { componentVisible: true }
}
public render(): JSX.Element {
return (
<div className="container sample">
<IgrRadialGauge
height="100%"
width="100%"
isNeedleDraggingEnabled={true}
isNeedleDraggingConstrained={true}
needleShape="NeedleWithBulb"
needleBrush="DodgerBlue"
needleOutline="DodgerBlue"
needleEndExtent={0.475}
needleStrokeThickness={1}
needlePivotShape="CircleOverlay"
needlePivotBrush="#9f9fa0"
needlePivotOutline="#9f9fa0"
needlePivotWidthRatio={0.2}
needlePivotStrokeThickness={1}
value={50}
minimumValue={0}
maximumValue={80}
interval={10} />
</div>
);
}
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<RadialGaugeNeedle/>);
tsx
針のハイライト
ラジアル ゲージを変更して、2 番目の針を表示できます。これにより、メイン針の value
の不透明度が低く表示されます。これを有効にするには、まず highlightValueDisplayMode
を Overlay に設定し、次に highlightValue
を適用します。
<IgrRadialGauge
highlightValueDisplayMode="Overlay"
highlightValue="25"
isHighlightNeedleDraggingEnabled="true"
isNeedleDraggingEnabled="true"
titleDisplaysValue="true"
label-interval="10"
label-extent="0.65"
height="100%"
width="100%"
minimumValue={0} value={75}
maximumValue={80} interval={10} />
tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrRadialGauge } from "@infragistics/igniteui-react-gauges";
import { IgrRadialGaugeModule } from "@infragistics/igniteui-react-gauges";
IgrRadialGaugeModule.register();
export default class RadialGaugeHighlightNeedle extends React.Component<any, any> {
constructor(props: any) {
super(props);
this.state = { componentVisible: true }
}
public render(): JSX.Element {
return (
<div className="container sample">
<IgrRadialGauge
highlightValue="50"
highlightValueDisplayMode="Overlay"
highlightLabelDisplaysValue="true"
highlightLabelSnapsToNeedlePivot="true"
isHighlightNeedleDraggingEnabled="true"
label-interval="10"
label-extent="0.65"
height="100%"
width="100%"
minimumValue={0} value={30}
maximumValue={100} interval={10} />
</div>
);
}
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<RadialGaugeHighlightNeedle/>);
tsx
まとめ
上記すべてのコード スニペットを以下のコード ブロックにまとめています。プロジェクトに簡単にコピーしてブレットグラフのすべての機能を再現できます。
<IgrRadialGauge
height="300px" width="300px"
minimumValue={0}
maximumValue={80}
scaleStartAngle={135}
scaleEndAngle={45}
scaleBrush="#c6c6c6"
scaleSweepDirection="Clockwise"
scaleOversweep={1}
scaleOversweepShape="Fitted"
scaleStartExtent={0.45}
scaleEndExtent={0.575}
value={70}
isNeedleDraggingEnabled={true}
isNeedleDraggingConstrained={true}
needleShape="NeedleWithBulb"
needleBrush="DodgerBlue"
needleOutline="DodgerBlue"
needleEndExtent={0.475}
needleStrokeThickness={1}
needlePivotShape="CircleOverlay"
needlePivotBrush="#9f9fa0"
needlePivotOutline="#9f9fa0"
needlePivotWidthRatio={0.2}
needlePivotStrokeThickness={1}
interval={10}
tickStartExtent={0.45}
tickEndExtent={0.575}
tickStrokeThickness={2}
tickBrush="Black"
minorTickCount={4}
minorTickEndExtent={0.5}
minorTickStartExtent={0.575}
minorTickStrokeThickness={1}
minorTickBrush="Black"
labelExtent={0.65}
labelInterval={10}
font="11px Verdana"
fontBrush="Black"
backingShape="Fitted"
backingBrush="#ededed"
backingOutline="Gray"
backingOversweep={5}
backingCornerRadius={10}
backingStrokeThickness={5}
backingOuterExtent={0.8}
backingInnerExtent={0.15}
rangeBrushes ="#a4bd29, #F86232"
rangeOutlines="#a4bd29, #F86232">
<IgrRadialGaugeRange
startValue={20} endValue={40}
innerStartExtent={0.45} innerEndExtent={0.45}
outerStartExtent={0.57} outerEndExtent={0.57} />
<IgrRadialGaugeRange
startValue={40} endValue={60}
innerStartExtent={0.45} innerEndExtent={0.45}
outerStartExtent={0.57} outerEndExtent={0.57} />
</IgrRadialGauge>
tsx
API リファレンス
以下は上記のセクションで説明した API メンバーのリストです。
その他のリソース
その他のゲージ タイプの詳細については、以下のトピックを参照してください。