Logarithmic axis in ASP.NET MVC 3D Chart Component

9 Jan 202412 minutes to read

Logarithmic axis uses logarithmic scale and it is very useful in visualizing data, when it has numerical values in both lower order of magnitude (eg: 10-6) and higher order of magnitude (eg: 106).

@(Html.EJS().Chart3D("container").WallColor("transparent").EnableRotation(true).Rotation(7).Tilt(10).Depth(100)
   .Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).  
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Add();
   })
   .PrimaryXAxis(px => 
      px.ValueType(Syncfusion.EJ2.Charts.ValueType.DateTime)
   )
   .PrimaryYAxis(py => 
      py.ValueType(Syncfusion.EJ2.Charts.ValueType.Logarithmic)
   )
   .Render())
public ActionResult Index()
{
    List<ChartData> chartData = new List<ChartData>
    {
        new ChartData { x= new DateTime(1995, 01, 01), y= 80 },
        new ChartData { x= new DateTime(1996, 01, 01), y= 200 },
        new ChartData { x= new DateTime(1997, 01, 01), y= 400 },
        new ChartData { x= new DateTime(1998, 01, 01), y= 600 },
        new ChartData { x= new DateTime(1999, 01, 01), y= 700 },
        new ChartData { x= new DateTime(2000, 01, 01), y= 1400 },
        new ChartData { x= new DateTime(2001, 01, 01), y= 2000 },
        new ChartData { x= new DateTime(2002, 01, 01), y= 4000 },
        new ChartData { x= new DateTime(2003, 01, 01), y= 6000 },
        new ChartData { x= new DateTime(2004, 01, 01), y= 8000 },
        new ChartData { x= new DateTime(2005, 01, 01), y= 11000 }
    };
    ViewBag.dataSource = chartData;
    return View();
}
public class ChartData
{
    public DateTime x;
    public double y;
}

Range

The range of an axis will be calculated automatically based on the provided data and it can also be customized by using the Minimum, Maximum and Interval properties of the axis.

@(Html.EJS().Chart3D("container").WallColor("transparent").EnableRotation(true).Rotation(7).Tilt(10).Depth(100)
   .Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).  
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Add();
   })
   .PrimaryXAxis(px => 
      px.ValueType(Syncfusion.EJ2.Charts.ValueType.DateTime)
   )
   .PrimaryYAxis(py => 
      py.ValueType(Syncfusion.EJ2.Charts.ValueType.Logarithmic).Minimum(100).Maximum(10000).Interval(1000)
   )
   .Render())
public ActionResult Index()
{
    List<ChartData> chartData = new List<ChartData>
    {
        new ChartData { x= new DateTime(1995, 01, 01), y= 80 },
        new ChartData { x= new DateTime(1996, 01, 01), y= 200 },
        new ChartData { x= new DateTime(1997, 01, 01), y= 400 },
        new ChartData { x= new DateTime(1998, 01, 01), y= 600 },
        new ChartData { x= new DateTime(1999, 01, 01), y= 700 },
        new ChartData { x= new DateTime(2000, 01, 01), y= 1400 },
        new ChartData { x= new DateTime(2001, 01, 01), y= 2000 },
        new ChartData { x= new DateTime(2002, 01, 01), y= 4000 },
        new ChartData { x= new DateTime(2003, 01, 01), y= 6000 },
        new ChartData { x= new DateTime(2004, 01, 01), y= 8000 },
        new ChartData { x= new DateTime(2005, 01, 01), y= 11000 }
    };
    ViewBag.dataSource = chartData;
    return View();
}
public class ChartData
{
    public DateTime x;
    public double y;
}

Logarithmic base

Logarithmic base can be customized by using the LogBase property of the axis. For example when the LogBase is 5, the axis values follows 5-2, 5-1, 50, 51, 52 etc.

@(Html.EJS().Chart3D("container").WallColor("transparent").EnableRotation(true).Rotation(7).Tilt(10).Depth(100)
   .Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).  
      XName("x").
      YName("y").
      ColumnSpacing(0.1).
      DataSource(ViewBag.dataSource).
      Add();
   })
   .PrimaryXAxis(px => 
      px.ValueType(Syncfusion.EJ2.Charts.ValueType.DateTime)
   )
   .PrimaryYAxis(py => 
      py.ValueType(Syncfusion.EJ2.Charts.ValueType.Logarithmic).LogBase(2)
   )
   .Render())
public ActionResult Index()
{
    List<ChartData> chartData = new List<ChartData>
    {
        new ChartData { x= new DateTime(1995, 01, 01), y= 80 },
        new ChartData { x= new DateTime(1996, 01, 01), y= 200 },
        new ChartData { x= new DateTime(1997, 01, 01), y= 400 },
        new ChartData { x= new DateTime(1998, 01, 01), y= 600 },
        new ChartData { x= new DateTime(1999, 01, 01), y= 700 },
        new ChartData { x= new DateTime(2000, 01, 01), y= 1400 },
        new ChartData { x= new DateTime(2001, 01, 01), y= 2000 },
        new ChartData { x= new DateTime(2002, 01, 01), y= 4000 },
        new ChartData { x= new DateTime(2003, 01, 01), y= 6000 },
        new ChartData { x= new DateTime(2004, 01, 01), y= 8000 },
        new ChartData { x= new DateTime(2005, 01, 01), y= 11000 }
    };
    ViewBag.dataSource = chartData;
    return View();
}
public class ChartData
{
    public DateTime x;
    public double y;
}

Logarithmic interval

The interval of the logarithmic axis can be customized by using the Interval property in the axis. When the logarithmic base is 10 and logarithmic Interval is 2, then the axis labels are placed at an interval of 102. The default value of the Interval is 1.

@(Html.EJS().Chart3D("container").WallColor("transparent").EnableRotation(true).Rotation(7).Tilt(10).Depth(100)
   .Series(series =>
   {
      series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).  
      XName("x").
      YName("y").
      DataSource(ViewBag.dataSource).
      Add();
   })
   .PrimaryXAxis(px => 
      px.ValueType(Syncfusion.EJ2.Charts.ValueType.DateTime)
   )
   .PrimaryYAxis(py => 
      py.ValueType(Syncfusion.EJ2.Charts.ValueType.Logarithmic).Interval(2)
   )
   .Render())
public ActionResult Index()
{
    List<ChartData> chartData = new List<ChartData>
    {
        new ChartData { x= new DateTime(1995, 01, 01), y= 80 },
        new ChartData { x= new DateTime(1996, 01, 01), y= 200 },
        new ChartData { x= new DateTime(1997, 01, 01), y= 400 },
        new ChartData { x= new DateTime(1998, 01, 01), y= 600 },
        new ChartData { x= new DateTime(1999, 01, 01), y= 700 },
        new ChartData { x= new DateTime(2000, 01, 01), y= 1400 },
        new ChartData { x= new DateTime(2001, 01, 01), y= 2000 },
        new ChartData { x= new DateTime(2002, 01, 01), y= 4000 },
        new ChartData { x= new DateTime(2003, 01, 01), y= 6000 },
        new ChartData { x= new DateTime(2004, 01, 01), y= 8000 },
        new ChartData { x= new DateTime(2005, 01, 01), y= 11000 }
    };
    ViewBag.dataSource = chartData;
    return View();
}
public class ChartData
{
    public DateTime x;
    public double y;
}