Highchart在X轴上显示字符串 [英] Highchart show string on x-axis
本文介绍了Highchart在X轴上显示字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将我的x轴值显示为一系列图表的字符串,但是获取(0,1,2 ....),这是x轴数组索引位置.如何在Higcharts上显示格式化为字符串的xaxis值?
I am trying to show my x-axis values as a string on highcharts for a series but instead get (0,1,2....) which is the xaxis array index position. How do I show the xaxis value formatted as a string on higcharts?
这就是我所拥有的
Highcharts.chart('container', {
title: {
text: 'Chart with time'
},
xAxis: {
type: 'datetime',
"labels": {
"formatter": function() {
console.log(this);
console.log(this.value.toString());
return this.value
}
},
},
series: [{
data: [
['Jan-1', 100],
['Jan-2', 120],
['Jan-3', 130]
]
}]
});
想在x轴上看到"Jan-1","Jan-2"作为标签.以下是 https://jsfiddle.net/dLfv2sbd/2/
Would like to see 'Jan-1', 'Jan-2' as the labels on the x-axis. Here is a link to the fiddle below https://jsfiddle.net/dLfv2sbd/2/
推荐答案
删除标签
并使用 type:'category'
代替 type:'datetime'
:
Highcharts.chart('container', {
title: {
text: 'Chart with time'
},
xAxis: {
type: 'category',
},
series: [{
data: [
['Jan-1', 100],
['Jan-2', 120],
['Jan-3', 130]
]
}]
});
检查小提琴.
这篇关于Highchart在X轴上显示字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文