嗨,我在Highchart有一些类别,例如:
Categories:["2015-10-31", "2015-11-04", "2015-11-12", "2015-11-03", "2015-11-11", "2015-11-02", "2015-11-01", "2015-11-13"]
它显示在x轴上,但我想更改日期格式,如下所示:
十月31 nov 4 nov 12 nov 3,nov 11像这样的格式
如果有人可以帮助我,我该如何实现,请帮助我无法获得解决方案。
提前致谢
使用格式化程序方法:http : //api.highcharts.com/highcharts#xAxis.labels.formatter
例子:
$(function () {
var months = [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec'
];
$('#container').highcharts({
title: {
text: 'Example'
},
xAxis: {
categories: ["2015-10-31", "2015-11-04", "2015-11-12"],
labels: {
formatter: function () {
var date = new Date(this.value);
return months[date.getMonth()] + ' ' + date.getDate();
}
}
},
series: [{
data: [1, 2, 3]
}]
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px; width: 500px"></div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句