我正在使用柱形图并在每个条形图上显示这些值.如果它们是0,我不想显示值.怎么做?这是我的一段代码
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
};
Run Code Online (Sandbox Code Playgroud)
jlb*_*ggs 31
您可以使用格式化程序.这样的事情应该这样做:
dataLabels: {
formatter:function() {
if(this.y != 0) {
return this.y;
}
}
}
Run Code Online (Sandbox Code Playgroud)
http://api.highcharts.com/highcharts#plotOptions.series.dataLabels.formatter
Seb*_*han 13
您可以使用datalabels formatter并添加条件,检查值是否大于零.
plotOptions: {
series: {
dataLabels:{
enabled:true,
formatter:function(){
if(this.y > 0)
return this.y;
}
}
}
},
Run Code Online (Sandbox Code Playgroud)
http://api.highcharts.com/highcharts#plotOptions.column.dataLabels.formatter
这是答案,你的问题有多短,如果现有的答案是正确的,我不是完整的.
在highcharts中,0被认为是一个数字,因此它将在图表上呈现.但是隐藏了null.因此,当您添加数据时,您必须检查值是否为0,如果是,则将其更改为null.
如果您有疑问,请告诉我.
小提琴:http://jsfiddle.net/8kr0tods/看到它可能是0而mar是null,并且隐藏了null.
if($VAL==0)
{
$VAL='null';
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
30157 次 |
| 最近记录: |