Search results

Numeric Axis

You can use numeric axis to represent numeric values of data in chart. By default, the ValueType of an axis is Double.

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

<EjsChart Width="60%">
        <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Double">
        </ChartPrimaryXAxis> 
		
        <ChartSeriesCollection>
            <ChartSeries DataSource="@Data" XName="XValue" YName="YValue" Type="ChartSeriesType.Line">
            </ChartSeries>                                                                     
        </ChartSeriesCollection>
</EjsChart>    

@code{
     public class ChartData
        {
            public double XValue;
            public double YValue;
        }
      public List<ChartData> Data =  new List<ChartData>
	  {
            new ChartData { XValue = 10, YValue = 21 },
            new ChartData { XValue = 20, YValue = 24 },
            new ChartData { XValue = 30, YValue = 36 },
            new ChartData { XValue = 40, YValue = 38 },
            new ChartData { XValue = 50, YValue = 54 },
            new ChartData { XValue = 60, YValue = 57 },
            new ChartData { XValue = 70, YValue = 70 },
        };
}

Numeric Axis

Range and Interval

Range for an axis, will be calculated automatically based on the provided data, you can also customize the range of the axis using Minimum, Maximum and Interval property of the axis.

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

<EjsChart Width="60%">  
     <ChartPrimaryXAxis Minimum="5" Maximum="50" Interval="2" ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Double">
     </ChartPrimaryXAxis>   
		
     <ChartSeriesCollection>
        <ChartSeries DataSource="@Data" XName="XValue" YName="YValue" Type="ChartSeriesType.Line">
        </ChartSeries>                                                                     
     </ChartSeriesCollection>
</EjsChart>

@code{
     public class ChartData
        {
            public double XValue;
            public double YValue;
        }
      public List<ChartData> Data =  new List<ChartData>
	  {
            new ChartData { XValue = 10, YValue = 21 },
            new ChartData { XValue = 20, YValue = 24 },
            new ChartData { XValue = 30, YValue = 36 },
            new ChartData { XValue = 40, YValue = 38 },
            new ChartData { XValue = 50, YValue = 54 },
            new ChartData { XValue = 60, YValue = 57 },
            new ChartData { XValue = 70, YValue = 70 },
        };
}

Range

Range Padding

Padding can be applied to the minimum and maximum extremes of the axis range by using the RangePadding property. Numeric axis supports following types of padding.

  • None
  • Round
  • Additional
  • Normal
  • Auto

Numeric - None

When the RangePadding is set to None, minimum and maximum of an axis is based on the data.

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

<EjsChart Width="60%"> 
    <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Double">
    </ChartPrimaryXAxis>

    <ChartPrimaryYAxis RangePadding="ChartRangePadding.None">
    </ChartPrimaryYAxis>  
    
    <ChartSeriesCollection>
        <ChartSeries DataSource="@Data" XName="XValue" YName="YValue" Type="ChartSeriesType.Line">
        </ChartSeries>                                                                     
    </ChartSeriesCollection>
</EjsChart>

@code{
     public class ChartData
        {
            public double XValue;
            public double YValue;
        }
      public List<ChartData> Data =  new List<ChartData>
	  {
            new ChartData { XValue = 10, YValue = 21 },
            new ChartData { XValue = 20, YValue = 24 },
            new ChartData { XValue = 30, YValue = 36 },
            new ChartData { XValue = 40, YValue = 38 },
            new ChartData { XValue = 50, YValue = 54 },
            new ChartData { XValue = 60, YValue = 57 },
            new ChartData { XValue = 70, YValue = 70 },
        };
}

Numeric - Round

When the RangePadding is set to Round, minimum and maximum will be rounded to the nearest possible value divisible by interval. For example, when the minimum is 3.5 and the interval is 1, then the minimum will be rounded to 3.

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

<EjsChart Width="60%">  
        <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Double">
        </ChartPrimaryXAxis>

        <ChartPrimaryYAxis RangePadding="ChartRangePadding.Round">
        </ChartPrimaryYAxis>   
		
        <ChartSeriesCollection>
            <ChartSeries DataSource="@Data" XName="XValue" YName="YValue" Type="ChartSeriesType.Line">
            </ChartSeries>                                                                     
        </ChartSeriesCollection>
</EjsChart>

