Axis in ASP.NET Core HeatMap Chart

HeatMap consists of two axes namely, X-axis and Y-axis that displays the row headers and column headers to plot the data points respectively. You can define the type, format, and other customizing options for both axes in the HeatMap.

Types

There are three different axis types available in the HeatMap, which defines the data type of the axis labels. You can define the axis type by using the valueType property in the HeatMap.

Category axis

Category axis type is used to represent the string values in axis labels.

<ejs-heatmap id='container' dataSource="ViewBag.dataSource">
  <e-heatmap-titlesettings text="Sales Revenue per Employee (in 1000 US$)" textStyle="ViewBag.textStyle">
  </e-heatmap-titlesettings>
  <e-heatmap-xaxis vaueType="Category" labels="ViewBag.xLabels">
  </e-heatmap-xaxis>
  <e-heatmap-yaxis vaueType="Category" labels=" ViewBag.yLabels">
  </e-heatmap-yaxis>
</ejs-heatmap>
public ActionResult Category()
{
    ViewBag.textStyle = new
     {
         size= "15px",
         fontWeight= "500",
         fontStyle= "Normal",
         fontFamily= "Segoe UI"
         };
         string[] xlabels = new string[12] { "Nancy", "Andrew", "Janet", "Margaret", "Steven", "Michael", "Robert", "Laura", "Anne", "Paul", "Karin", "Mario" };
         ViewBag.xLabels = xlabels;
         string[] yLabels = new string[6] { "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat" };
         ViewBag.yLabels = yLabels;
         ViewBag.dataSource = GetDataSource();
         return View();
}

 private int[,] GetDataSource()
 {
     int[,] data = new int[,]
            {
                {73, 39, 26, 39, 94, 0},
                {93, 58, 53, 38, 26, 68},
                {99, 28, 22, 4, 66, 90},
                {14, 26, 97, 69, 69, 3},
                {7, 46, 47, 47, 88, 6},
                {41, 55, 73, 23, 3, 79},
                {56, 69, 21, 86, 3, 33},
                {45, 7, 53, 81, 95, 79},
                {60, 77, 74, 68, 88, 51},
                {25, 25, 10, 12, 78, 14},
                {25, 56, 55, 58, 12, 82},
                {74, 33, 88, 23, 86, 59}
            };
            return data;
 }

Numeric axis

Numeric axis type is used to represent the numeric values in axis labels.

<ejs-heatmap id='container' dataSource="ViewBag.dataSource">
  <e-heatmap-titlesettings text="Sales Revenue per Employee (in 1000 US$)" textStyle="ViewBag.textStyle">
  </e-heatmap-titlesettings>
  <e-heatmap-xaxis vaueType="Numeric" minimum="1" maximum="11">
  </e-heatmap-xaxis>
  <e-heatmap-yaxis vaueType="Numeric" minimum="1" maximum="5">
  </e-heatmap-yaxis>
</ejs-heatmap>
public ActionResult Numeric()
{
    ViewBag.textStyle = new
     {
         size= "15px",
         fontWeight= "500",
         fontStyle= "Normal",
         fontFamily= "Segoe UI"
         };
         ViewBag.dataSource = GetDataSource();
         return View();
}

 private int[,] GetDataSource()
 {
     int[,] data = new int[,]
            {
                {73, 39, 26, 39, 94, 0},
                {93, 58, 53, 38, 26, 68},
                {99, 28, 22, 4, 66, 90},
                {14, 26, 97, 69, 69, 3},
                {7, 46, 47, 47, 88, 6},
                {41, 55, 73, 23, 3, 79},
                {56, 69, 21, 86, 3, 33},
                {45, 7, 53, 81, 95, 79},
                {60, 77, 74, 68, 88, 51},
                {25, 25, 10, 12, 78, 14},
                {25, 56, 55, 58, 12, 82},
                {74, 33, 88, 23, 86, 59}
            };
            return data;
 }

Date-time axis

Date-time axis type is used to represent the date-time values in axis labels with a specific format. In date-time axis, you can define the start and end date/time using the minimum and maximum properties.

