如何解决Highcharts - 隐藏可见总计为 0 的堆叠列的类别
我有一个堆积柱形图,其中 X 轴上的每一列由 4 个系列组成。单击图例隐藏系列时,许多列的总数可能为 0。
我不知道如何隐藏这些列。
显示所有系列 Screenshot of chart
主要系列被隐藏 Largest Series Hidden Resulting in 0's
如您所见,X 轴并未调整大小以仅显示总计非 0 的列。 我尝试了其他人提到的各种事情。
我正在使用的代码是:
Highcharts.chart(containerName,{
chart: {
marginTop : 100,marginBottom : 130,//marginleft : 30,//marginright : 30,spacingTop: 10,borderColor: '#335cad',borderWidth: 4,type: 'column',style: {
fontFamily: 'Arial',fontWeight : 'normal',}
},title: {
text: title
},xAxis: {
categories: nkeys,title: {
text: xtitle,fonts : 'Arial',fontSize : '20px'
},},labels: {
rotation: 300
}
},yAxis: {
style: {
fontFamily: 'Arial',strokewidth:'0px',textShadow: false,min: 0,title: {
text: 'Count'
},stackLabels: {
enabled: true,style: {
//fontWeight: 'normal',fontFamily : 'Arial',textoutline : '0px contrast',color: ( // theme
Highcharts.defaultOptions.title.style &&
Highcharts.defaultOptions.title.style.color
) || 'gray'
}
}
},legend: {
align: 'right',x: -333,verticalAlign: 'top',y: 30,floating: true,backgroundColor:
Highcharts.defaultOptions.legend.backgroundColor || 'white',borderColor: '#CCC',borderWidth: 1,shadow: false,itemStyle: {
fontWeight: 'normal',fontFamily: 'arial'
}
},tooltip: {
headerFormat: '<b>{point.x}</b><br/>',pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
},// Formatting of the Chart
plotOptions: {
column: {
stacking: 'normal',dataLabels: {
formatter: function () {
return this.y > 0 ? '<p style="font-family:Arial;stroke-width:0px">' + this.y + '</p>' : null;
},textshadow : false,enabled: true,textoutline : false
}
}
}
},//Data to be displayed
series: [{
name: 'WO Complete',data: anwnValue,color : '#fc8eac',legendIndex : 1,strokeWidth : "0px",borderColor : '#000000',borderWidth :'0px',fontWeight : 'normal'
}
},{
name: 'Needs Work',data: nwvalue,color : '#FF0000',legendIndex : 0,{
name: 'Abnormal',data: anvalue,color : '#FFBF00',legendIndex : -1,{
name: 'Normal',data: nvalue,color : '#32CD32',legendIndex : -2,}]
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。