Search results

Axis Customization

Axis Crossing

An axis can be positioned in the chart area using crossesAt and crossesInAxis properties. The crossesAt property specifies the values (datetime, numeric, or logarithmic) at which the axis line has to be intersected with the vertical axis or vice-versa, and the crossesInAxis property specifies the axis name with which the axis line has to be crossed.

razor
axis-cross.cs
@using Syncfusion.EJ2;
@section ControlsSection{
@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). crossesAt(15)).
   PrimaryXAxis(px => px.Interval(1).ValueType(Syncfusion.EJ2.Charts.ValueType.Category). crossesAt(5)).
   Title("Olympic Medal Counts - RIO").Render()
}
public IActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData { x= "USA", yValue= 46 },
                new ColumnChartData { x= "GBR", yValue= 27 },
                new ColumnChartData { x= "CHN", yValue= 26 },
                new ColumnChartData { x= "UK", yValue= 26 },
                new ColumnChartData { x= "AUS", yValue= 26 },
                new ColumnChartData { x= "IND", yValue= 26 },
                new ColumnChartData { x= "DEN", yValue= 26 },
                new ColumnChartData { x= "MEX", yValue= 26 },
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class ColumnChartData
        {
            public string x;
            public double yValue;
        }

Title

You can add a title to the axis using title property to provide quick information to the user about the data plotted in the axis.

razor
title.cs
@using Syncfusion.EJ2;
@section ControlsSection{
@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).TitleStyle(ViewBag.titleStyle)).
   Title("Olympic Medal Counts - RIO").Render()
}
public IActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData { x= "USA", yValue= 46 },
                new ColumnChartData { x= "GBR", yValue= 27 },
                new ColumnChartData { x= "CHN", yValue= 26 },
                new ColumnChartData { x= "UK", yValue= 26 },
                new ColumnChartData { x= "AUS", yValue= 26 },
                new ColumnChartData { x= "IND", yValue= 26 },
                new ColumnChartData { x= "DEN", yValue= 26 },
                new ColumnChartData { x= "MEX", yValue= 26 },
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class ColumnChartData
        {
            public string x;
            public double yValue;
        }

Tick Lines Customization

You can customize the  widthcolor and size of the minor and major tick lines, using majorTickLines and minorTickLines properties in the axis.

razor
tick.cs
@using Syncfusion.EJ2;
@section ControlsSection{
@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).MajorTickLines(ViewBag.majorTickLines)
   .MinorTickLines(ViewBag.minorTickLines)).
   PrimaryyAxis(px => px.MajorTickLines(ViewBag.majorTickLines)
   .MinorTickLines(ViewBag.minorTickLines)).
   Title("Olympic Medal Counts - RIO").Render()
}
public IActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData { x= "USA", yValue= 46 },
                new ColumnChartData { x= "GBR", yValue= 27 },
                new ColumnChartData { x= "CHN", yValue= 26 },
                new ColumnChartData { x= "UK", yValue= 26 },
                new ColumnChartData { x= "AUS", yValue= 26 },
                new ColumnChartData { x= "IND", yValue= 26 },
                new ColumnChartData { x= "DEN", yValue= 26 },
                new ColumnChartData { x= "MEX", yValue= 26 },
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class ColumnChartData
        {
            public string x;
            public double yValue;
        }

Grid Lines Customization

You can customize the widthcolor and dashArray of the minor and major grid lines, using majorGridLines and minorGridLines properties in the axis.

