js腳本:
$(function () {
$('#container').highcharts({
chart: {
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) || 'gray'
}
}
},
tooltip: {
formatter: function() {
return ''+
this.series.name +': '+ this.y +' ('+ Math.round(this.percentage) +'%)';
}
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
}
}
},
series: [{
name: 'John',
data: [5, 3, 4, 7, 2]
}, {
name: 'Jane',
data: [2, 2, 3, 2, 1]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}, {
name: 'jack', //下角标為10
data: [8, 4, 4, 2, 5]
},{ name:'不是11啊',
data:[]
}, {
name: 'nancy', //下角标為11
data: [7, 4, 4, 2, 5]
},{ name:'不是13啊', //本該是13的
data:[]
}, {
name: 'kog', //下角标為12
data: [5, 4, 4, 2, 5]
},{},{}]
});
var chart = $('#container').highcharts();
chart.series[10].remove();
chart.series[11].remove();
chart.series[12].remove();
// chart.series[13].remove();
});
HTML頁面資料:
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>測試動态頁面</title>
<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="js/highcharts-4.0.1/js/highcharts.js"></script>
<script type="text/javascript" src="js/highcharts-4.0.1/js/modules/exporting.js"> </script>
<script type="text/javascript" src="js/test01.js"></script>
</head>
<body>
<div id="container" style="height: 450px"></div>
</body>
</html>
最後顯示的圖檔:
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLiIXZ05WZD9CX5RXa2Fmcn9CXwczLcVmds92czlGZvwVP9EUTDZ0aRJkSwk0LcxGbpZ2LcBDM08CXlpXazRnbvZ2LcRlMMVDT2EWNvwFdu9mZvwVPNhUZxxmbhZXUYpVd1kmYr50MZV3YyI2cKJDT29GRjBjUIF2LcRHelR3LcJzLctmch1mclRXY39DO2kzMzMzM1ETMzITM0EDMy8CX0Vmbu4GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.jpg)
可以很容易的看到series超過11個的時候會出現BUG問題,series的API調用錯誤。我用的是HIGHCHARTS4,不知道官方什麼時候能改過來!!
問題解決了:
今天又重新把這個地方過了一遍,發現下角标不能從小往大去取,隻能從大向小去取就沒有上述問題了!