这是改变后的js为什么没效果了呢?
$(document).ready(function() {
var title = {
text: '国外航班'
};
var sum=[
///===============MU
{"Flight":"MU","name":"CANPEK","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1706,1290,1150,1010,1080]},
{"Flight":"MU","name":"CANSHA","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1235.78,1172.65,1092.21,1031.31,878.03]},
{"Flight":"MU","name":"PEKCAN","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1150,1195,1130,1305,1060]},
{"Flight":"MU","name":"PEKSHA","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1100.48,1072.88,1063.32,1027.02,807.2]},
{"Flight":"MU","name":"SHACAN","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1193.98,1171.92,1011.94,976.4,946.77]},
{"Flight":"MU","name":"SHAPEK","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1093.05,1091.02,1041.62,945.55,962.54]},
{"Flight":"MU","name":"SHASZX","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1255.15,1226.37,1103.55,1051.84,857.69]},
{"Flight":"MU","name":"SZXSHA","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1213.9,1240.3,1173.22,1092.39,950.37]}
];
for(var i=0;i<sum.length;i++){
var xAxis = {
categories:sum[0].BOOKING_Data
};
var yAxis = {
title: {
text: '票价金额(¥)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
};
var tooltip = {
shared: false,
useHTML: true
};
var legend = {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
};
var series=[];
for(var i=0;i<sum.length;i++){
series.push({name:sum[i].name,data:sum[i].SELL_AMPUNT});
}
$('#select').change(function(){
data=[];
$('.highcharts-line-series').hide()
console.log(data);
//获取被选中的option标签option:selected
var ind = $(this).find('option:selected').index();
<span>alert</span>(ind);
if(ind==0){
$('.highcharts-line-series').show();
drawLineChart ()
}else if(ind>=1){
$('.highcharts-series-'+(ind-1)).show();
data[0]=series[ind-1] ;
console.log(data)
drawLineChart()
}
});
$('#select').change(function(){
data=[];
//console.log(series);
$('.highcharts-line-series').hide()
//获取被选中的option标签option:selected
var ind = $(this).find('option:selected').index();
if(ind==0){
$('.highcharts-line-series').show();
drawLineChart ()
}else if(ind==1){
$('.highcharts-series-0').siblings().hide();
data[0]=series[0] ;
console.log(series[0])
drawLineChart()
}else if(ind==2){
$('.highcharts-series-1').show();
data[0]=series[1] ;
console.log(series[1])
drawLineChart()
}
});
drawLineChart()
function drawLineChart () {
var json = {};
json.tooltip=tooltip;
json.title = title;
json.xAxis = xAxis;
json.yAxis = yAxis;
json.legend = legend;
json.series = series;
$('#container_3').highcharts(json);
}
}
});
$(document).ready(function() { var sum=[ //=============================CZ {"Flight":"CZ","name":"CANPEK","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1836.67,1587.78,760,860,1027.5]}, {"Flight":"CZ","name":"CANSHA","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1247.42,1242.63,1025.33,923.41,880.64]}, {"Flight":"CZ","name":"PEKCAN","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1840.91,1497.5,1860,960,975]}, {"Flight":"CZ","name":"PEKSHA","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[935.6,841,620,896.67,868.33]}, {"Flight":"CZ","name":"SHACAN","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1219.87,1217.42,1076.18,1055.22,840.88]}, {"Flight":"CZ","name":"SHAPEK","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[870,962.5,1044,740,812]}, {"Flight":"CZ","name":"SHASZX","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1280.89,1132.69,1004.47,891.48,869.27]}, {"Flight":"CZ","name":"SZXSHA","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1296.53,1290.88,1149.42,968.07,776]}, {"Flight":"CZ","name":"SZXPEK","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1927.14,1810,1650,1706,1346.50]}, {"Flight":"CZ","name":"PEKSZX","BOOKING_Data":[2,5,7,10,14],"SELL_AMPUNT":[1930,1447.5,1764,1610,1275]}]; for(var i=0;i<sum.length;i++){ var data0={name:sum[0].name,data:sum[0].SELL_AMPUNT}; var data1={name:sum[1].name,data:sum[1].SELL_AMPUNT}; var data2={name:sum[2].name,data:sum[2].SELL_AMPUNT}; var data3={name:sum[3].name,data:sum[3].SELL_AMPUNT}; var data4={name:sum[4].name,data:sum[4].SELL_AMPUNT}; var data5={name:sum[5].name,data:sum[5].SELL_AMPUNT}; var data6={name:sum[6].name,data:sum[6].SELL_AMPUNT}; var data7={name:sum[7].name,data:sum[7].SELL_AMPUNT}; var data8={name:sum[8].name,data:sum[8].SELL_AMPUNT}; var data9={name:sum[9].name,data:sum[9].SELL_AMPUNT}; var series=[data0,data1,data2,data3,data4,data5,data6,data7,data8,data9]; $('#select').change(function(){ series = []; $('.highcharts-line-series').hide() //获取被选中的option标签option:selected var ind = $(this).find('option:selected').index(); switch(ind){ case ind=0: $('.highcharts-line-series').show(); drawCineChart (); break; case ind=1: $('.highcharts-series-0').show(); series[0] = data0; console.log(data0); break; case ind=2: $('.highcharts-series-1').show(); series[0] = data1; drawLineChart() break; case ind=3: $('.highcharts-series-2').show(); series[0] = data2; drawLineChart() break; case ind=4: $('.highcharts-series-3').show(); series[0] = data3; drawLineChart() break; case ind=5: $('.highcharts-series-4').show(); series[0] = data4; drawLineChart() break; case ind=6: $('.highcharts-series-5').show(); series[0] = data5; drawLineChart() break; case ind=7: $('.highcharts-series-6').show(); series[0] = data6; drawLineChart() break; case ind=8: $('.highcharts-series-7').show(); series[0] = data7; drawLineChart() break; case ind=9: $('.highcharts-series-8').show(); series[0] = data8; drawLineChart() break; case ind=10: $('.highcharts-series-9').show(); series[0] = data9; drawLineChart() break; } }); drawLineChart() function drawLineChart () { var json = {}; json.tooltip=tooltip; json.title = title; json.xAxis = xAxis; json.yAxis = yAxis; json.legend = legend; json.series = series; $('#container_2').highcharts(json); } } });
var series = []; for(var i=0;i<sum.length;i++){ series.push({name:sum[i].name,data:sum[i].SELL_AMPUNT}) }
但是他的值怎么取到呢?你这样追加,我的值是通过sum的json获取的值,