从您的代码看来,您的月份是 inthead而不是tbody. 所以你应该真正使用$('thead th')选择器。我还建议使用:parent选择器过滤掉空ths
$('thead th:parent', table).each( function(i) {
var month=$(this).text();
options.xAxis.categories.push(month);
});
此外,如果您希望 x 轴为月份,您的系列数据需要更改,您现在应该只有 3 个系列,而不是之前的 6 个。每个系列现在将有 6 个点(每个月一个)而不是前 3 点/系列。所以你的表格解析需要改变成这样的东西。
options.series = [];
$('tbody tr', table).each(function (i) {
var tr = this;
var serie = {};
serie.name = $('th', tr).text();
serie.data = [];
$('td', tr).each(function (j) {
serie.data.push(parseFloat(this.innerHTML));
});
options.series.push(serie);
});
演示@jsFiddle