lbo*_*yel 3 javascript highcharts
我试图将我的 x 轴值显示为一个系列的 highcharts 上的字符串,但得到 (0,1,2....) 这是 xaxis 数组索引位置。如何在 higcharts 上显示格式化为字符串的 xaxis 值?
这是我所拥有的
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]
]
}]
});
Run Code Online (Sandbox Code Playgroud)
希望将“Jan-1”、“Jan-2”作为 x 轴上的标签。这是下面的小提琴链接https://jsfiddle.net/dLfv2sbd/2/
删除labels并使用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]
]
}]
});
Run Code Online (Sandbox Code Playgroud)
检查小提琴。
| 归档时间: |
|
| 查看次数: |
2550 次 |
| 最近记录: |