2016-04-21 74 views

回答

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" 
    } ] 
} 
+0

这是一个完美的答案。非常感谢 :) –

0
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仅适用)

+0

它不工作,您能告诉我一个工作示例吗? –

相关问题