var legendsectorAirline = {}; var legendsectorAlliance = {}; legendsectorAlliance['OneWorld'] = 137; legendsectorAlliance['Star Alliance'] = 5; legendsectorAlliance['SkyTeam'] = 49; legendsectorAlliance['No Alliance'] = 85; legendsectorAirline['FlyBe'] = 18; legendsectorAirline['British Airways'] = 128; legendsectorAirline['Virgin Atlantic'] = 37; legendsectorAirline['Easyjet'] = 7; legendsectorAirline['Ryanair'] = 11; legendsectorAirline['Wizz Air'] = 2; legendsectorAirline['BMI British Midland'] = 2; legendsectorAirline['Citywing'] = 1; legendsectorAirline['Eastern Airways'] = 2; legendsectorAirline['KLM Royal Dutch Airlines'] = 2; legendsectorAirline['IcelandAir'] = 6; legendsectorAirline['Aer Lingus'] = 7; legendsectorAirline['Norwegian Air Shuttle'] = 3; legendsectorAirline['SAS'] = 1; legendsectorAirline['Delta'] = 10; legendsectorAirline['Cityjet'] = 2; legendsectorAirline['Qantas'] = 4; legendsectorAirline['Loganair (LC)'] = 11; legendsectorAirline['Norwegian Air International'] = 2; legendsectorAirline['American Airlines'] = 4; legendsectorAirline['EasyJet'] = 2; legendsectorAirline['Air 2000'] = 2; legendsectorAirline['Excel Airways'] = 2; legendsectorAirline['JMC Airlines'] = 2; legendsectorAirline['TAP Portugal'] = 2; legendsectorAirline['Bmi Regional'] = 2; legendsectorAirline['Alaska Airlines'] = 1; legendsectorAirline['Loganair'] = 1; legendsectorAirline['EasyJet'] = 2; legendsectorAirline['OneWorld'] = 137; legendsectorAirline['Star Alliance'] = 5; legendsectorAirline['SkyTeam'] = 49; legendsectorAirline['No Alliance'] = 85; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['OneWorld','Star Alliance','SkyTeam','No Alliance'], name = 'Carriers', data = [{ y: 49.6, color: colors[0], drilldown: { name: 'OneWorld (137)', categories: ['British Airways','Qantas','American Airlines','Others'], data: [46.4,1.4,1.4,0.4], color: colors[0] } } ,{ y: 1.8, color: colors[1], drilldown: { name: 'Star Alliance (5)', categories: ['Others'], data: [1.8], color: colors[1] } } ,{ y: 17.8, color: colors[2], drilldown: { name: 'SkyTeam (49)', categories: ['Virgin Atlantic','Delta','Others'], data: [13.4,3.6,0.7], color: colors[2] } } ,{ y: 30.8, color: colors[3], drilldown: { name: 'No Alliance (85)', categories: ['FlyBe','Easyjet','Ryanair','IcelandAir','Aer Lingus','Norwegian Air Shuttle','Loganair (LC)','Others'], data: [6.5,2.5,4,2.2,2.5,1.1,4,7.8], color: colors[3] } } ]; // Build the data arrays var allianceData = []; var carrierData = []; for (var i = 0; i < data.length; i++) { // add browser data allianceData.push({ name: categories[i], y: data[i].y, color: data[i].color }); // add version data for (var j = 0; j < data[i].drilldown.data.length; j++) { var brightness = 0.2 - (j / data[i].drilldown.data.length) / 5 ; carrierData.push({ name: data[i].drilldown.categories[j], y: data[i].drilldown.data[j], color: Highcharts.Color(data[i].color).brighten(brightness).get() }); } } // Create the chart chart = new Highcharts.Chart({ chart: { renderTo: 'airline_sector', type: 'pie' }, title: { text: '' }, yAxis: { title: { text: '' } }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: true }, showInLegend: false } }, tooltip: { valueSuffix: '%' }, series: [{ name: 'proportion', data: allianceData, size: '80%', dataLabels: { formatter: function() { return this.y > 5 ? this.point.name : null; }, color: 'white', distance: -75 } }, { name: 'proportion', data: carrierData, innerSize: '80%', dataLabels: { formatter: function() { // display only if larger than 1 return this.y > 1 ? ''+ this.point.name +': '+ this.y + '%' + getCountsector(this.point.name) : null; } } }] }); }); }); function getCountsector(airline) { if(legendsectorAirline[airline]) { return " (" + parseInt(legendsectorAirline[airline]).toLocaleString() + ")"; } else { return ""; } }