Strip Lines in ASP.NET Core Charts
The EJ2 chart supports horizontal and vertical strip lines, as well as customization of the strip line in both orientations.
Horizontal Strip lines
You can create a horizontal strip line by adding a stripline to the vertical axis and setting the visible option to true. Striplines are rendered in the specified start to end range and you can add more than one stripline for an axis.
<ejs-chart id="container" width="60%">
<e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
<e-chart-axes>
<e-chart-axis name="yAxis" valueType="Category">
<e-striplines>
<e-stripline visible="true" start="20" end="30" color="red"></e-stripline>
</e-striplines>
</e-chart-axis>
</e-chart-axes>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" yName="y" yAxisName="yAxis" type="@Syncfusion.EJ2.Charts.ChartSeriesType.Column"></e-series>
</e-series-collection>
</ejs-chart>public ActionResult Index()
{
List<StripLineChartData> chartData = new List<StripLineChartData>
{
new StripLineChartData { x = "Sun", y = 28 },
new StripLineChartData { x = "Mon", y = 27 },
new StripLineChartData { x = "Tue", y = 33 },
new StripLineChartData { x = "Wed", y = 36 },
new StripLineChartData { x = "Thu", y = 28 },
new StripLineChartData { x = "Fri", y = 30 },
new StripLineChartData { x = "Sat", y = 31 }
};
ViewBag.dataSource = chartData;
return View();
}
public class StripLineChartData
{
public string x;
public double y;
}Vertical strip lines
You can create a vertical strip line by adding a stripline to the horizontal axis and setting the visible option to true. Striplines are rendered in the specified start to end range and you can add more than one stripline for an axis.
<ejs-chart id="container" width="60%">
<e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
<e-chart-axes>
<e-chart-axis name="xAxis" valueType="Category">
<e-striplines>
<e-stripline visible="true" start="0" end="3" color="red"></e-stripline>
</e-striplines>
</e-chart-axis>
</e-chart-axes>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" yName="y" xAxisName="xAxis" type="@Syncfusion.EJ2.Charts.ChartSeriesType.Column"></e-series>
</e-series-collection>
</ejs-chart>public ActionResult Index()
{
List<StripLineChartData> chartData = new List<StripLineChartData>
{
new StripLineChartData { x = "Sun", y = 28 },
new StripLineChartData { x = "Mon", y = 27 },
new StripLineChartData { x = "Tue", y = 33 },
new StripLineChartData { x = "Wed", y = 36 },
new StripLineChartData { x = "Thu", y = 28 },
new StripLineChartData { x = "Fri", y = 30 },
new StripLineChartData { x = "Sat", y = 31 }
};
ViewBag.dataSource = chartData;
return View();
}
public class StripLineChartData
{
public string x;
public double y;
}Customize the strip line
The starting value of a specific strip line can be customized by the start property. The ending value is customized by end. Whether the strip line starts from the origin of the axis is controlled by startFromOrigin. The size of the strip line is customized by size. The border of the strip line is customized by border. The order of the strip line (rendered behind or over the series elements) is customized by zIndex.
<ejs-chart id="container" width="60%">
<e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
<e-chart-axes>
<e-chart-axis name="xAxis" valueType="Category">
<e-striplines>
<e-stripline visible="true" startFromAxis="true" size="4" zIndex="Behind" opacity="0.5" color="green"></e-stripline>
</e-striplines>
</e-chart-axis>
</e-chart-axes>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" yName="y" xAxisName="xAxis" type="@Syncfusion.EJ2.Charts.ChartSeriesType.Column"></e-series>
</e-series-collection>
</ejs-chart>public ActionResult Index()
{
List<StripLineChartData> chartData = new List<StripLineChartData>
{
new StripLineChartData { x = "Sun", y = 28 },
new StripLineChartData { x = "Mon", y = 27 },
new StripLineChartData { x = "Tue", y = 33 },
new StripLineChartData { x = "Wed", y = 36 },
new StripLineChartData { x = "Thu", y = 28 },
new StripLineChartData { x = "Fri", y = 30 },
new StripLineChartData { x = "Sat", y = 31 }
};
ViewBag.dataSource = chartData;
return View();
}
public class StripLineChartData
{
public string x;
public double y;
}Customize the stripline text
You can customize the text rendered in a strip line by the textStyle property. The rotation of the strip line text is changed by the rotation property. The horizontal and vertical alignment of the strip line text is changed by horizontalAlignment and verticalAlignment properties.
<ejs-chart id="container" width="60%">
<e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
<e-chart-axes>
<e-chart-axis name="xAxis" valueType="Category">
<e-striplines>
<e-stripline visible="true" startFromAxis="true" size="4" zIndex="Behind" opacity="0.5" color="green"
text="good" verticalAlignment="Middle" horizontalAlignment="Middle" rotation="90"></e-stripline>
</e-striplines>
</e-chart-axis>
</e-chart-axes>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" xName="x" yName="y" xAxisName="xAxis" type="@Syncfusion.EJ2.Charts.ChartSeriesType.Column"></e-series>
</e-series-collection>
</ejs-chart>public ActionResult Index()
{
List<StripLineChartData> chartData = new List<StripLineChartData>
{
new StripLineChartData { x = "Sun", y = 28 },
new StripLineChartData { x = "Mon", y = 27 },
new StripLineChartData { x = "Tue", y = 33 },
new StripLineChartData { x = "Wed", y = 36 },
new StripLineChartData { x = "Thu", y = 28 },
new StripLineChartData { x = "Fri", y = 30 },
new StripLineChartData { x = "Sat", y = 31 }
};
ViewBag.dataSource = chartData;
return View();
}
public class StripLineChartData
{
public string x;
public double y;
}Dash Array
You can create a dash array strip line by using the dashArray property. The strip lines are rendered with the specified dash array values.
<ejs-chart id="container" enableAnimation="true">
<e-chart-primaryxaxis valueType="@Syncfusion.EJ2.Charts.ValueType.Category" interval="1"></e-chart-primaryxaxis>
<e-chart-primaryyaxis interval="10" stripLines="ViewBag.yAxis"></e-chart-primaryyaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" name="Gold" xName="x" yName="y" type="@Syncfusion.EJ2.Charts.ChartSeriesType.Column">
</e-series>
</e-series-collection>
</ejs-chart>public ActionResult Index()
{
List<StripLineChartData> chartData = new List<StripLineChartData>
{
new StripLineChartData { x = "Sun", y = 28 },
new StripLineChartData { x = "Mon", y = 27 },
new StripLineChartData { x = "Tue", y = 33 },
new StripLineChartData { x = "Wed", y = 36 },
new StripLineChartData { x = "Thu", y = 28 },
new StripLineChartData { x = "Fri", y = 30 },
new StripLineChartData { x = "Sat", y = 31 }
};
ViewBag.dataSource = chartData;
return View();
}
public class StripLineChartData
{
public string x;
public double y;
}Recurrence Stripline
Strip lines can be drawn repeatedly at regular intervals, which is useful for marking an event that recurs along the timeline of the chart. The following properties are used to configure this feature.
-
isRepeat- It is used to enable or disable the recurrence strip line. -
repeatEvery- It is used to mention the stripline interval. -
repeatUntil- It specifies the end value at which point strip line has to stop repeating.
<ejs-chart id="container" enableAnimation="true">
<e-chart-primaryxaxis stripLines="ViewBag.yAxis" valueType="@Syncfusion.EJ2.Charts.ValueType.Category" interval="1"></e-chart-primaryxaxis>
<e-chart-primaryyaxis interval="10"></e-chart-primaryyaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" name="Gold" xName="x" yName="y" type="@Syncfusion.EJ2.Charts.ChartSeriesType.Column">
</e-series>
</e-series-collection>
</ejs-chart>public ActionResult Index()
{
List<StripLineChartData> chartData = new List<StripLineChartData>
{
new StripLineChartData { x = 1, y = 28 },
new StripLineChartData { x = 2, y = 27 },
new StripLineChartData { x = 3, y = 33 },
new StripLineChartData { x = 4, y = 36 },
new StripLineChartData { x = 5, y = 28 },
new StripLineChartData { x = 6, y = 30 },
new StripLineChartData { x = 7, y = 31 }
};
List<ChartStripLine> yaxisstriplines = new List<ChartStripLine>();
ChartStripLine stripy = new ChartStripLine();
stripy.Start = 1;
stripy.Size = 1;
stripy.IsRepeat = true;
stripy.RepeatEvery = 2;
stripy.Color = "rgba(167,169,171, 0.3)";
stripy.Visible = true;
yaxisstriplines.Add(stripy);
ViewBag.yAxis = yaxisstriplines;
ViewBag.dataSource = chartData;
return View();
}
public class StripLineChartData
{
public double x;
public double y;
}Size Type
The sizeType property refers to the size of the strip line. They are,
AutoPixelYearsMonthsDaysHoursMinutesSeconds
<ejs-chart id="container" enableAnimation="true">
<e-chart-primaryxaxis stripLines="ViewBag.yAxis" valueType="@Syncfusion.EJ2.Charts.ValueType.DateTime" interval="1" intervalType="@Syncfusion.EJ2.Charts.IntervalType.Years"></e-chart-primaryxaxis>
<e-chart-primaryyaxis interval="10"></e-chart-primaryyaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" name="Gold" xName="xValue" yName="yValue" type="@Syncfusion.EJ2.Charts.ChartSeriesType.Column">
</e-series>
</e-series-collection>
</ejs-chart>public ActionResult Index()
{
List<LineChartData> chartData = new List<LineChartData>
{
new LineChartData { xValue = new DateTime(2005, 01, 01), yValue = 21 },
new LineChartData { xValue = new DateTime(2006, 01, 01), yValue = 24 },
new LineChartData { xValue = new DateTime(2007, 01, 01), yValue = 36 },
new LineChartData { xValue = new DateTime(2008, 01, 01), yValue = 38 },
};
ViewBag.dataSource = chartData;
List<ChartStripLine> yaxisstriplines = new List<ChartStripLine>();
ChartStripLine stripy = new ChartStripLine();
stripy.Start = new DateTime(2005, 01, 01);
stripy.Size = 1;
stripy.SizeType = SizeType.Years;
stripy.Color = "rgba(167,169,171, 0.3)";
stripy.Visible = true;
yaxisstriplines.Add(stripy);
ViewBag.yAxis = yaxisstriplines;
return View();
}
public class LineChartData
{
public System.DateTime xValue;
public double yValue;
}Segment Stripline
You can create a strip line in a particular region with respect to a segment. You can enable the segment stripline using isSegmented property. The start and end value of this type of stripline can be defined using segmentStart and segmentEnd properties.
-
isSegmented- Used to enable the segment stripline. -
segmentStart- Used to change the segment start value. Value correspond to associated axis. -
segmentEnd- Used to change the segment end value. Value correspond to associated axis. -
segmentAxisName- Used to specify the name of the associated axis.
<ejs-chart id="container" enableAnimation="true">
<e-chart-primaryyaxis stripLines="ViewBag.yAxis" interval="10"></e-chart-primaryyaxis>
<e-series-collection>
<e-series dataSource="ViewBag.dataSource" name="Gold" xName="xValue" yName="yValue" type="@Syncfusion.EJ2.Charts.ChartSeriesType.Line">
</e-series>
</e-series-collection>
</ejs-chart>public ActionResult Index()
{
List<LineChartData> chartData = new List<LineChartData>
{
new LineChartData { xValue = 1, yValue = 5 },
new LineChartData { xValue = 2, yValue = 39 },
new LineChartData { xValue = 3, yValue = 21 },
new LineChartData { xValue = 4, yValue = 51 },
new LineChartData { xValue = 5, yValue = 30 },
new LineChartData { xValue = 6, yValue = 26 }
};
List<ChartStripLine> yaxisstriplines = new List<ChartStripLine>();
ChartStripLine stripy = new ChartStripLine();
stripy.Start = 20;
stripy.End = 40;
stripy.IsSegmented = true;
stripy.SegmentStart = 2;
stripy.SegmentEnd = 4;
stripy.Color = "rgba(167,169,171, 0.3)";
stripy.Visible = true;
yaxisstriplines.Add(stripy);
ViewBag.yAxis = yaxisstriplines;
ViewBag.dataSource = chartData;
return View();
}
public class LineChartData
{
public double xValue;
public double yValue;
}