var legendsectorAirline = {}; var legendsectorAlliance = {}; legendsectorAlliance['OneWorld'] = 473; legendsectorAlliance['Star Alliance'] = 11; legendsectorAlliance['SkyTeam'] = 2; legendsectorAlliance['No Alliance'] = 63; legendsectorAirline['EasyJet'] = 2; legendsectorAirline['British Airways'] = 427; legendsectorAirline['WestJet'] = 1; legendsectorAirline['Ryanair'] = 8; legendsectorAirline['Air Southwest (of UK)'] = 3; legendsectorAirline['Jet2'] = 12; legendsectorAirline['Thomas Cook (MT)'] = 2; legendsectorAirline['EasyJet'] = 9; legendsectorAirline['Virgin America'] = 1; legendsectorAirline['America West'] = 4; legendsectorAirline['FlyBe'] = 18; legendsectorAirline['Virgin Atlantic'] = 2; legendsectorAirline['American Airlines'] = 15; legendsectorAirline['BMI British Midland'] = 4; legendsectorAirline['Iberia'] = 4; legendsectorAirline['United Airlines'] = 1; legendsectorAirline['Qantas'] = 1; legendsectorAirline['Cathay Pacific'] = 1; legendsectorAirline['US Airways'] = 4; legendsectorAirline['Japan Airlines'] = 3; legendsectorAirline['Qatar Airways'] = 14; legendsectorAirline['Unknown'] = 1; legendsectorAirline['Kuwait Airways'] = 2; legendsectorAirline['Jet Airways'] = 2; legendsectorAirline['Aer Lingus'] = 2; legendsectorAirline['Cathay Dragon'] = 1; legendsectorAirline['Malaysia Airlines'] = 3; legendsectorAirline['Turkish Airlines'] = 2; legendsectorAirline['OneWorld'] = 473; legendsectorAirline['Star Alliance'] = 11; legendsectorAirline['SkyTeam'] = 2; legendsectorAirline['No Alliance'] = 63; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['OneWorld','Star Alliance','SkyTeam','No Alliance'], name = 'Carriers', data = [{ y: 86.2, color: colors[0], drilldown: { name: 'OneWorld (473)', categories: ['British Airways','American Airlines','Qatar Airways','Others'], data: [77.8,2.7,2.6,3], color: colors[0] } } ,{ y: 2, color: colors[1], drilldown: { name: 'Star Alliance (11)', categories: ['Others'], data: [2], color: colors[1] } } ,{ y: 0.4, color: colors[2], drilldown: { name: 'SkyTeam (2)', categories: ['Others'], data: [0.4], color: colors[2] } } ,{ y: 11.5, color: colors[3], drilldown: { name: 'No Alliance (63)', categories: ['Ryanair','Jet2','EasyJet','FlyBe','Others'], data: [1.5,2.2,1.6,3.3,3.1], 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 ""; } }