Resumen de React Medidor radial
El componente de calibre radial React proporciona una serie de elementos visuales, como una aguja, marcas de graduación, rangos y etiquetas, para crear una forma y una escala predefinidas. También IgrRadialGauge
tiene soporte incorporado para transiciones animadas. Esta animación es fácilmente personalizable configurando la transitionDuration
propiedad.
React Medidor radial Ejemplo
El siguiente ejemplo demuestra cómo configurar varias propiedades en el mismo IgrRadialGauge
puede transformarlo en un calibre radial completamente diferente.
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 コピー
¿Te gusta este ejemplo? Obtén acceso a nuestro kit de herramientas completo Ignite UI for React y comienza a crear tus propias aplicaciones en minutos. Descárgalo gratis.
dependencias
Al instalar el componente medidor, también se debe instalar el paquete central.
npm install --save igniteui-react-core
npm install --save igniteui-react-gauges
cmd
Módulos de componentes
El IgrRadialGauge
requiere los siguientes módulos:
import { IgrRadialGaugeModule } from 'igniteui-react-gauges' ;
IgrRadialGaugeModule.register();
ts
Uso
El siguiente código demuestra cómo crear un medidor radial que contiene una aguja y tres rangos comparativos en la escala.
<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
Apoyo
El componente de calibre radial viene con una forma de respaldo dibujada detrás de la escala que actúa como fondo para el calibre radial.
El elemento de respaldo representa el fondo y el borde del componente de calibre radial. Siempre es el primer elemento renderizado y el resto de elementos, como la aguja, las etiquetas y las marcas, se superponen encima.
El respaldo puede ser circular o empotrado. Una forma circular crea un indicador circular de 360 grados, mientras que una forma ajustada crea un segmento de arco relleno que abarca las propiedades scaleStartAngle
y scaleEndAngle
. Esto se puede configurar configurando la propiedad 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 コピー
Escala
La escala es un elemento visual que resalta la gama completa de valores en el indicador que se pueden crear proporcionando valores minimumValue
y maximumValue
. Junto con el respaldo, define la forma general del calibre. Las propiedades scaleStartAngle
y scaleEndAngle
definen los límites del arco de la escala. Mientras que la propiedad scaleSweepDirection
especifica si la escala barre en el sentido de las agujas del reloj o en el sentido contrario a las agujas del reloj. Puede personalizar la apariencia de la escala configurando las propiedades scaleBrush
, scaleStartExtent
y 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 コピー
Etiquetas y títulos
Las etiquetas de calibre radial son elementos visuales que muestran valores numéricos en un intervalo específico entre los valores de las propiedades minimumValue
y maximumValue
. Puede colocar etiquetas estableciendo la propiedad labelExtent
en una fracción, donde 0 representa el centro del calibre y 1 representa la extensión exterior del respaldo del calibre. Además, puede personalizar las etiquetas configurando varias propiedades de estilo, como fontBrush
y font
.
Cada una de estas etiquetas para la aguja tiene varios atributos de estilo que puede aplicar para cambiar la fuente, el ángulo, el pincel y la distancia desde el centro del medidor, como , 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 コピー
Título y subtítulo
titleText
y subtitleText
las propiedades están disponibles y se pueden usar para mostrar texto personalizado para la aguja. Alternativamente, y subtitleDisplaysValue
, titleDisplaysValue
cuando se establece en true, permitirá mostrar el valor de la aguja y anular titleText
y subtitleText
. Por lo tanto, puede ocupar texto personalizado para el título pero mostrar el valor a través del subtítulo y viceversa.
Si se muestra la aguja de resaltado, como se explica a continuación, el texto personalizado se puede mostrar a través highlightLabelText
de, de lo contrario highlightLabelDisplaysValue
, se puede habilitar y mostrar su valor.
<IgrRadialGauge
titleText ="Global Sales"
subtitleText ="2024"
/>
tsx
Escalado óptico
Las etiquetas y los títulos del medidor radial pueden cambiar su escala. Para habilitar esto, primero establézcalo opticalScalingEnabled
en true. A continuación, puede establecer opticalScalingSize
cuál administra el tamaño en el que las etiquetas tienen un escalado óptico del 100%. Las etiquetas tendrán fuentes más grandes cuando el tamaño del medidor sea mayor. Por ejemplo, las etiquetas tendrán un tamaño de fuente un 200% más grande cuando esta propiedad se establece en 500 y el tamaño del px del medidor se duplica a, por ejemplo. 1000.
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 コピー
Marcas de verificación
Las marcas de graduación son líneas finas que irradian desde el centro del calibre radial. Hay dos tipos de marcas: mayores y menores. Las marcas principales se muestran en el interval
entre las propiedades minimumValue
y maximumValue
. Utilice la propiedad minorTickCount
para especificar el número de marcas menores que se muestran entre cada marca mayor. Puede controlar la longitud de las marcas estableciendo una fracción (entre 0 y 1) en las propiedades tickStartExtent
, tickEndExtent
, minorTickStartExtent
y minorTickEndExtent
.
<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 コピー
Rangos
Un rango resalta un conjunto de valores continuos vinculados por propiedades minimumValue
y maximumValue
especificadas. Puede agregar varios rangos al calibre radial especificando sus valores inicial y final. Cada rango tiene algunas propiedades de personalización, como brush
y outline
. Alternativamente, puede configurar las propiedades rangeBrushes
y rangeOutlines
en una lista de colores para los rangos.
<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 コピー
Aguja
Las agujas de calibre radial son elementos visuales que se utilizan para indicar un valor establecido de calibre. Las agujas están disponibles en una de las varias formas predefinidas. La aguja puede tener forma de pivote, que se coloca en el centro del calibre. La forma de pivote también adopta una de las formas predefinidas. Las formas de pivote que incluyen una superposición o una base pueden tener un pincel de pivote independiente aplicado a la forma.
Las formas y tapas de agujas admitidas se configuran mediante las propiedades needleShape
y needlePivotShape
.
Puede habilitar un modo interactivo del medidor (usando la propiedad isNeedleDraggingEnabled
) y el usuario final podrá cambiar el valor arrastrando la aguja entre los valores de las propiedades de minimumValue
y 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 コピー
Aguja de resaltado
El calibre radial se puede modificar para mostrar una segunda aguja. Esto hará que la aguja value
principal aparezca con una opacidad más baja. Para habilitar esto, primero establezca highlightValueDisplayMode
en Superposición y, a continuación, aplique a 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 コピー
Resumen
Para su comodidad, todos los fragmentos de código anteriores se combinan en un bloque de código a continuación que puede copiar fácilmente a su proyecto y ver el medidor radial con todas las funciones y elementos visuales habilitados.
<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
Referencias de API
La siguiente es una lista de miembros de API mencionados en las secciones anteriores:
Recursos adicionales
Puede encontrar más información sobre otros tipos de medidores en estos temas: