You can categorize the axis values using start
and end
property in the ranges
. You can add any number of range for an axis by using array of range objects.
import { LinearGauge } from '@syncfusion/ej2-lineargauge';
let gauge: LinearGauge = new LinearGauge({
axes: [{
ranges: [{
start: 50,
end: 80
}]
}]
}, '#element');
<!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>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Ranges can be customized using the following properties.
startWidth
- Specifies start width of the rangeendWidth
- Specifies end width of the rangecolor
- Specifies color of the rangeposition
- Specifies the range bar position. Its possible values are ‘inside’ and ‘outside’Offset
- Specifies offset value from its default positionLinearGaugeRangeBorder
- Specifies range bar border color and width.import { LinearGauge } from '@syncfusion/ej2-lineargauge';
let gauge: LinearGauge = new LinearGauge({
axes: [{
ranges: [{
start: 50,
end: 80,
startWidth: 10,
endWidth: 20,
color: 'red'
}]
}]
}, '#element');
<!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>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
You can add multiple ranges to an axis as demonstrated below.
import { LinearGauge } from '@syncfusion/ej2-lineargauge';
let gauge: LinearGauge = new LinearGauge({
axes: [{
ranges: [
{
start: 0,
end: 30,
startWidth: 10,
endWidth: 10,
color: '#41f47f'
},
{
start: 30,
end: 50,
startWidth: 10,
endWidth: 10,
color: '#f49441'
}, {
start: 50,
end: 100,
startWidth: 10,
endWidth: 10,
color: '#cd41f4'
}
]
}]
}, '#element');
<!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>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Gradient support allows to add multiple colors in the ranges and pointers of the circular gauge. The following gradient types are supported in the linear gauge.
Using linear gradient, colors will be applied in a linear progression. The start value of the linear gradient can be set using the startValue
property. The end value of the linear gradient will be set using the endValue
property. The color stop values such as color, opacity and offset are set using colorStop
property.
To apply linear gradient to the range, follow the below code sample.
import { LinearGauge, Gradient } from '@syncfusion/ej2-lineargauge';
LinearGauge.Inject(Gradient);
let gauge: LinearGauge = new LinearGauge({
orientation: 'Horizontal',
container: {
width: 30, offset: 30
},
axes: [{
line: { width: 0 },
majorTicks: { height: 0, interval: 25 },
minorTicks: { height: 0 },
labelStyle: {
font: { color: '#424242',
}, offset: 55
},
pointers: [{
value: 80, height: 25,
width: 35, placement: 'Near',
offset: -44, markerType: 'Triangle',
color: '#f54ea2'
}],
ranges: [{
start: 0, end: 80,
startWidth: 30, endWidth: 30,
offset: 30,
linearGradient: {
startValue: '0%',
endValue: '100%',
colorStop: [
{ color: '#fef3f9', offset: '0%', opacity: 1 },
{ color: '#f54ea2', offset: '100%', opacity: 1 }]
}
}]
}]
}, '#element');
<!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>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Using radial gradient, colors will be applied in circular progression. The inner circle position of the radial gradient will be set using the innerPosition
property. The outer circle position of the radial gradient can be set using the outerPosition
property. The color stop values such as color, opacity and offset are set using colorStop
property.
To apply radial gradient to the range, follow the below code sample.
import { LinearGauge, Gradient } from '@syncfusion/ej2-lineargauge';
LinearGauge.Inject(Gradient);
let gauge: LinearGauge = new LinearGauge({
orientation: 'Horizontal',
container: {
width: 30, offset: 30
},
axes: [{
line: { width: 0 },
majorTicks: { height: 0, interval: 25 },
minorTicks: { height: 0 },
labelStyle: {
font: { color: '#424242',
}, offset: 55
},
pointers: [{
value: 80, height: 25,
width: 35, placement: 'Near',
offset: -44, markerType: 'Triangle',
color: '#f54ea2'
}],
ranges: [{
start: 0, end: 80,
startWidth: 30, endWidth: 30,
offset: 30,
radialGradient: {
radius: '65%',
outerPosition: { x: '50%', y: '70%' },
innerPosition: { x: '60%', y: '60%' },
colorStop: [
{ color: '#fff5f5', offset: '5%', opacity: 0.9 },
{ color: '#f54ea2', offset: '100%', opacity: 0.9 }]
}
}]
}]
}, '#element');
<!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>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>