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
You can use datalabels formatter and add condition which check if value is bigger than zero.
http://jsfiddle.net/DdvGm/
plotOptions: {
series: {
dataLabels:{
enabled:true,
formatter:function(){
if(this.y > 0)
return this.y;
}
}
}
},
http://api.highcharts.com/highcharts#plotOptions.column.dataLabels.formatter
Here is the answer, by how short your question is i am not full sue if the existing answers are correct.
In highcharts 0 is considered a number so it will render it on charts. But null is hidden. So when you are adding data, you have to check if the value is 0 and if it is, then change it to null.
Let me know if you have questions.
Fiddle: http://jsfiddle.net/8kr0tods/ See that may is a 0 and mar is null, and null is hidden.
if($VAL==0)
{
$VAL='null';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With