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

Chart: get millisonds from JS Date with Datetime Axis in axisLabelRender event

Hello,
I'm configuring a Chart with a DateTime Axis by giving a JS Date in the datasource and I tried to configure the LabelFormat to get milliseconds from this Date but the value I get in the xisLabelRender event is without ms.
I tried:
HH:mm:ss.sss
HH:mm:ss.SSS
HH:mm:ss.fff
HH:mm:ss.FFF
could you tell me please what should I use to get milliseconds ?
thank you
Christophe

1 Reply

KC Kalaimathi Chellaiah Syncfusion Team February 20, 2019 01:42 PM UTC

Hi Christophe, 
 
Greetings from Syncfusion. 
 
We have analyzed your query. Currently, we don’t have support for milliseconds label format. In work around using axisLabelRender event, you can customize axis label. We have achieved this using the DateTimeCategory axis, but this is behave like category axis. Please find below sample and code snippet. 
 
Code Snippet: 
 
 
axis = (args: IAxisLabelRenderEventArgs) => { 
    if(args.axis.orientation === 'Horizontal') {   
       for(var i=0; i< args.axis.series.length; i++) 
       { 
         for(var j=0; j<args.axis.series[i].points.length; j++){ 
           if(args.axis.series[i].points[j].xValue === args.value){ 
               args.text = args.text + ':' + (new Date(+args.axis.series[i].points[j].x).getMilliseconds()).toString(); 
           }          
         } 
       } 
       } 
  } 
 
 Here we have shown the customized label format(hours:minutes:seconds:milliseconds), 
Screenshot: 
 
 
 
 
Hope this helps. 

Regards, 
Kalai. 

 


Loader.
Live Chat Icon For mobile
Up arrow icon