[英]Custom bar chart text with Highcharts
我正在創建堆積的Highcharts條形圖。 在每個欄中,我想要自定義文本。 但是,highcharts僅顯示數據編號。
小提琴在這里 。
我的代碼是:
$(function () {
$('#container').highcharts({
chart: {
type: 'bar'
},
title: {
text: 'Stacked bar chart'
},
xAxis: {
categories: ['Apples', 'Oranges']
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
}
},
legend: {
reversed: true
},
plotOptions: {
series: {
stacking: 'normal'
},
bar: {
dataLabels: {
enabled: true
}
}
},
series: [{
name: 'John',
data: [['test 1', 5], ['test 2', 3]]
}, {
name: 'Jane',
data: [['test 3', 2], ['test 4', 2]]
}]
});
});
我想在條形圖中顯示“ test 1”,“ test 2”等(它們確實顯示在彈出窗口上)。 但是,數據編號(即5、3、2和2)出現在此處。 能做到嗎?
使用格式化程序功能:
bar: {
dataLabels: {
formatter: function(){
return this.point.name
},
enabled: true
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.