Range Area in ASP.NET CORE Charts Component
13 Dec 202424 minutes to read
Range Area
To render a range area series in your chart, you need to follow a few steps to configure it correctly. Here’s a concise guide on how to do this:
-
Set the series type: Define the series
type
as RangeArea in your chart configuration. This indicates that the data should be represented as a range area chart, which is ideal for visualizing a range of values for each data point. This type of chart is particularly useful for displaying data that has a range between a minimum and maximum value, such as temperature ranges, stock price ranges, or any other type of data that varies within a specific interval. -
Provide high and low values: The RangeArea series requires two y-values for each data point, you need to specify both the high and low values. The high value represents the maximum range, while the low value represents the minimum range for each data point. These values define the upper and lower boundaries of the area for each point on the chart.
<ejs-chart id="container">
<e-chart-primaryxaxis valueType="Category">
</e-chart-primaryxaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeArea"></e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<AxisLabelData> chartData = new List<AxisLabelData>
{
new AxisLabelData { x= "Sun", low= 2.5, high= 9.8 },
new AxisLabelData { x= "Mon", low= 4.7, high= 11.4 },
new AxisLabelData { x= "Tue", low= 6.4, high= 14.4 },
new AxisLabelData { x= "Wed", low= 9.6, high= 17.2 },
new AxisLabelData { x= "Thu", low= 7.5, high= 15.1 },
new AxisLabelData { x= "Fri", low= 3.0, high= 10.5 },
new AxisLabelData { x= "Sat", low= 1.2, high= 7.9 }
};
ViewBag.dataSource = chartData;
return View();
}
public class AxisLabelData
{
public string x;
public double low;
public double high;
}
Binding data with series
You can bind data to the chart using the dataSource
property within the series configuration. This allows you to connect a JSON dataset or remote data to your chart. To display the data correctly, map the fields from the data to the chart series xName
, high
, and low
properties.
<ejs-chart id="container">
<e-chart-primaryxaxis valueType="Category">
</e-chart-primaryxaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeArea"></e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<AxisLabelData> chartData = new List<AxisLabelData>
{
new AxisLabelData { x= "Sun", low= 2.5, high= 9.8 },
new AxisLabelData { x= "Mon", low= 4.7, high= 11.4 },
new AxisLabelData { x= "Tue", low= 6.4, high= 14.4 },
new AxisLabelData { x= "Wed", low= 9.6, high= 17.2 },
new AxisLabelData { x= "Thu", low= 7.5, high= 15.1 },
new AxisLabelData { x= "Fri", low= 3.0, high= 10.5 },
new AxisLabelData { x= "Sat", low= 1.2, high= 7.9 }
};
ViewBag.dataSource = chartData;
return View();
}
public class AxisLabelData
{
public string x;
public double low;
public double high;
}
Series customization
The following properties can be used to customize the range area series.
Fill
The fill
property determines the color applied to the series.
<ejs-chart id="container">
<e-chart-primaryxaxis valueType="Category">
</e-chart-primaryxaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeArea" fill="blue"></e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<AxisLabelData> chartData = new List<AxisLabelData>
{
new AxisLabelData { x= "Sun", low= 2.5, high= 9.8 },
new AxisLabelData { x= "Mon", low= 4.7, high= 11.4 },
new AxisLabelData { x= "Tue", low= 6.4, high= 14.4 },
new AxisLabelData { x= "Wed", low= 9.6, high= 17.2 },
new AxisLabelData { x= "Thu", low= 7.5, high= 15.1 },
new AxisLabelData { x= "Fri", low= 3.0, high= 10.5 },
new AxisLabelData { x= "Sat", low= 1.2, high= 7.9 }
};
ViewBag.dataSource = chartData;
return View();
}
public class AxisLabelData
{
public string x;
public double low;
public double high;
}
The fill
property can be used to apply a gradient color to the range area series. By configuring this property with gradient values, you can create a visually appealing effect in which the color transitions smoothly from one shade to another.
<svg style="width:1px; height:1px">
<defs>
<linearGradient id="gradient">
<stop offset="0%" style="stop-color:blue;stop-opacity:5" />
<stop offset="50%" style="stop-color:violet;stop-opacity:5" />
</linearGradient>
</defs>
</svg>
<ejs-chart id="container">
<e-chart-primaryxaxis valueType="Category">
</e-chart-primaryxaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeArea" fill="url(#gradient)"></e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<AxisLabelData> chartData = new List<AxisLabelData>
{
new AxisLabelData { x= "Sun", low= 2.5, high= 9.8 },
new AxisLabelData { x= "Mon", low= 4.7, high= 11.4 },
new AxisLabelData { x= "Tue", low= 6.4, high= 14.4 },
new AxisLabelData { x= "Wed", low= 9.6, high= 17.2 },
new AxisLabelData { x= "Thu", low= 7.5, high= 15.1 },
new AxisLabelData { x= "Fri", low= 3.0, high= 10.5 },
new AxisLabelData { x= "Sat", low= 1.2, high= 7.9 }
};
ViewBag.dataSource = chartData;
return View();
}
public class AxisLabelData
{
public string x;
public double low;
public double high;
}
Opacity
The opacity
property specifies the transparency level of the fill. Adjusting this property allows you to control how opaque or transparent the fill color of the series appears.
<ejs-chart id="container">
<e-chart-primaryxaxis valueType="Category">
</e-chart-primaryxaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeArea" opacity="0.5"></e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<AxisLabelData> chartData = new List<AxisLabelData>
{
new AxisLabelData { x= "Sun", low= 2.5, high= 9.8 },
new AxisLabelData { x= "Mon", low= 4.7, high= 11.4 },
new AxisLabelData { x= "Tue", low= 6.4, high= 14.4 },
new AxisLabelData { x= "Wed", low= 9.6, high= 17.2 },
new AxisLabelData { x= "Thu", low= 7.5, high= 15.1 },
new AxisLabelData { x= "Fri", low= 3.0, high= 10.5 },
new AxisLabelData { x= "Sat", low= 1.2, high= 7.9 }
};
ViewBag.dataSource = chartData;
return View();
}
public class AxisLabelData
{
public string x;
public double low;
public double high;
}
Border
Use the border
property to customize the width, color and dasharray of the series border.
<ejs-chart id="container">
<e-chart-primaryxaxis valueType="Category">
</e-chart-primaryxaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeArea" dashArray="5,5">
<e-series-border width="2" color="red" dashArray="5,5"></e-series-border>
</e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<AxisLabelData> chartData = new List<AxisLabelData>
{
new AxisLabelData { x= "Sun", low= 2.5, high= 9.8 },
new AxisLabelData { x= "Mon", low= 4.7, high= 11.4 },
new AxisLabelData { x= "Tue", low= 6.4, high= 14.4 },
new AxisLabelData { x= "Wed", low= 9.6, high= 17.2 },
new AxisLabelData { x= "Thu", low= 7.5, high= 15.1 },
new AxisLabelData { x= "Fri", low= 3.0, high= 10.5 },
new AxisLabelData { x= "Sat", low= 1.2, high= 7.9 }
};
ViewBag.dataSource = chartData;
ChartBorder border = new ChartBorder();
border.Width = 2;
border.Color = "#962D18";
border.DashArray="5,5";
ViewBag.seriesBorder = border;
return View();
}
public class AxisLabelData
{
public string x;
public double low;
public double high;
}
Empty points
Data points with null or undefined values are considered empty. Empty data points are ignored and not plotted on the chart.
Mode
Use the mode
property to define how empty or missing data points are handled in the series. The default mode for empty points is Gap.
<ejs-chart id="container">
<e-chart-primaryxaxis valueType="Category">
</e-chart-primaryxaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeArea">
<e-series-emptypointsettings mode="Syncfusion.EJ2.Charts.EmptyPointMode.Zero"></e-series-emptypointsettings>
</e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<AxisLabelData> chartData = new List<AxisLabelData>
{
new AxisLabelData { x= "Sun", low= 2.5, high= 9.8 },
new AxisLabelData { x= "Mon", low= 4.7, high= 11.4 },
new AxisLabelData { x= "Tue", low= null, high= 14.4 },
new AxisLabelData { x= "Wed", low= 9.6, high= 17.2 },
new AxisLabelData { x= "Thu", low= 7.5 },
new AxisLabelData { x= "Fri", low= 3.0, high= 10.5 },
new AxisLabelData { x= "Sat", low= 1.2, high= 7.9 }
};
ViewBag.dataSource = chartData;
ChartEmptyPointSettings emptyPointSettings = new ChartEmptyPointSettings();
emptyPointSettings.Mode = EmptyPointMode.Zero;
ViewBag.empty = emptyPointSettings;
return View();
}
public class AxisLabelData
{
public string x;
public double low;
public double high;
}
Fill
Use the fill
property to customize the fill color of empty points in the series.
<ejs-chart id="container">
<e-chart-primaryxaxis valueType="Category">
</e-chart-primaryxaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeArea">
<e-series-marker visible="true" height="7" width="7" isFilled="true"></e-series-marker>
<e-series-emptypointsettings mode="Syncfusion.EJ2.Charts.EmptyPointMode.Zero" fill="red"></e-series-emptypointsettings>
</e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<AxisLabelData> chartData = new List<AxisLabelData>
{
new AxisLabelData { x= "Sun", low= 2.5, high= 9.8 },
new AxisLabelData { x= "Mon", low= 4.7, high= 11.4 },
new AxisLabelData { x= "Tue", low= null, high= 14.4 },
new AxisLabelData { x= "Wed", low= 9.6, high= 17.2 },
new AxisLabelData { x= "Thu", low= 7.5 },
new AxisLabelData { x= "Fri", low= 3.0, high= 10.5 },
new AxisLabelData { x= "Sat", low= 1.2, high= 7.9 }
};
ViewBag.dataSource = chartData;
ChartEmptyPointSettings emptyPointSettings = new ChartEmptyPointSettings();
emptyPointSettings.Mode = EmptyPointMode.Average;
emptyPointSettings.Fill = "red";
ViewBag.empty = emptyPointSettings;
ChartMarkerSettings markerSettings = new ChartMarkerSettings();
markerSettings.Visible = true;
markerSettings.Width = 7;
markerSettings.Height = 7;
markerSettings.IsFilled = true;
ViewBag.marker = markerSettings;
return View();
}
public class AxisLabelData
{
public string x;
public double low;
public double high;
}
Border
Use the border
property to customize the width and color of the border for empty points.
<ejs-chart id="container">
<e-chart-primaryxaxis valueType="Category">
</e-chart-primaryxaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeArea">
<e-series-marker visible="true" height="7" width="7" isFilled="true"></e-series-marker>
<e-series-emptypointsettings mode="Syncfusion.EJ2.Charts.EmptyPointMode.Zero" fill="red">
<e-emptypointsettings-border width="2" color="green"></e-emptypointsettings-border>
</e-series-emptypointsettings>
</e-series>
</e-series-collection>
</ejs-chart>
public ActionResult Index()
{
List<AxisLabelData> chartData = new List<AxisLabelData>
{
new AxisLabelData { x= "Sun", low= 2.5, high= 9.8 },
new AxisLabelData { x= "Mon", low= 4.7, high= 11.4 },
new AxisLabelData { x= "Tue", low= null, high= 14.4 },
new AxisLabelData { x= "Wed", low= 9.6, high= 17.2 },
new AxisLabelData { x= "Thu", low= 7.5 },
new AxisLabelData { x= "Fri", low= 3.0, high= 10.5 },
new AxisLabelData { x= "Sat", low= 1.2, high= 7.9 }
};
ViewBag.dataSource = chartData;
ChartEmptyPointSettings emptyPointSettings = new ChartEmptyPointSettings();
emptyPointSettings.Mode = EmptyPointMode.Average;
emptyPointSettings.Border.Width = 2;
emptyPointSettings.Border.Color = "green";
ViewBag.empty = emptyPointSettings;
ChartMarkerSettings markerSettings = new ChartMarkerSettings();
markerSettings.Visible = true;
markerSettings.Width = 7;
markerSettings.Height = 7;
markerSettings.IsFilled = true;
ViewBag.marker = markerSettings;
return View();
}
public class AxisLabelData
{
public string x;
public double low;
public double high;
}
Events
Series render
The seriesRender
event allows you to customize series properties, such as data, fill, and name, before they are rendered on the chart.
<ejs-chart id="container" seriesRender="changeColor">
<e-chart-primaryxaxis valueType="Category">
</e-chart-primaryxaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeArea">
</e-series>
</e-series-collection>
</ejs-chart>
<script>
function changeColor(args) {
args.fill = '#ff6347';
}
</script>
public ActionResult Index()
{
List<AxisLabelData> chartData = new List<AxisLabelData>
{
new AxisLabelData { x= "Sun", low= 2.5, high= 9.8 },
new AxisLabelData { x= "Mon", low= 4.7, high= 11.4 },
new AxisLabelData { x= "Tue", low= 6.4, high= 14.4 },
new AxisLabelData { x= "Wed", low= 9.6, high= 17.2 },
new AxisLabelData { x= "Thu", low= 7.5, high= 15.1 },
new AxisLabelData { x= "Fri", low= 3.0, high= 10.5 },
new AxisLabelData { x= "Sat", low= 1.2, high= 7.9 }
};
ViewBag.dataSource = chartData;
return View();
}
public class AxisLabelData
{
public string x;
public double low;
public double high;
}
Point render
The pointRender
event allows you to customize each data point before it is rendered on the chart.
<ejs-chart id="container" pointRender="changeColor">
<e-chart-primaryxaxis valueType="Category">
</e-chart-primaryxaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeArea">
<e-series-marker visible="true" height="7" width="7" isFilled="true"></e-series-marker>
</e-series>
</e-series-collection>
</ejs-chart>
<script>
function changeColor(args) {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
}
</script>
public ActionResult Index()
{
List<AxisLabelData> chartData = new List<AxisLabelData>
{
new AxisLabelData { x= "Sun", low= 2.5, high= 9.8 },
new AxisLabelData { x= "Mon", low= 4.7, high= 11.4 },
new AxisLabelData { x= "Tue", low= 6.4, high= 14.4 },
new AxisLabelData { x= "Wed", low= 9.6, high= 17.2 },
new AxisLabelData { x= "Thu", low= 7.5, high= 15.1 },
new AxisLabelData { x= "Fri", low= 3.0, high= 10.5 },
new AxisLabelData { x= "Sat", low= 1.2, high= 7.9 }
};
ViewBag.dataSource = chartData;
return View();
}
public class AxisLabelData
{
public string x;
public double low;
public double high;
}