razor
grid.cs
@using Syncfusion.EJ2;
@section ControlsSection{
@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).MajorGridLines(ViewBag.majorGridLines)
   .MinorGridLines(ViewBag.minorGridLines)).
   PrimaryyAxis(px => px.MajorTickLines(ViewBag.majorTickLines)
   .MinorTickLines(ViewBag.minorTickLines)).
   Title("Olympic Medal Counts - RIO").Render()
}
public IActionResult Index()
        {
            List<ColumnChartData> chartData = new List<ColumnChartData>
            {
                new ColumnChartData { x= "USA", yValue= 46 },
                new ColumnChartData { x= "GBR", yValue= 27 },
                new ColumnChartData { x= "CHN", yValue= 26 },
                new ColumnChartData { x= "UK", yValue= 26 },
                new ColumnChartData { x= "AUS", yValue= 26 },
                new ColumnChartData { x= "IND", yValue= 26 },
                new ColumnChartData { x= "DEN", yValue= 26 },
                new ColumnChartData { x= "MEX", yValue= 26 },
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class ColumnChartData
        {
            public string x;
            public double yValue;
        }

Multiple Axis

In addition to primary X and Y axis, we can add n number of axis to the chart. Series can be associated with this axis, by mapping with axis’s unique name.

razor
multiple.cs
@using Syncfusion.EJ2;
@section ControlsSection{
 @Html.EJS().Chart("container").Series(series =>
   {
       series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Column).XName("x").YName("y").DataSource(ViewBag.dataSource).Name("Germany").Add();
       series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line).YAxisName("yAxis").XName("x").Marker(ViewBag.marker).YName("y1").DataSource(ViewBag.dataSource).Name("Japan").Add();

   }).PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
.Interval(1).LabelIntersectAction(Syncfusion.EJ2.Charts.LabelIntersectAction.Rotate90)
       ).Axes(ax =>
       {
           ax.OpposedPosition(true).RowIndex(0).Minimum(24).Maximum(36).Interval(2).Name("yAxis").LabelFormat("{value}°C").Add();
       }
       )
).Title("Weather Condition JPN vs DEU").ChartArea(area => area.Border(ViewBag.ChartBorder)).Tooltip(tt => tt.Enable(true)).LegendSettings(lg=>lg.Visible(false)).Render()
}
public ActionResult Index()
        {
            List<MultipleAxesChartData> chartData = new List<MultipleAxesChartData>
            {
                new MultipleAxesChartData { x = "Sun", y = 35, y1 = 30 },
                new MultipleAxesChartData { x = "Mon", y = 40, y1 = 28 },
                new MultipleAxesChartData { x = "Tue", y = 80, y1 = 29 },
                new MultipleAxesChartData { x = "Wed", y = 70, y1 = 30 },
                new MultipleAxesChartData { x = "Thu", y = 65, y1 = 33 },
                new MultipleAxesChartData { x = "Fri", y = 55, y1 = 32 },
                new MultipleAxesChartData { x = "Sat", y = 50, y1 = 34 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class MultipleAxesChartData
        {
            public string x;
            public double y;
            public double y1;
        }

Inversed Axis

When an axis is inversed, highest value of the axis comes closer to origin and vice versa. To place an axis in inversed manner set this property isInversed to true.

razor
inversed.cs
@using Syncfusion.EJ2;
@section ControlsSection{
@Html.EJS().Chart("container").Series(series =>
   {
   series.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Line).
   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).IsInversed(true)).
   Title("Olympic Medal Counts - RIO").Render()
}
public ActionResult Index()
        {
            List<MultipleAxesChartData> chartData = new List<MultipleAxesChartData>
            {
                new MultipleAxesChartData { x = "Sun", y = 35, y1 = 30 },
                new MultipleAxesChartData { x = "Mon", y = 40, y1 = 28 },
                new MultipleAxesChartData { x = "Tue", y = 80, y1 = 29 },
                new MultipleAxesChartData { x = "Wed", y = 70, y1 = 30 },
                new MultipleAxesChartData { x = "Thu", y = 65, y1 = 33 },
                new MultipleAxesChartData { x = "Fri", y = 55, y1 = 32 },
                new MultipleAxesChartData { x = "Sat", y = 50, y1 = 34 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class MultipleAxesChartData
        {
            public string x;
            public double y;
            public double y1;
        }

Opposed Position

To place an axis opposite from its original position, set opposedPosition property of the axis to true.

razor
opposed.cs
@using Syncfusion.EJ2;
@section ControlsSection{
@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).OpposedPosition(true)).
   Title("Olympic Medal Counts - RIO").Render()
}
public ActionResult Index()
        {
            List<MultipleAxesChartData> chartData = new List<MultipleAxesChartData>
            {
                new MultipleAxesChartData { x = "Sun", y = 35, y1 = 30 },
                new MultipleAxesChartData { x = "Mon", y = 40, y1 = 28 },
                new MultipleAxesChartData { x = "Tue", y = 80, y1 = 29 },
                new MultipleAxesChartData { x = "Wed", y = 70, y1 = 30 },
                new MultipleAxesChartData { x = "Thu", y = 65, y1 = 33 },
                new MultipleAxesChartData { x = "Fri", y = 55, y1 = 32 },
                new MultipleAxesChartData { x = "Sat", y = 50, y1 = 34 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class MultipleAxesChartData
        {
            public string x;
            public double y;
            public double y1;
        }