PrimaryXAxis and IntervalType Hours

Hi,
I would need to represent an entire day on the abscissa axis from 00:00 to 23:59 at 5-minute intervals; Since the data I receive from the database is datetime (day, hour, minute, second) I thought it was enough to write like this:

PrimaryXAxis (px => px.ValueType) (Syncfusion.EJ2.Charts.ValueType.DateTime).IntervalType (Syncfusion.EJ2.Charts.IntervalType.Hours) .EdgeLabelPlacement (Syncfusion .EJ2.Charts.EdgeLabelPlacement.Shift).MajorGridLines (ViewBag.majorGridLines) . .LabelFormat ( "y")

But I do not get what I need as it represents me the year while I need to display only the time and minutes.
Can you help me?
Thanks in advance
Barbara Inzitari

3 Replies

DD Dharanidharan Dharmasivam Syncfusion Team August 6, 2018 06:53 AM UTC

Hi Inzitari, 

Greetings from Syncfusion. 

We would like to let you know that, if you need customized label formats, then you can use the labelFormat property of the axis and from the provided code snippet, you have specified labelFormat as y which specfies the year (2010, 2011, 2012, 2013 …), so the output of your chart has shown the year. But your requirement is to display the time and minutes for the date time values, so you can use the Skeleton property of the axis. The skeleton property is used to process the date time values in the specified format. 

For more information skeleton formats, kindly find the help document. In this help document, you can find the skeleton types under the Additional skeletons section. We have prepared a sample in which we have used the skeleton property to format the axis labels. Kindly find the code snippet below to achieve this requirement and you can change this with respect to your requirement. 
 
ASP.Net Core: 

@Html.EJS().Chart("container").PrimaryXAxis(px => px.ValueType(Syncfusion.EJ2.Charts.ValueType.DateTime) 
.IntervalType(Syncfusion.EJ2.Charts.IntervalType.Hours).Skeleton("hms")).Render() 


Output of the above code will be as follows, 

 

Sample for reference can be find from below link. 
Sample link : Label Format 

Thanks, 
Dharani. 



NI nimue August 6, 2018 04:34 PM UTC

Hi Dharani,
Thanks for the support now I can perfectly represent the hours of the day.
Barbara Inzitari


DD Dharanidharan Dharmasivam Syncfusion Team August 7, 2018 05:59 AM UTC

Hi Inzitari, 
 
Most welcome. Please get in touch with us, if you would require any further assistance. 
  
 
Thanks, 
Dharani. 
 


Loader.
Up arrow icon