Contents
- setPointerValue
- setAnnotationValue
- refresh
Having trouble getting help?
Contact Support
Contact Support
Methods in EJ2 TypeScript Linear gauge control
31 Aug 20237 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 { LinearGauge } from '@syncfusion/ej2-lineargauge';
let gauge: LinearGauge = new LinearGauge({
axes: [{
pointers: [{
value: 80
}]
}]
}, '#element');
document.getElementById('btn').onclick = () => {
gauge.setPointerValue(0, 0, 30);
};
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container' style="margin-top: 20%;">
<div id='element' style="margin-top: 20%;"></div>
<button id="btn" type="button" width ='15%' style="float: right">Click me</button>
</div>
</body>
</html>
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 { LinearGauge, Annotations } from '@syncfusion/ej2-lineargauge';
LinearGauge.Inject(Annotations);
let gauge: LinearGauge = new LinearGauge({
annotations: [{
content: '10',
zIndex: '1',
axisValue: 0
}]
}, '#element');
document.getElementById('btn').onclick = () => {
gauge.setAnnotationValue(0, '50', 50);
};
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container' style="margin-top: 20%;">
<div id='element' style="margin-top: 20%;"></div>
<button id="btn" type="button" width ='15%' style="float: right">Click me</button>
</div>
</body>
</html>
refresh
The refresh
method can be used to change the state of the component and render it again.
import { LinearGauge } from '@syncfusion/ej2-lineargauge';
let gauge: LinearGauge = new LinearGauge({
axes:[{
pointers:[{
value: 10
}]
}]
}, '#element');
document.getElementById('btn').onclick = () => {
gauge.refresh();
};
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container' style="margin-top: 20%;">
<div id='element' style="margin-top: 20%;"></div>
<button id="btn" type="button" width ='15%' style="float: right">Click me</button>
</div>
</body>
</html>