質問

I have the following .js.coffee file

jQuery ->
 Morris.Line
  element: 'averages_chart'
  data: [{month: '2014 01 01', average: 6}, {month: '2014 02 01', average: 5}]
  xkey: 'month'
  ykeys: ['average']
  labels: ['Average']

What is the correct date format to display the months correctly?

None of these seem to work properly

month: '2014 01 01'
month: 2014/01/01
month: '2014/01/01'
month: 'Jan 2014'

Here is a js bin example: http://jsbin.com/uqawig/441/embed?javascript,live

役に立ちましたか?

解決

Quote from the official documentation

Timestamps are accepted in the form of millisecond timestamps (as returned by Date.getTime() or as strings in the following formats:

2012
2012 Q1
2012 W1
2012-02
2012-02-24
2012-02-24 15:00
2012-02-24 15:00:00
2012-02-24 15:00:00.000

Note: when using millisecond timestamps, it's recommended that you check out the dateFormat option. Note 2: date/time strings can optionally contain a T between the date and time parts, and/or a Z suffix, for compatibility with ISO-8601 dates.

Just replace slashes by hyphens, and it should be ok

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top