如何在柱状图中隐藏零值 [英] How to hide zero values in Column chart
本文介绍了如何在柱状图中隐藏零值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用柱形图并在每个栏的顶部显示这些值。我不想显示这些值是否为0.如何做到这一点?这是我的一段代码
I am using column chart and displaying those value on top of each bar. I don't want to show the values if they are 0. How to do that? Here is my piece of code
var series = { data: [],
dataLabels: {
enabled: true,
color: 'black',
align: 'right',
x: -3,
y: 3,
style: {
color: '#333',
fontWeight: 'bold',
fontSize: '12px',
fontFamily: 'Trebuchet MS, Verdana, sans-serif'
}
},
pointWidth: 28
};
推荐答案
您可以使用格式化程序。像这样的东西应该这样做:
You can use the formatter. Something like this should do it:
dataLabels: {
formatter:function() {
if(this.y != 0) {
return this.y;
}
}
}
http://api.highcharts.com/highcharts#plotOptions.series.dataLabels.formatter
这篇关于如何在柱状图中隐藏零值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文