We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Label Created

Hi Symcfusion,
I am using DateTimeAxis and the event LableCreated
and I wants the DateTime of the point and to change the label how
can I get the DateTime from ChartAxis.LabelCreatedEventArgs
Thanks, Roi 

1 Reply

MK Muneesh Kumar G Syncfusion Team September 8, 2017 10:21 AM UTC

Hi Roi Godelman, 
  
Thanks for using Syncfusion products. 
 
Solution 1:  
  
We can get the DateTime of label by using Position property in AxisLabel and we can change the label by using LabelContent property as per the below code snippet.   
 
Code Snippet [C#] 
  
  
privatevoid PrimaryAxis_LabelCreated(object sender, ChartAxis.LabelCreatedEventArgs e) 
{ 
  
       DateTime dt = DateTime.FromOADate(e.AxisLabel.Position); 
  
       if (dt.Hour < 12) 
          e.AxisLabel.LabelContent = e.AxisLabel.LabelContent + " AM"; 
       else 
          e.AxisLabel.LabelContent = e.AxisLabel.LabelContent + " PM"; 
  
} 
  
 
  
Solution 2 :  
  
We can change the DateTimeAxis label by setting LabelFormat in DateTimeAxis as per the below code snippet. 
  
Code Snippet [C#] 
  
  
DateTimeAxis dateTimeAxis = newDateTimeAxis(); 
dateTimeAxis.LabelStyle.LabelFormat = "yyyy/MMM"; 
chart.PrimaryAxis = dateTimeAxis; 
  
 
  
We have prepared a sample based on this and you can find the sample under the following location:  
Sample: http://www.syncfusion.com/downloads/support/forum/132540/ze/Sample1457582701 
Please let us know if you have any queries. 
Regards, 
Muneesh Kumar G. 



Loader.
Live Chat Icon For mobile
Up arrow icon