在 AM 图表上显示日期名称而不是日期编号

Show day name on AM Chart instead of day number

我正在处理 AM 图表,我需要在类别字段上显示日期名称,如 SUN、MON、TUE,但我无法做到。我能够显示天数但没有名字。请帮忙。

提前致谢!!!

AmCharts.formatDate(new Date(2016,4,21), "EEE, DD MMM YYYY");

上午图表

Day of the month:
D = 7 (one or two digits)
DD = 07 (always two digits)  
Day of week:
E = 2 (single digit day of week)  
EE = 02 (two-digit day of week)  
EEE = Tue (3-letter abbreviation of the literal representation of the day of week)   
EEEE = Tuesday (full day of week name)

更多信息https://www.amcharts.com/tutorials/formatting-dates/

如果是图表

AmCharts.formatDate([new Date(2016,4,21)],shortDayNames);

它用于日期名称的短版本数组,在格式化日期时使用

(But it works only if categoryAxis.parseDates is set to true)

为此,您需要在 categoryAxis 上使用 dateFormats。如果您有每日数据,您可能只需要覆盖 "DD":

的格式
"categoryAxis": {
  // ...
  "dateFormats": [ {
    "period": "fff",
    "format": "JJ:NN:SS"
  }, {
    "period": "ss",
    "format": "JJ:NN:SS"
  }, {
    "period": "mm",
    "format": "JJ:NN"
  }, {
    "period": "hh",
    "format": "JJ:NN"
  }, {
    // overriding date format for daily data
    "period": "DD",
    "format": "EEE"
  }, {
    "period": "WW",
    "format": "MMM DD"
  }, {
    "period": "MM",
    "format": "MMM"
  }, {
    "period": "YYYY",
    "format": "YYYY"
  } ]
}