7
我一直在研究Highcharts刚刚陷入了一个麻烦问题是,当没有任何价值的图表上的某些数据存在,然后它显示0它看起来不好,请检查以下jsfiddle图表上的标签会被下列功能填充,但我无法检查它是否应该只显示图表上的值大于零的那些条形图从HIGHCHART删除零
http://jsfiddle.net/CzHyC/3/ [KINDLY检查图表上的APPLE部分]
$(function() {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column'
},
title: {
text: 'Stacked column chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'blue'
}
}
},
legend: {
align: 'right',
x: -100,
verticalAlign: 'top',
y: 20,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'gray',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
formatter: function() {
return '<b>'+ this.x +'</b><br/>'+
this.series.name +': '+ this.y +'<br/>'+
'Total: '+ this.point.stackTotal;
}
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
}
}
},
series: [{
name: 'John',
data: [0, 3, 4, 7, 2]
}, {
name: 'Jane',
data: [2, 2, 3, 2, 1]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}]
});
});
});
不错的技巧,但数据是在我从数据库表被填充,但我可以把支票上 – 2012-07-09 20:06:58
是的,您必须先将数据以特定格式构建,然后才能将其提供给高层图表。 – c0deNinja 2012-07-09 20:08:44
我会将该值设置为null。请记住,-1是一个值,而null不是。 – wergeld 2012-07-09 20:27:07