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.

axis-cross.razor
@using Syncfusion.EJ2.Blazor.Charts

<EjsChart Title="Olympic Medals">
        <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Category" CrossesAt="15">
        </ChartPrimaryXAxis>
  
        <ChartPrimaryYAxis CrossesAt="5">
        </ChartPrimaryYAxis>
  
        <ChartSeriesCollection>
            <ChartSeries DataSource="@MedalDetails" XName="X" YName="YValue" Type="ChartSeriesType.Column">
            </ChartSeries>
        </ChartSeriesCollection>
</EjsChart>

@code{
    public class ChartData
    {
        public string X;
        public double YValue;
    }
    public List<ChartData> MedalDetails = new List<ChartData> 
      {
         new ChartData { X= "USA", YValue= 46 },
         new ChartData { X= "GBR", YValue= 27 },
         new ChartData { X= "CHN", YValue= 26 },
         new ChartData { X= "UK", YValue= 26 },
         new ChartData { X= "AUS", YValue= 26 },
         new ChartData { X= "IND", YValue= 26 },
         new ChartData { X= "DEN", YValue= 26 },
         new ChartData { X= "MEX", YValue= 26 },
      };
 }

Axis Crossing

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. Title style can be customized using TitleStyle property of the axis.

title.razor
@using Syncfusion.EJ2.Blazor.Charts

<EjsChart Title="Olympic Medals">
        <ChartPrimaryXAxis Title="Countries" ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Category">
            <ChartTitleStyle Size="16px" Color="red" FontFamily="Segoe UI" FontWeight="bold"></ChartTitleStyle>
        </ChartPrimaryXAxis>
  
        <ChartSeriesCollection>
            <ChartSeries DataSource="@MedalDetails" XName="X" YName="YValue" Type="ChartSeriesType.Column">
            </ChartSeries>
        </ChartSeriesCollection>
</EjsChart>

@code{
    public class ChartData
    {
        public string X;
        public double YValue;
    }
    public List<ChartData> MedalDetails = new List<ChartData> 
      {
         new ChartData { X= "USA", YValue= 46 },
         new ChartData { X= "GBR", YValue= 27 },
         new ChartData { X= "CHN", YValue= 26 },
         new ChartData { X= "UK", YValue= 26 },
         new ChartData { X= "AUS", YValue= 26 },
         new ChartData { X= "IND", YValue= 26 },
         new ChartData { X= "DEN", YValue= 26 },
         new ChartData { X= "MEX", YValue= 26 },
      };
 }

Tick Lines Customization

You can customize the  Width, Color and Size of the minor and major tick lines, using MajorTickLines and MinorTickLines properties in the axis.

tick.razor
@using Syncfusion.EJ2.Blazor.Charts

<EjsChart Title="Sales History of Product X">
        <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Category">
            <ChartAxisMajorTickLines Width="5" Color="blue"></ChartAxisMajorTickLines>
            <ChartAxisMinorTickLines Width="0" Color="red"></ChartAxisMinorTickLines>
        </ChartPrimaryXAxis>
  
        <ChartPrimaryYAxis Title="Profit($)">
            <ChartAxisMajorTickLines Width="5" Color="blue"></ChartAxisMajorTickLines>
            <ChartAxisMinorTickLines Width="0" Color="red"></ChartAxisMinorTickLines>
        </ChartPrimaryYAxis>
  
        <ChartSeriesCollection>
            <ChartSeries DataSource="@SalesData" XName="X" YName="YValue" Type="ChartSeriesType.Column">
            </ChartSeries>
        </ChartSeriesCollection>
</EjsChart>

@code{
    public class ChartData
    {
        public string X;
        public double YValue;
    }
    public List<ChartData> SalesData = new List<ChartData> 
     {
        new ChartData { X= "John", YValue= 10000 },
        new ChartData { X= "Jake", YValue= 12000 },
        new ChartData { X= "Peter", YValue= 18000 },
        new ChartData { X= "James", YValue= 11000 }
    };
}

Tick Lines Customization

Grid Lines Customization

You can customize the Width, Color and DashArray of the minor and major grid lines, using MajorGridLines and MinorGridLines properties in the axis.

gridline.razor
@using Syncfusion.EJ2.Blazor.Charts

<EjsChart Width="60%">
    <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Category">
        <ChartAxisMajorGridLines Width="5" Color="blue"></ChartAxisMajorGridLines>
        <ChartAxisMinorGridLines Width="0" Color="red"></ChartAxisMinorGridLines>
    </ChartPrimaryXAxis>
    
    <ChartSeriesCollection>
        <ChartSeries DataSource="@MedalDetails" XName="X" YName="YValue" Type="ChartSeriesType.Column">
        </ChartSeries>
    </ChartSeriesCollection>
