Strip lines

28 Feb 202224 minutes to read

EJ2 chart supports horizontal and vertical strip lines and customization of stripline in both orientation.

Horizontal Strip lines

You can create Horizontal stripline by adding the Stripline in the vertical axis and set 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.

@Html.EJS().Chart("container").Series(series =>
   {
   series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).
   Marker(ViewBag.Marker).
   XName("x").
   YName("yValue").
   DataSource(ViewBag.dataSource).
   Name("Gold").
   Width(2).Add();
   }).
   PrimaryXAxis(px => px.Interval(1).ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).
   StripLines(ViewBag.yAxisStripLine ).
   Title("Olympic Medal Counts - RIO").Render()
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 Striplines

You can create vertical stripline by adding the Stripline in the horizontal axis and set 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.

@Html.EJS().Chart("container").Series(series =>
   {
   series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).
   Marker(ViewBag.Marker).
   XName("x").
   YName("yValue").
   DataSource(ViewBag.dataSource).
   Name("Gold").
   Width(2).Add();
   }).
   PrimaryXAxis(px => px.Interval(1).ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).
   StripLines(ViewBag.xAxisStripLine).
   Title("Olympic Medal Counts - RIO").Render()
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

Starting value in specific strip line can be customized by Start property in strip line. Similarly, ending value is customized by End. It can be also set for starting from the corresponding origin of the axis by StartFromOrigin. Size of the strip line is customized by Size. Border for the stripline is customized by Border. Order of the strip line such that whether it should be rendered in behind or over the series elements is customized by ZIndex.

@Html.EJS().Chart("container").Series(series =>
   {
   series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).
   Marker(ViewBag.Marker).
   XName("x").
   YName("yValue").
   DataSource(ViewBag.dataSource).
   Name("Gold").
   Width(2).Add();
   }).
   PrimaryXAxis(px => px.Interval(1).ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).
   StripLines(ViewBag.xAxisStripLine).
   Title("Olympic Medal Counts - RIO").Render()
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 stripline by TextStyle property. Rotation of the strip line text can be changed by Rotation property. Horizontal and Vertical alignment of stripline text can be changed by HorizontalAlignment and VerticalAlignment property.

@Html.EJS().Chart("container").Series(series =>
   {
   series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).
   Marker(ViewBag.Marker).
   XName("x").
   YName("yValue").
   DataSource(ViewBag.dataSource).
   Name("Gold").
   Width(2).Add();
   }).
   PrimaryXAxis(px => px.Interval(1).ValueType(Syncfusion.EJ2.Charts.ValueType.Category)).
   StripLines(ViewBag.xAxisStripLine).
   Title("Olympic Medal Counts - RIO").Render()
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 dash array stripline by using DashArray property. The Striplines are rendered with specified dash array values.

@(Html.EJS().Chart("container").EnableAnimation(true).Series(series =>
{
    series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).
        XName("x").
        YName("y").
        DataSource(ViewBag.dataSource).
        Name("Gold").
        Width(2).Add();
}).
                   PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category).Interval(1)).
                   PrimaryYAxis(py => py.Interval(10).StripLines(sl => { sl.Visible(true).Start(30).Size(2).SizeType(Syncfusion.EJ2.Charts.SizeType.Pixel).DashArray("10,5").Color("red").Add(); }))
   .Render()
)
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

The strip lines to be drawn repeatedly at the regular intervals – this will be useful when you want to mark an event that occurs recursively along the timeline of the chart. Following properties are used to configure this feature.

  • IsRepeat - It is used for enable / disable the recurrence strip line.
  • RepeatEvery - It is used for mention the stripline interval.
  • RepeatUntil - It specifies the end value at which point strip line has to stop repeating.
@(Html.EJS().Chart("container").Series(series =>
{
    series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).
        XName("x").
        YName("y").
        DataSource(ViewBag.dataSource).
        Name("Gold").
        Width(2).Add();
}).
                   PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category).Interval(1).StripLines(sl => { sl.Visible(true).IsRepeat(true).RepeatEvery(2).Start(1).Color("rgba(167,169,171, 0.3)").Size(1).Add(); })).
                   PrimaryYAxis(py => py.Interval(10))
   .Render()
)
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 the size of the stripline. They are,

  • Auto
  • Pixel
  • Years
  • Months
  • Days
  • Hours
  • Minutes
  • Seconds
@(Html.EJS().Chart("container").Series(series =>
{
    series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).
        XName("xValue").
        YName("yValue").
        DataSource(ViewBag.dataSource).
        Name("Gold").
        Width(2).Add();
}).
     PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.DateTime).IntervalType(Syncfusion.EJ2.Charts.IntervalType.Years).StripLines(sl => { sl.Visible(true).Start(new System.DateTime(2005, 01, 01)).Size(1).SizeType(Syncfusion.EJ2.Charts.SizeType.Years).Color("rgba(167,169,171, 0.3)").Add(); })).
     PrimaryYAxis(py => py.Interval(10))
   .Render()
)
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 stripline in a particular region with respect to 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 - It is used for 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.
@(Html.EJS().Chart("container").Series(series =>
{
    series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line).
        XName("xValue").
        YName("yValue").
        DataSource(ViewBag.dataSource).
        Name("Gold").
        Width(2).Add();
}).
     PrimaryYAxis(py => py.Interval(10).StripLines(sl => { sl.Visible(true).Start(20).End(40).IsSegmented(true).SegmentStart(2).SegmentEnd(4).Color("rgba(167,169,171, 0.3)").Add(); }))
   .Render()
)
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;
        }