Range step area in ASP.NET CORE Charts component
8 Oct 202424 minutes to read
Range step area
To render a range step 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 RangeStepArea in your chart configuration. This indicates that the data should be represented as a range step area chart, which is ideal for displaying data points as a range with high and low values. It connects these points with vertical and horizontal lines, creating a step like appearance.
-
Provide high and low values: The RangeStepArea 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" title="Monthly Temperature Range">
<e-chart-primaryxaxis valueType="Category" edgeLabelPlacement="Shift">
<e-majorgridlines width="0"></e-majorgridlines>
</e-chart-primaryxaxis>
<e-chart-primaryyaxis labelFormat="{value}˚C" minimum="0" maximum="40">
<e-linestyle width="0"></e-linestyle>
<e-majorticklines width="0"></e-majorticklines>
</e-chart-primaryyaxis>
<e-series-collection>
<e-series name="India" xName="x" high="high" low="low" dataSource="ViewBag.dataSource"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea">
</e-series>
</e-series-collection>
</ejs-chart>
public IActionResult Index ()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { x = "Jan", high = 14, low = 4, high1 = 29, low1 = 19 },
new ChartData { x = "Feb", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Mar", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Apr", high = 22, low = 12, high1 = 37, low1 = 27 },
new ChartData { x = "May", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Jun", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Jul", high = 15, low = 5, high1 = 30, low1 = 20 },
new ChartData { x = "Aug", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Sep", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Oct", high = 22, low = 12, high1 = 37, low1 = 27 },
new ChartData { x = "Nov", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Dec", high = 17, low = 7, high1 = 32, low1 = 22 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string x;
public double high;
public double low;
public double high1;
public double low1;
}
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" title="Monthly Temperature Range">
<e-chart-primaryxaxis valueType="Category" edgeLabelPlacement="Shift">
<e-majorgridlines width="0"></e-majorgridlines>
</e-chart-primaryxaxis>
<e-chart-primaryyaxis labelFormat="{value}˚C" minimum="0" maximum="40">
<e-linestyle width="0"></e-linestyle>
<e-majorticklines width="0"></e-majorticklines>
</e-chart-primaryyaxis>
<e-series-collection>
<e-series name="India" xName="x" high="high" low="low" dataSource="ViewBag.dataSource"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea">
</e-series>
</e-series-collection>
</ejs-chart>
public IActionResult Index ()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { x = "Jan", high = 14, low = 4, high1 = 29, low1 = 19 },
new ChartData { x = "Feb", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Mar", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Apr", high = 22, low = 12, high1 = 37, low1 = 27 },
new ChartData { x = "May", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Jun", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Jul", high = 15, low = 5, high1 = 30, low1 = 20 },
new ChartData { x = "Aug", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Sep", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Oct", high = 22, low = 12, high1 = 37, low1 = 27 },
new ChartData { x = "Nov", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Dec", high = 17, low = 7, high1 = 32, low1 = 22 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string x;
public double high;
public double low;
public double high1;
public double low1;
}
Series customization
The following properties can be used to customize the range step area
series.
Fill
The fill
property determines the color applied to the series.
<ejs-chart id="container" title="Monthly Temperature Range">
<e-chart-primaryxaxis valueType="Category" edgeLabelPlacement="Shift">
<e-majorgridlines width="0"></e-majorgridlines>
</e-chart-primaryxaxis>
<e-chart-primaryyaxis labelFormat="{value}˚C" minimum="0" maximum="40">
<e-linestyle width="0"></e-linestyle>
<e-majorticklines width="0"></e-majorticklines>
</e-chart-primaryyaxis>
<e-series-collection>
<e-series name="India" xName="x" high="high" low="low" dataSource="ViewBag.dataSource" fill="blue"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea">
</e-series>
</e-series-collection>
</ejs-chart>
public IActionResult Index ()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { x = "Jan", high = 14, low = 4, high1 = 29, low1 = 19 },
new ChartData { x = "Feb", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Mar", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Apr", high = 22, low = 12, high1 = 37, low1 = 27 },
new ChartData { x = "May", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Jun", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Jul", high = 15, low = 5, high1 = 30, low1 = 20 },
new ChartData { x = "Aug", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Sep", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Oct", high = 22, low = 12, high1 = 37, low1 = 27 },
new ChartData { x = "Nov", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Dec", high = 17, low = 7, high1 = 32, low1 = 22 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string x;
public double high;
public double low;
public double high1;
public double low1;
}
The fill
property can be used to apply a gradient color to the range step 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" title="Monthly Temperature Range">
<e-chart-primaryxaxis valueType="Category" edgeLabelPlacement="Shift">
<e-majorgridlines width="0"></e-majorgridlines>
</e-chart-primaryxaxis>
<e-chart-primaryyaxis labelFormat="{value}˚C" minimum="0" maximum="40">
<e-linestyle width="0"></e-linestyle>
<e-majorticklines width="0"></e-majorticklines>
</e-chart-primaryyaxis>
<e-series-collection>
<e-series name="India" xName="x" high="high" low="low" dataSource="ViewBag.dataSource" fill="url(#gradient)"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea">
</e-series>
</e-series-collection>
</ejs-chart>
public IActionResult Index ()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { x = "Jan", high = 14, low = 4, high1 = 29, low1 = 19 },
new ChartData { x = "Feb", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Mar", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Apr", high = 22, low = 12, high1 = 37, low1 = 27 },
new ChartData { x = "May", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Jun", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Jul", high = 15, low = 5, high1 = 30, low1 = 20 },
new ChartData { x = "Aug", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Sep", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Oct", high = 22, low = 12, high1 = 37, low1 = 27 },
new ChartData { x = "Nov", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Dec", high = 17, low = 7, high1 = 32, low1 = 22 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string x;
public double high;
public double low;
public double high1;
public double low1;
}
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" title="Monthly Temperature Range">
<e-chart-primaryxaxis valueType="Category" edgeLabelPlacement="Shift">
<e-majorgridlines width="0"></e-majorgridlines>
</e-chart-primaryxaxis>
<e-chart-primaryyaxis labelFormat="{value}˚C" minimum="0" maximum="40">
<e-linestyle width="0"></e-linestyle>
<e-majorticklines width="0"></e-majorticklines>
</e-chart-primaryyaxis>
<e-series-collection>
<e-series name="India" xName="x" high="high" low="low" dataSource="ViewBag.dataSource" opacity="0.7"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea">
</e-series>
</e-series-collection>
</ejs-chart>
public IActionResult Index ()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { x = "Jan", high = 14, low = 4, high1 = 29, low1 = 19 },
new ChartData { x = "Feb", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Mar", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Apr", high = 22, low = 12, high1 = 37, low1 = 27 },
new ChartData { x = "May", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Jun", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Jul", high = 15, low = 5, high1 = 30, low1 = 20 },
new ChartData { x = "Aug", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Sep", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Oct", high = 22, low = 12, high1 = 37, low1 = 27 },
new ChartData { x = "Nov", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Dec", high = 17, low = 7, high1 = 32, low1 = 22 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string x;
public double high;
public double low;
public double high1;
public double low1;
}
Dash array
The dashArray
property determines the pattern of dashes and gaps in the series.
<ejs-chart id="container" title="Monthly Temperature Range">
<e-chart-primaryxaxis valueType="Category" edgeLabelPlacement="Shift">
<e-majorgridlines width="0"></e-majorgridlines>
</e-chart-primaryxaxis>
<e-chart-primaryyaxis labelFormat="{value}˚C" minimum="0" maximum="40">
<e-linestyle width="0"></e-linestyle>
<e-majorticklines width="0"></e-majorticklines>
</e-chart-primaryyaxis>
<e-series-collection>
<e-series name="India" xName="x" high="high" low="low" dataSource="ViewBag.dataSource" dashArray="5,5"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea">
<e-series-border width="2" color="red"></e-series-border>
</e-series>
</e-series-collection>
</ejs-chart>
public IActionResult Index ()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { x = "Jan", high = 14, low = 4, high1 = 29, low1 = 19 },
new ChartData { x = "Feb", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Mar", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Apr", high = 22, low = 12, high1 = 37, low1 = 27 },
new ChartData { x = "May", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Jun", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Jul", high = 15, low = 5, high1 = 30, low1 = 20 },
new ChartData { x = "Aug", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Sep", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Oct", high = 22, low = 12, high1 = 37, low1 = 27 },
new ChartData { x = "Nov", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Dec", high = 17, low = 7, high1 = 32, low1 = 22 }
};
ViewBag.dataSource = chartData;
ChartBorder border = new ChartBorder();
border.Width = 2;
border.Color = "#ff4251";
ViewBag.border = border;
return View();
}
public class ChartData
{
public string x;
public double high;
public double low;
public double high1;
public double low1;
}
Step
Use the step
property to change the position of the steps in a range step area series.
<ejs-chart id="container" title="Monthly Temperature Range">
<e-chart-primaryxaxis valueType="Category" edgeLabelPlacement="Shift">
<e-majorgridlines width="0"></e-majorgridlines>
</e-chart-primaryxaxis>
<e-chart-primaryyaxis labelFormat="{value}˚C" minimum="0" maximum="40">
<e-linestyle width="0"></e-linestyle>
<e-majorticklines width="0"></e-majorticklines>
</e-chart-primaryyaxis>
<e-series-collection>
<e-series name="India" xName="x" high="high" low="low" dataSource="ViewBag.dataSource" step="Right"
type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea">
</e-series>
</e-series-collection>
</ejs-chart>
public IActionResult Index ()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { x = "Jan", high = 14, low = 4, high1 = 29, low1 = 19 },
new ChartData { x = "Feb", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Mar", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Apr", high = 22, low = 12, high1 = 37, low1 = 27 },
new ChartData { x = "May", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Jun", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Jul", high = 15, low = 5, high1 = 30, low1 = 20 },
new ChartData { x = "Aug", high = 17, low = 7, high1 = 32, low1 = 22 },
new ChartData { x = "Sep", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Oct", high = 22, low = 12, high1 = 37, low1 = 27 },
new ChartData { x = "Nov", high = 20, low = 10, high1 = 35, low1 = 25 },
new ChartData { x = "Dec", high = 17, low = 7, high1 = 32, low1 = 22 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string x;
public double high;
public double low;
public double high1;
public double low1;
}
No risers
You can eliminate the vertical lines between points by using the NoRisers
property in a series. This approach is useful for highlighting trends without the distraction of risers.
<ejs-chart id="container" title="Monthly Temperature Range">
<e-chart-primaryxaxis valueType="@Syncfusion.EJ2.Charts.ValueType.Category" title="Month" edgeLabelPlacement="@Syncfusion.EJ2.Charts.EdgeLabelPlacement.Shift">
<e-majorgridlines width="0"></e-majorgridlines>
</e-chart-primaryxaxis>
<e-chart-primaryyaxis labelFormat="{value}˚C" minimum="10" maximum="40" title="Temperature">
<e-linestyle width="0"></e-linestyle>
<e-majorticklines width="0"></e-majorticklines>
</e-chart-primaryyaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="X" high="High" low="Low" noRisers="true" type="@Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea">
</e-series>
</e-series-collection>
</ejs-chart>
public IActionResult Index ()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { X = "Jan", High = 29, Low = 19 },
new ChartData { X = "Feb", High = 32, Low = 22 },
new ChartData { X = "Mar", High = 35, Low = 25 },
new ChartData { X = "Apr", High = 37, Low = 27 },
new ChartData { X = "May", High = 35, Low = 25 },
new ChartData { X = "Jun", High = 32, Low = 22 },
new ChartData { X = "Jul", High = 30, Low = 20 },
new ChartData { X = "Aug", High = 32, Low = 22 },
new ChartData { X = "Sep", High = 35, Low = 25 },
new ChartData { X = "Oct", High = 37, Low = 27 },
new ChartData { X = "Nov", High = 35, Low = 25 },
new ChartData { X = "Dec", High = 32, Low = 22 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string X;
public double High;
public double Low;
}
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.RangeStepArea">
<e-series-emptypointsettings mode="Syncfusion.EJ2.Charts.EmptyPointMode.Gap"></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.RangeStepArea">
<e-series-marker visible="true" height="7" width="7" isFilled="true"></e-series-marker>
<e-series-emptypointsettings mode="Syncfusion.EJ2.Charts.EmptyPointMode.Average" 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.Zero;
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.RangeStepArea">
</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.RangeStepArea">
<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;
}