目录

  • xAxis自定义时间刻度的显示

xAxis自定义时间刻度

我们先来看下HighCharts图表的xAxis对象有哪些属性(红色标记重要属性):
allowDecimals: Boolean
categories: Array
dateTimeLabelFormats: Object
minTickInterval: Number
offset: Number
showFirstLabel: Boolean
showLastLabel: Boolean
tickColor: Color
title
type: String
//轴线的类型。可选项:"linear","logarithmic","datetime" or "category"
tickInterval: Number
//在轴线上单位刻度的间距
labels
startOnTick: Boolean
endOnTick: Boolean
events
 
详细参考:
 
1)在X轴显示例01-01的时间刻度
$('#container').highcharts({
xAxis: {
type: 'datetime',
labels: {
formatter: function () {
return Highcharts.dateFormat('%m-%d ', this.value);
}
},
startOnTick: true,
endOnTick: true,
},
series: [{
pointStart: Date.UTC(2014, 1, 1), //JS时间戳 1388534400000
data: [29.9, 19.9, 42.9, 20.9]
}]
});

HighCharts学习笔记-LMLPHP

04-14 02:09