View Full Version : How to properly display a Unix timestamp in chart axis

29 Sep 2014, 10:11 AM
Here is my simple chart definition of the x axis:

axes: [
type: 'Time',
position: 'bottom',
fields: ['time'],
title: 'Time',
dateFormat: 'H:i'
} ]

If my input data 'time' in this case, is a unix timestamps, i.e., long intergers, how would I be able to format the X axis time display. The above code gives me all 00:00 time marks.

The dateFormat obviously is to instruct the display format, but how do I tell Extjs my input format is a Unix timestamp.

I know there are lots of examples on charts, but they are all using the same set of sample data which are already in time format like '2014-09-25 12:22:00'. But my input time format is simply an integer. How would I tell ExtJs to convert it?

1 Oct 2014, 10:12 PM
When you define the fields for your model / store you'll set the name to 'time' and the type to 'date' and use the dateFormat config:

The dateFormat syntax will follow the table at the top of the Ext.Date class's API description:

That will do the parsing of your server-provided date to one that is consumable in the client.

2 Oct 2014, 11:09 AM
Thanks! I figured out the solution, and it is same as you stated.