Javascript 从所选行表绘制海图的问题
请看一下这段代码,让我知道为什么我没有将数据加载到highcharts系列数据中,例如:Javascript 从所选行表绘制海图的问题,javascript,jquery,highcharts,Javascript,Jquery,Highcharts,请看一下这段代码,让我知道为什么我没有将数据加载到highcharts系列数据中,例如:checkedRows[0][2]in data: [checkedRows[0][2], 19000, 60000, 35000, 17000, 10000], 以下是我的js代码: $(function () { $('#btn').on('click', function() { var checkCounter = 0; var checkedRows = [];
checkedRows[0][2]
in
data: [checkedRows[0][2], 19000, 60000, 35000, 17000, 10000],
以下是我的js代码:
$(function () {
$('#btn').on('click', function() {
var checkCounter = 0;
var checkedRows = [];
$(':checkbox:checked').closest('tr').each(function() {
checkedRows.push(
$(this).find('td:gt(0)').map(function() {
return $(this).html();
}).get()
);
});
$('#container').highcharts({
chart: {
polar: true,
type: 'line'
},
title: {
text: 'Budget vs spending',
x: -80
},
pane: {
size: '80%'
},
xAxis: {
categories: ['Sales', 'Marketing', 'Development', 'Customer Support',
'Information Technology', 'Administration'],
tickmarkPlacement: 'on',
lineWidth: 0
},
yAxis: {
gridLineInterpolation: 'polygon',
lineWidth: 0,
min: 0
},
tooltip: {
shared: true,
pointFormat: '<span style="color:{series.color}">{series.name}: <b>${point.y:,.0f}</b><br/>'
},
legend: {
align: 'right',
verticalAlign: 'top',
y: 70,
layout: 'vertical'
},
series: [{
name: 'Allocated Budget',
data: [checkedRows[0][2], 19000, 60000, 35000, 17000, 10000],
pointPlacement: 'on'
}, {
name: 'Actual Spending',
data: [checkedRows[1][2], 39000, 42000, 31000, 26000, 14000],
pointPlacement: 'on'
}]
});
});
谢谢问题在于数组包含表格元素的文本值,而不是数值。您可以这样转换:
parseInt(checkedRows[0][1])
parseInt(checkedRows[0][1])