我有以下高亮度输出:
我只想在x轴标签上看到2月10日而不是2月10日18:00。因此,所有xaxis标签都将像2月10日,2月12日,依此类推。但工具提示将与输出屏幕相同。如何格式化xaxis以便我将获得2月10日,2月12日等,而不是2月10日18:00,2月12日20:00,依此类推。
$(function () {
$('#container').highcharts({
chart: {
zoomType: 'xy',
spacingRight: 20
},
credits: {
enabled: false
},
title: {
text: ''
},
xAxis: {
type: 'datetime',
labels: {
overflow: 'justify'
},
startOnTick: true,
showFirstLabel: true,
endOnTick: true,
showLastLabel: true,
categories: dateAndTimeArray,
tickInterval: 10,
labels: {
rotation: 0.1,
align: 'left',
step: 10,
enabled: true
},
style: {
fontSize: '8px'
}
},
yAxis: {
title: {
text: 'Measurement value'
}
},
tooltip: {
xDateFormat: '%Y-%m-%d %H:%M',
shared: true
},
legend: {
enabled: false
},
plotOptions: {
area: {
fillColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0, Highcharts.getOptions().colors[0]],
[1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
]
},
lineWidth: 1,
marker: {
enabled: false
},
shadow: false,
states: {
hover: {
lineWidth: 1
}
},
// threshold: null
}
},
series: [{
type: 'line',
name: 'Value',
data: chartData,
marker: {
enabled: false
}
}]
});
});
答案 0 :(得分:23)
酷,试试这个:
将此格式化程序添加到xAxis
labels
对象:
xAxis {
...
labels: {
...
formatter: function() {
return this.value.toString().substring(0, 6);
},
}
}