</EjsChart>

@code{
    public class ChartData
    {
        public string X;
        public double YValue;
    }
    public List<ChartData> MedalDetails = new List<ChartData>
    {
        new ChartData { X= "USA", YValue= 46 },
        new ChartData { X= "GBR", YValue= 27 },
        new ChartData { X= "CHN", YValue= 26 },
        new ChartData { X= "UK", YValue= 23 },
        new ChartData { X= "AUS", YValue= 16 },
        new ChartData { X= "IND", YValue= 36 },
        new ChartData { X= "DEN", YValue= 12 },
        new ChartData { X= "MEX", YValue= 20 },
    };
}

Grid Lines Customization

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. See also

multiple.razor
@using Syncfusion.EJ2.Blazor.Charts

<EjsChart Title="Olympic Medals">
        <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Category">
        </ChartPrimaryXAxis>

        <ChartAxes>
            <ChartAxis Name="YAxis"></ChartAxis>
        </ChartAxes>

        <ChartSeriesCollection>
            <ChartSeries DataSource="@WeatherReports" XName="X" YName="Y" Type="ChartSeriesType.Column">
            </ChartSeries>
            <ChartSeries DataSource="@WeatherReports" XName="X" YName="Y1" YAxisName="YAxis" Type="ChartSeriesType.Line">
            </ChartSeries>
        </ChartSeriesCollection>
</EjsChart>

@code{
    public class ChartData
    {
        public string X;
        public double Y;
        public double Y1;
    }
    public List<ChartData> WeatherReports = new List<ChartData> 
	{
        new ChartData { X = "Sun", Y = 35, Y1 = 30 },
        new ChartData { X = "Mon", Y = 40, Y1 = 28 },
        new ChartData { X = "Tue", Y = 80, Y1 = 29 },
        new ChartData { X = "Wed", Y = 70, Y1 = 30 },
        new ChartData { X = "Thu", Y = 65, Y1 = 33 },
        new ChartData { X = "Fri", Y = 55, Y1 = 32 },
        new ChartData { X = "Sat", Y = 50, Y1 = 34 }
    };
}

Multiple Axis

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.

inversed.razor
@using Syncfusion.EJ2.Blazor.Charts

<EjsChart Title="Olympic Medals">
        <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Category"> 
        </ChartPrimaryXAxis> 
        <ChartPrimaryYAxis IsInversed="true"></ChartPrimaryYAxis>
        <ChartSeriesCollection>
            <ChartSeries DataSource="@MedalDetails" XName="X" YName="Y" Type="ChartSeriesType.Column">
            </ChartSeries> 
        </ChartSeriesCollection> 
</EjsChart> 

@code{
    public class ChartData
    {
        public string X;
        public double Y;
    }
    public List<ChartData> MedalDetails = new List<ChartData> 
	{
        new ChartData { X = "Sun", Y = 35 },
        new ChartData { X = "Mon", Y = 40 },
        new ChartData { X = "Tue", Y = 80 },
        new ChartData { X = "Wed", Y = 70 },
        new ChartData { X = "Thu", Y = 65 },
        new ChartData { X = "Fri", Y = 55 },
        new ChartData { X = "Sat", Y = 50 }
    };
}

Inversed Axis

Opposed Position

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

opposed.razor
@using Syncfusion.EJ2.Blazor.Charts

<EjsChart Title="Olympic Medals"> 
        <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Category"> 
        </ChartPrimaryXAxis> 
  
        <ChartPrimaryYAxis OpposedPosition="true"></ChartPrimaryYAxis> 
  
        <ChartSeriesCollection> 
            <ChartSeries DataSource="@MedalDetails" XName="X" YName="Y" Type="ChartSeriesType.Column"> 
            </ChartSeries> 
        </ChartSeriesCollection> 
</EjsChart>

@code{
    public class ChartData
    {
        public string X;
        public double Y;
    }
    public List<ChartData> MedalDetails = new List<ChartData> 
	{
        new ChartData { X = "Sun", Y = 35 },
        new ChartData { X = "Mon", Y = 40 },
        new ChartData { X = "Tue", Y = 80 },
        new ChartData { X = "Wed", Y = 70 },
        new ChartData { X = "Thu", Y = 65 },
        new ChartData { X = "Fri", Y = 55 },
        new ChartData { X = "Sat", Y = 50 }
    };
}

Opposed Position

See Also