@code{
     public class ChartData
        {
            public double XValue;
            public double YValue;
        }
      public List<ChartData> Data =  new List<ChartData>
	  {
            new ChartData { XValue = 10, YValue = 21 },
            new ChartData { XValue = 20, YValue = 24 },
            new ChartData { XValue = 30, YValue = 36 },
            new ChartData { XValue = 40, YValue = 38 },
            new ChartData { XValue = 50, YValue = 54 },
            new ChartData { XValue = 60, YValue = 57 },
            new ChartData { XValue = 70, YValue = 70 },
        };
}

Numeric - Additional

When the RangePadding is set to Additional, interval of an axis will be padded to the minimum and maximum of the axis.

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

<EjsChart Width="60%">    
		<ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Double">
		</ChartPrimaryXAxis>

		 <ChartPrimaryYAxis RangePadding="ChartRangePadding.Additional">
		</ChartPrimaryYAxis>    

		<ChartSeriesCollection>
			<ChartSeries DataSource="@Data" XName="XValue" YName="YValue" Type="ChartSeriesType.Line">
			</ChartSeries>                                                                     
		</ChartSeriesCollection>
</EjsChart>

@code{
     public class ChartData
        {
            public double XValue;
            public double YValue;
        }
      public List<ChartData> Data =  new List<ChartData>
	  {
            new ChartData { XValue = 10, YValue = 21 },
            new ChartData { XValue = 20, YValue = 24 },
            new ChartData { XValue = 30, YValue = 36 },
            new ChartData { XValue = 40, YValue = 38 },
            new ChartData { XValue = 50, YValue = 54 },
            new ChartData { XValue = 60, YValue = 57 },
            new ChartData { XValue = 70, YValue = 70 },
        };
}

Numeric - Normal

When the RangePadding is set to Normal, padding is applied to the axis based on default range calculation.

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

<EjsChart Width="60%">  
        <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Double">
        </ChartPrimaryXAxis>

        <ChartPrimaryYAxis RangePadding="ChartRangePadding.Normal">
        </ChartPrimaryYAxis>   
		
        <ChartSeriesCollection>
            <ChartSeries DataSource="@Data" XName="XValue" YName="YValue" Type="ChartSeriesType.Line">
            </ChartSeries>                                                                     
        </ChartSeriesCollection>
</EjsChart>

@code{
     public class ChartData
        {
            public double XValue;
            public double YValue;
        }
      public List<ChartData> Data =  new List<ChartData>
	  {
            new ChartData { XValue = 10, YValue = 21 },
            new ChartData { XValue = 20, YValue = 24 },
            new ChartData { XValue = 30, YValue = 36 },
            new ChartData { XValue = 40, YValue = 38 },
            new ChartData { XValue = 50, YValue = 54 },
            new ChartData { XValue = 60, YValue = 57 },
            new ChartData { XValue = 70, YValue = 70 },
        };
}

Numeric - Auto

When the RangePadding is set to Auto,horizontal numeric axis takes None as padding calculation, while the vertical numeric axis takes Normal as padding calculation.

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

<EjsChart Width="60%">
        <ChartPrimaryXAxis RangePadding="ChartRangePadding.Auto" ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Double">
        </ChartPrimaryXAxis>

         <ChartPrimaryYAxis RangePadding="ChartRangePadding.Auto" ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Double">
        </ChartPrimaryYAxis>    
		
        <ChartSeriesCollection>
            <ChartSeries DataSource="@Data" XName="XValue" YName="YValue" Type="ChartSeriesType.Line">
            </ChartSeries>                                                                     
        </ChartSeriesCollection>
 </EjsChart>

 @code{
     public class ChartData
        {
            public double XValue;
            public double YValue;
        }
      public List<ChartData> Data =  new List<ChartData>
	  {
            new ChartData { XValue = 10, YValue = 21 },
            new ChartData { XValue = 20, YValue = 24 },
            new ChartData { XValue = 30, YValue = 36 },
            new ChartData { XValue = 40, YValue = 38 },
            new ChartData { XValue = 50, YValue = 54 },
            new ChartData { XValue = 60, YValue = 57 },
            new ChartData { XValue = 70, YValue = 70 },
        };
}

Label Format

Numeric Label Format

Numeric labels can be formatted by using the LabelFormat property. Numeric labels supports all globalize format.

label-format.razor
@using Syncfusion.EJ2.Blazor.Charts

