To render a range area series, use series type
as RangeArea
and inject RangeAreaSeries
module using Chart.Inject(RangeAreaSeries)
method.
Since the RangeArea series requires two y values for a point, you have to add the high and low value. High and Low value specifies the maximum and minimum range of the points.
var series= [];
var value = 70;
var point;
for (var i = 1; i < 70; i++) {
if (Math.random() > .5) {
value += Math.random();
} else {
value -= Math.random();
}
point = { x: new Date(1930 + i, 5, i), high: value, low: value - 14 };
series.push(point);
}
var chart = new ej.charts.Chart({
primaryXAxis: {
title: 'Month',
valueType: 'DateTime',
edgeLabelPlacement: 'Shift',
},
primaryYAxis:
{
title: 'Temperature(Celsius)',
minimum: 50, maximum: 80, interval: 5,
},
series: [
{
type: 'RangeArea',
name: 'India',
dataSource: series,
xName: 'x', high: 'high', low: 'low'
}],
title: 'Maximum and Minimum Temperature',
}, '#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://cdn.syncfusion.com/ej2/21.2.3/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
The following properties can be used to customize the range area
series.
fill
– Specifies the color of the area series.opacity
– Specifies the opacity of fill
.dashArray
– Specifies the dashes of series.border
– Specifies the color
and width
of series border.var series= [];
var value = 70;
var point;
for (var i = 1; i < 70; i++) {
if (Math.random() > .5) {
value += Math.random();
} else {
value -= Math.random();
}
point = { x: new Date(1930 + i, 5, i), high: value, low: value - 14 };
series.push(point);
}
var chart = new ej.charts.Chart({
primaryXAxis: {
title: 'Month',
valueType: 'DateTime',
edgeLabelPlacement: 'Shift',
},
primaryYAxis:
{
title: 'Temperature(Celsius)',
minimum: 50, maximum: 80, interval: 5,
},
series: [
{
type: 'RangeArea',
name: 'India',
dataSource: series,
xName: 'x', high: 'high', low: 'low', opacity: 0.5,
opacity: 0.7,
dashArray:'4',fill:'grey', border: { color: 'blueviolet', width: 1 }
}],
title: 'Maximum and Minimum Temperature',
}, '#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://cdn.syncfusion.com/ej2/21.2.3/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>