Range step area in ASP.NET MVC 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.
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea).
XName("x").
High("high").
Low("low").
DataSource(ViewBag.dataSource).
Name("India").
Add();
}).PrimaryXAxis(px =>
px.MajorGridLines(mg => mg.Width(0))
.EdgeLabelPlacement(Syncfusion.EJ2.Charts.EdgeLabelPlacement.Shift)
.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).PrimaryYAxis(py => py.LabelFormat("{value}˚C")
.Minimum(0)
.Maximum(40)
.MajorTickLines(mt => mt.Width(0))
.LineStyle(ls => ls.Width(0))
).Title("Monthly Temperature Range").Render()
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.
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea).
XName("x").
High("high").
Low("low").
DataSource(ViewBag.dataSource).
Name("India").
Add();
}).PrimaryXAxis(px =>
px.MajorGridLines(mg => mg.Width(0))
.EdgeLabelPlacement(Syncfusion.EJ2.Charts.EdgeLabelPlacement.Shift)
.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).PrimaryYAxis(py => py.LabelFormat("{value}˚C")
.Minimum(0)
.Maximum(40)
.MajorTickLines(mt => mt.Width(0))
.LineStyle(ls => ls.Width(0))
).Title("Monthly Temperature Range").Render()
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.
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea).
XName("x").
High("high").
Low("low").
DataSource(ViewBag.dataSource).
Fill("blue").
Name("India").
Add();
}).PrimaryXAxis(px =>
px.MajorGridLines(mg => mg.Width(0))
.EdgeLabelPlacement(Syncfusion.EJ2.Charts.EdgeLabelPlacement.Shift)
.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).PrimaryYAxis(py => py.LabelFormat("{value}˚C")
.Minimum(0)
.Maximum(40)
.MajorTickLines(mt => mt.Width(0))
.LineStyle(ls => ls.Width(0))
).Title("Monthly Temperature Range").Render()
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>
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea).
XName("x").
High("high").
Low("low").
DataSource(ViewBag.dataSource).
Fill("url(#gradient)").
Name("India").
Add();
}).PrimaryXAxis(px =>
px.MajorGridLines(mg => mg.Width(0))
.EdgeLabelPlacement(Syncfusion.EJ2.Charts.EdgeLabelPlacement.Shift)
.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).PrimaryYAxis(py => py.LabelFormat("{value}˚C")
.Minimum(0)
.Maximum(40)
.MajorTickLines(mt => mt.Width(0))
.LineStyle(ls => ls.Width(0))
).Title("Monthly Temperature Range").Render()
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.
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea).
XName("x").
High("high").
Low("low").
DataSource(ViewBag.dataSource).
Name("India").
Opacity(0.7)
Add();
}).PrimaryXAxis(px =>
px.MajorGridLines(mg => mg.Width(0))
.EdgeLabelPlacement(Syncfusion.EJ2.Charts.EdgeLabelPlacement.Shift)
.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).PrimaryYAxis(py => py.LabelFormat("{value}˚C")
.Minimum(0)
.Maximum(40)
.MajorTickLines(mt => mt.Width(0))
.LineStyle(ls => ls.Width(0))
).Title("Monthly Temperature Range").Render()
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.
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea).
XName("x").
High("high").
Low("low").
DataSource(ViewBag.dataSource).
DashArray("5,5").
Border(ViewBag.border).
Name("India").
Add();
}).PrimaryXAxis(px =>
px.MajorGridLines(mg => mg.Width(0))
.EdgeLabelPlacement(Syncfusion.EJ2.Charts.EdgeLabelPlacement.Shift)
.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).PrimaryYAxis(py => py.LabelFormat("{value}˚C")
.Minimum(0)
.Maximum(40)
.MajorTickLines(mt => mt.Width(0))
.LineStyle(ls => ls.Width(0))
).Title("Monthly Temperature Range").Render()
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.
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea).
XName("x").
High("high").
Low("low").
DataSource(ViewBag.dataSource).
Step(Syncfusion.EJ2.Charts.StepPosition.Right).
Name("India").
Add();
}).PrimaryXAxis(px =>
px.MajorGridLines(mg => mg.Width(0))
.EdgeLabelPlacement(Syncfusion.EJ2.Charts.EdgeLabelPlacement.Shift)
.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
).PrimaryYAxis(py => py.LabelFormat("{value}˚C")
.Minimum(0)
.Maximum(40)
.MajorTickLines(mt => mt.Width(0))
.LineStyle(ls => ls.Width(0))
).Title("Monthly Temperature Range").Render()
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.
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea)
.XName("X")
.High("High")
.Low("Low")
.NoRisers(true)
.DataSource(ViewBag.dataSource)
.Add();
}).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
.EdgeLabelPlacement(Syncfusion.EJ2.Charts.EdgeLabelPlacement.Shift)
.Title("Month")
.MajorGridLines(mg => mg.Width(0))
).PrimaryYAxis(py => py.LabelFormat("{value}˚C")
.Minimum(10)
.Maximum(40)
.Title("Temperature")
.MajorTickLines(mt => mt.Width(0))
.LineStyle(ls => ls.Width(0))
).Title("Monthly Temperature Range").Render()
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.
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea).
XName("x").
High("high").
Low("low").
EmptyPointSettings(ViewBag.empty).
DataSource(ViewBag.dataSource).
Add();
}).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Render()
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.
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea).
XName("x").
High("high").
Low("low").
EmptyPointSettings(ViewBag.empty).
DataSource(ViewBag.dataSource).
Marker(ViewBag.marker).
Add();
}).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Render()
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.
@Html.EJS().Chart("container").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.RangeArea).
XName("x").
High("high").
Low("low").
EmptyPointSettings(ViewBag.empty).
DataSource(ViewBag.dataSource).
Marker(ViewBag.marker).
Add();
}).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Render()
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.
@Html.EJS().Chart("container").SeriesRender("changeColor").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea).
XName("x").
High("high").
Low("low").
DataSource(ViewBag.dataSource).
Add();
}).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Render()
<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.
@Html.EJS().Chart("container").PointRender("changeColor").Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.RangeStepArea).
XName("x").
High("high").
Low("low").
DataSource(ViewBag.dataSource).
Marker(ViewBag.marker).
Add();
}).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).Render()
<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;
}