Contents
- setPointerValue
- setAnnotationValue
- refresh
Having trouble getting help?
Contact Support
Contact Support
Methods in React Linear gauge component
29 Aug 202313 minutes to read
The following methods are available in the Linear Gauge component.
setPointerValue
To change the pointer value dynamically, use the setPointerValue
method in the Linear Gauge component. The following are the arguments for this method.
Argument name | Description |
---|---|
axisIndex | Specifies the index of the axis in which the pointer value is to be updated. |
pointerIndex | Specifies the index of the pointer to be updated. |
pointerValue | Specifies the value of the pointer to be updated. |
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import { LinearGaugeComponent, AxesDirective, AxisDirective, PointersDirective, PointerDirective } from '@syncfusion/ej2-react-lineargauge';
export function App() {
function clickHandler(){
gaugeInstance.setPointerValue(0, 0, 30);
}
var gaugeInstance;
return (<div>
<ButtonComponent onClick= { clickHandler }>Click</ButtonComponent>
<LinearGaugeComponent ref={g => gaugeInstance = g}>
<AxesDirective>
<AxisDirective>
<PointersDirective>
<PointerDirective value={80}>
</PointerDirective>
</PointersDirective>
</AxisDirective>
</AxesDirective>
</LinearGaugeComponent></div>);
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import { LinearGaugeComponent, AxesDirective, AxisDirective, PointersDirective, PointerDirective } from '@syncfusion/ej2-react-lineargauge';
export function App() {
function clickHandler(){
gaugeInstance.setPointerValue(0, 0, 30);
}
let gaugeInstance : LinearGaugeComponent;
return (<div>
<ButtonComponent onClick= { clickHandler }>Click</ButtonComponent>
<LinearGaugeComponent ref={g => gaugeInstance = g}>
<AxesDirective>
<AxisDirective>
<PointersDirective>
<PointerDirective value={80}>
</PointerDirective>
</PointersDirective>
</AxisDirective>
</AxesDirective>
</LinearGaugeComponent></div>);
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);
setAnnotationValue
To change the annotation content dynamically, use the setAnnotationValue
method in the Linear Gauge component. The following are the arguments for this method.
Argument name | Description |
---|---|
annotationIndex | Specifies the index number of the annotation to be updated. |
content | Specifies the text for the annotation to be updated. |
axisValue | Specifies the value of the axis where the annotation is to be placed. |
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import { Annotations, AnnotationsDirective, AnnotationDirective, LinearGaugeComponent, AxesDirective, AxisDirective, PointersDirective, Inject, PointerDirective } from '@syncfusion/ej2-react-lineargauge';
export function App(){
function clickHandler(){
gaugeInstance.setAnnotationValue(0, '50', 50);
}
var gaugeInstance;
return (<div>
<ButtonComponent onClick= { clickHandler }>Click</ButtonComponent>
<LinearGaugeComponent ref={g => gaugeInstance = g}>
<Inject services={[Annotations]}/>
<AnnotationsDirective>
<AnnotationDirective content='10' axisValue={0} zIndex='1'>
</AnnotationDirective>
</AnnotationsDirective>
<AxesDirective>
<AxisDirective>
<PointersDirective>
<PointerDirective value={10}>
</PointerDirective>
</PointersDirective>
</AxisDirective>
</AxesDirective>
</LinearGaugeComponent></div>);
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import { Annotations, AnnotationsDirective, AnnotationDirective, LinearGaugeComponent, AxesDirective, AxisDirective, PointersDirective, Inject, PointerDirective } from '@syncfusion/ej2-react-lineargauge';
export function App(){
function clickHandler(){
gaugeInstance.setAnnotationValue(0, '50', 50);
}
let gaugeInstance : LinearGaugeComponent;
return (<div>
<ButtonComponent onClick= { clickHandler }>Click</ButtonComponent>
<LinearGaugeComponent ref={g => gaugeInstance = g}>
<Inject services={[Annotations]}/>
<AnnotationsDirective>
<AnnotationDirective content='10' axisValue={0} zIndex='1'>
</AnnotationDirective>
</AnnotationsDirective>
<AxesDirective>
<AxisDirective>
<PointersDirective>
<PointerDirective value={10}>
</PointerDirective>
</PointersDirective>
</AxisDirective>
</AxesDirective>
</LinearGaugeComponent></div>);
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);
refresh
The refresh
method can be used to change the state of the component and render it again.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import {
LinearGaugeComponent,
AxesDirective,
AxisDirective,
PointersDirective,
PointerDirective,
} from '@syncfusion/ej2-react-lineargauge';
export function App() {
function clickHandler() {
gaugeInstance.axes[0].pointers[0].value = 50;
gaugeInstance.refresh();
}
var gaugeInstance;
return (
<div>
<ButtonComponent onClick={clickHandler}>
Click
</ButtonComponent>
<LinearGaugeComponent ref={(g) => (gaugeInstance = g)}>
<AxesDirective>
<AxisDirective>
<PointersDirective>
<PointerDirective value={10}></PointerDirective>
</PointersDirective>
</AxisDirective>
</AxesDirective>
</LinearGaugeComponent>
</div>
);
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import {
LinearGaugeComponent,
AxesDirective,
AxisDirective,
PointersDirective,
PointerDirective,
} from '@syncfusion/ej2-react-lineargauge';
export function App() {
function clickHandler() {
gaugeInstance.axes[0].pointers[0].value = 50;
gaugeInstance.refresh();
}
let gaugeInstance : LinearGaugeComponent;
return (
<div>
<ButtonComponent onClick={clickHandler}>
Click
</ButtonComponent>
<LinearGaugeComponent ref={(g) => (gaugeInstance = g)}>
<AxesDirective>
<AxisDirective>
<PointersDirective>
<PointerDirective value={10}></PointerDirective>
</PointersDirective>
</AxisDirective>
</AxesDirective>
</LinearGaugeComponent>
</div>
);
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);