我正在使用AM Charts,我需要在类别字段上显示SUN,MON,TUE等日名,但我无法做到。我能够显示日期数字,但没有名字。请帮助。
提前致谢!!!!
答案 0 :(得分:1)
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);
它用于日期名称的简短版本数组,用于格式化日期
(但仅当categoryAxis.parseDates设置为true时才有效)
答案 1 :(得分:0)
您需要在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"
} ]
}