使用Highcharts在x轴上显示自定义值
我已经编写了以下代码来显示图表。我没有提到x轴和y轴标签。这些是自动生成的。 我想在x轴的刻度开始处显示“低”,在刻度结束处显示“高”,而不是满刻度使用Highcharts在x轴上显示自定义值,highcharts,Highcharts,我已经编写了以下代码来显示图表。我没有提到x轴和y轴标签。这些是自动生成的。 我想在x轴的刻度开始处显示“低”,在刻度结束处显示“高”,而不是满刻度 $('#container').highcharts({ yAxis: { title: { text: 'Temperature' }, id: 'my_y', lineWidth: 2, lineColor: '#F33',
$('#container').highcharts({
yAxis: {
title: {
text: 'Temperature'
},
id: 'my_y',
lineWidth: 2,
lineColor: '#F33',
min:0,
max:100
},
series: [{
name: 'Temperature',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6],
color: '#F33'
}]
});
像这样
它有点“黑客”,我相信有更好的方法做它,但它的工作
xAxis: {
tickAmount: 2,
labels: {
formatter: function () {
if (typeof(this.axis.ticks[this.value]) != "undefined"){
if(this.axis.ticks[this.value].isFirst) {
return 'low'
}
else if (this.axis.ticks[this.value].isLast){
return 'high'
}
}
}
}
}
像这样
它有点“黑客”,我相信有更好的方法做它,但它的工作
xAxis: {
tickAmount: 2,
labels: {
formatter: function () {
if (typeof(this.axis.ticks[this.value]) != "undefined"){
if(this.axis.ticks[this.value].isFirst) {
return 'low'
}
else if (this.axis.ticks[this.value].isLast){
return 'high'
}
}
}
}
}
你想在xaxis中显示什么,缩放值low和high你想用low和high替换0-10值吗?是的,我想在x轴的起点显示'low',在x轴的终点显示'high',而不是0到10的数字。你想在xaxis中显示什么,缩放值低和高是否要将0-10的值替换为低和高?是的,我想在x轴的起点显示“低”,在x轴的终点显示“高”,而不是0到10的数字。