@{
    var Xminimum = new DateTime(2007, 1, 1);
    var Xmaximum = new DateTime(2017, 1, 1);
}

<ejs-heatmap id='container' dataSource="ViewBag.dataSource">
  <e-heatmap-titlesettings text="Monthly Flight Traffic at JFK Airport" textStyle="ViewBag.textStyle">
  </e-heatmap-titlesettings>
  <e-heatmap-xaxis minimum="Xminimum" maximum="Xmaximum" intervalType="Years" valueType="DateTime" labelFormat="yyyy" labelRotation="45" labelIntersectAction="None"></e-heatmap-xaxis>
  <e-heatmap-yaxis labels="ViewBag.yLabels">
  </e-heatmap-yaxis>
  <e-heatmap-cellsettings border="ViewBag.border" showLabel="false" format="{value} flights">
  </e-heatmap-cellsettings>
  <e-heatmap-legendsettings visible="false"></e-heatmap-legendsettings>
</ejs-heatmap>
public ActionResult DateTime()
{
    ViewBag.textStyle = new
     {
         size= "15px",
         fontWeight= "500",
         fontStyle= "Normal",
         fontFamily= "Segoe UI"
         };
         string[] yLabels = new string[12] { "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug",
         "Sep", "Oct", "Nov", "Dec"};
         ViewBag.yLabels = yLabels;
         ViewBag.border = new { width = 0};
         ViewBag.dataSource = GetDataSource();
         return View();
}

 private int[,] GetDataSource()
 {
     int[,] data = new int[,]
            {
                {36371, 25675, 28292, 33399, 35980, 38585, 39351, 39964, 36543, 30529, 33298, 36985},
                {34702, 27618, 31063, 34525, 36772, 35410, 38750, 39467, 35390, 34196, 35302, 35703},
                {34522, 31324, 32128, 34231, 36817, 34381, 37180, 38255, 32776, 32645, 31539, 32981},
                {32213, 28755, 29517, 31214, 33747, 33507, 35763, 36837, 32910, 33437, 30659, 31965},
                {31282, 28663, 32952, 33941, 34506, 36875, 38836, 35497, 34285, 34094, 32256, 33699},
                {31714, 29405, 33745, 32838, 33461, 35034, 36122, 37943, 34128, 30624, 32398, 33522},
                {32064, 28387, 33751, 32537, 34034, 35977, 37196, 38301, 33627, 34115, 31072, 33939},
                {32417, 27868, 30807, 33386, 35284, 36126, 39753, 40978, 35777, 35277, 31281, 35411},
                {32494, 29848, 34385, 35804, 37943, 38722, 41315, 41335, 37177, 37443, 32457, 37304},
                {34378, 29576, 30547, 35664, 36622, 38145, 40347, 41868, 38252, 36505, 29576, 36450},
                {35219, 31670, 32589, 34927, 36998, 39825, 41126, 42002, 37021, 36583, 32408, 37108}
            };
            return data;
 }

Inversed axis

HeatMap supports inversing the axis origin for both axes, where the axis labels are placed in an inversed manner. You can enable axis inversing by enabling the isInversed property.

@{
    var Xminimum = new DateTime(2007, 1, 1);
    var Xmaximum = new DateTime(2017, 12, 31);
}

<ejs-heatmap id='container' dataSource="ViewBag.dataSource">
  <e-heatmap-titlesettings text="Monthly Flight Traffic at JFK Airport" textStyle=" ViewBag.textStyle">
  </e-heatmap-titlesettings>
 <e-heatmap-xaxis minimum="Xminimum" maximum="Xmaximum" intervalType="Years" valueType="DateTime" labelFormat="yyyyy" labelRotation="45" labelIntersectAction="None" isInversed="true"></e-heatmap-xaxis>
  <e-heatmap-yaxis labels="ViewBag.yLabels">
  </e-heatmap-yaxis>
  <e-heatmap-cellsettings border="ViewBag.border" showLabel="false" format="{value} flights">
  </e-heatmap-cellsettings>