我在我的网站上显示了此图表图表。如何设置X轴的间隔?例如,我希望显示拳头值,然后跳过第二个并显示第三个。能做到吗?或者,您是否始终只是要以阵列形式显示要传递给轴的所有数据?
我的代码:(时间戳是一个包含我的时间的JS数组。我可以以时间格式获取该时间。act和temps是用于沿y轴绘制数据的数组)
$(function () {
$('#tempactgraph').highcharts({
chart: {
zoomType: 'xy'
},
title: {
text: 'Temperature & Activity Monitoring '
},
subtitle: {
text: 'Source: Cowlar Sensors'
},
xAxis: [{
categories: timestamp,
crosshair: true
}],
yAxis: [{ // Primary yAxis
labels: {
format: '{value}°C',
style: {
color: Highcharts.getOptions().colors[1]
}
},
title: {
text: 'Temperature',
style: {
color: Highcharts.getOptions().colors[1]
}
}
}, { // Secondary yAxis
title: {
text: 'Activity',
style: {
color: Highcharts.getOptions().colors[0]
}
},
labels: {
format: '{value} xx',
style: {
color: Highcharts.getOptions().colors[0]
}
},
opposite: true
}],
tooltip: {
shared: true
},
legend: {
layout: 'vertical',
align: 'left',
x: 120,
verticalAlign: 'top',
y: 100,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
},
series: [{
name: 'Activities',
type: 'spline',
connectNulls: 1,
yAxis: 1,
data: act,
tooltip: {
valueSuffix: ' xx'
}
}, {
name: 'Temperature',
type: 'spline',
connectNulls: 1,
data: temps,
tooltip: {
valueSuffix: '°C'
}
}]
});
});
您需要tickInterval:2
像这样在x轴偏移中添加a
xAxis: [{
categories: timestamp,
crosshair: true,
tickInterval: 2
}],
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句