<EjsChart Width="60%">  
    <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Double">
    </ChartPrimaryXAxis>

    <ChartPrimaryYAxis LabelFormat="c">
    </ChartPrimaryYAxis>  

    <ChartSeriesCollection>
        <ChartSeries DataSource="@Data" XName="XValue" YName="YValue" Type="ChartSeriesType.Line">
        </ChartSeries>                                                                     
    </ChartSeriesCollection>
</EjsChart>

@code{
     public class ChartData
        {
            public double XValue;
            public double YValue;
        }
      public List<ChartData> Data =  new List<ChartData>
	  {
            new ChartData { XValue = 10, YValue = 21 },
            new ChartData { XValue = 20, YValue = 24 },
            new ChartData { XValue = 30, YValue = 36 },
            new ChartData { XValue = 40, YValue = 38 },
            new ChartData { XValue = 50, YValue = 54 },
            new ChartData { XValue = 60, YValue = 57 },
            new ChartData { XValue = 70, YValue = 70 },
        };
}

The following table describes the result of applying some commonly used label formats on numeric values.

Label Value Label Format property value Result Description
1000 n1 1000.0 The Number is rounded to 1 decimal place
1000 n2 1000.00 The Number is rounded to 2 decimal place
1000 n3 1000.000 The Number is rounded to 3 decimal place
0.01 p1 1.0% The Number is converted to percentage with 1 decimal place
0.01 p2 1.00% The Number is converted to percentage with 2 decimal place
0.01 p3 1.000% The Number is converted to percentage with 3 decimal place
1000 c1 $1000.0 The Currency symbol is appended to number and number is rounded to 1 decimal place
1000 c2 $1000.00 The Currency symbol is appended to number and number is rounded to 2 decimal place

Grouping Separator

To separate groups of thousands, use UseGroupingSeparator property in chart.

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

<EjsChart Title="Sales Comparison" UseGroupingSeparator="true">   
        <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Double">
        </ChartPrimaryXAxis>

        <ChartPrimaryYAxis LabelFormat="c">
        </ChartPrimaryYAxis>  
		
        <ChartSeriesCollection>
            <ChartSeries DataSource="@Data" XName="X" YName="Y" Type="ChartSeriesType.Column">
            </ChartSeries>                                                                                
        </ChartSeriesCollection>
</EjsChart>

@code{
        public class ChartData
        {
            public double X;
            public double Y;
        }
        public List<ChartData> Data =  new List<ChartData> 
		{
          new ChartData{ X= 10, Y=7000 },
          new ChartData{ X= 20, Y= 1000 },
          new ChartData{ X= 30, Y= 12000 },
          new ChartData{ X= 40, Y= 14000 },
          new ChartData{ X= 50, Y= 11000 }, 
          new ChartData{ X= 60, Y= 5000 },
          new ChartData{ X= 70, Y= 7300 },
          new ChartData{ X= 80, Y= 9000 },
          new ChartData{ X= 90, Y= 12000 },
          new ChartData{ X= 100, Y= 14000 }, 
          new ChartData{ X= 110, Y= 11000 },
          new ChartData{ X= 120, Y= 5000 }
        };
}

GroupingSeparator

Custom Label Format

Axis also supports custom label format using placeholder like {value}°C, in which the value represent the axis label e.g 20°C.

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

<EjsChart Width="60%">
    <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.Double">
    </ChartPrimaryXAxis>

    <ChartPrimaryYAxis LabelFormat="${value}K">
    </ChartPrimaryYAxis>  

    <ChartSeriesCollection>
        <ChartSeries DataSource="@Data" XName="XValue" YName="YValue" Type="ChartSeriesType.Line">
        </ChartSeries>                                                                                
    </ChartSeriesCollection>
</EjsChart>

@code{
     public class ChartData
        {
            public double XValue;
            public double YValue;
        }
      public List<ChartData> Data =  new List<ChartData>
	  {
            new ChartData { XValue = 10, YValue = 21 },
            new ChartData { XValue = 20, YValue = 24 },
            new ChartData { XValue = 30, YValue = 36 },
            new ChartData { XValue = 40, YValue = 38 },
            new ChartData { XValue = 50, YValue = 54 },
            new ChartData { XValue = 60, YValue = 57 },
            new ChartData { XValue = 70, YValue = 70 },
        };
}

See Also