var legendsectorAirline = {}; var legendsectorAlliance = {}; legendsectorAlliance['OneWorld'] = 30; legendsectorAlliance['Star Alliance'] = 100; legendsectorAlliance['SkyTeam'] = 16; legendsectorAlliance['No Alliance'] = 90; legendsectorAirline['Monarch'] = 12; legendsectorAirline['Singapore Airlines'] = 15; legendsectorAirline['Swiss'] = 22; legendsectorAirline['KLM Royal Dutch Airlines'] = 9; legendsectorAirline['Thomas Cook (MT)'] = 4; legendsectorAirline['South African Airways'] = 25; legendsectorAirline['Air Mauritius'] = 2; legendsectorAirline['Thai'] = 12; legendsectorAirline['Lufthansa'] = 19; legendsectorAirline['Bmibaby'] = 8; legendsectorAirline['BMI British Midland'] = 5; legendsectorAirline['British Airways'] = 28; legendsectorAirline['Qantas'] = 2; legendsectorAirline['Emirates'] = 12; legendsectorAirline['Air Malta'] = 12; legendsectorAirline['Austrian Airlines'] = 2; legendsectorAirline['EasyJet'] = 4; legendsectorAirline['Aer Lingus'] = 2; legendsectorAirline['Thomson Airways'] = 4; legendsectorAirline['Virgin Atlantic'] = 2; legendsectorAirline['Ryanair'] = 12; legendsectorAirline['FlyBe'] = 10; legendsectorAirline['Air France'] = 4; legendsectorAirline['Thomas Cook (TCX)'] = 4; legendsectorAirline['Jet2'] = 4; legendsectorAirline['Czech Airlines'] = 1; legendsectorAirline['OneWorld'] = 30; legendsectorAirline['Star Alliance'] = 100; legendsectorAirline['SkyTeam'] = 16; legendsectorAirline['No Alliance'] = 90; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['OneWorld','Star Alliance','SkyTeam','No Alliance'], name = 'Carriers', data = [{ y: 12.7, color: colors[0], drilldown: { name: 'OneWorld (30)', categories: ['British Airways','Others'], data: [11.9,0.8], color: colors[0] } } ,{ y: 42.4, color: colors[1], drilldown: { name: 'Star Alliance (100)', categories: ['Singapore Airlines','Swiss','South African Airways','Thai','Lufthansa','BMI British Midland','Others'], data: [6.4,9.3,10.6,5.1,8.1,2.1,0.8], color: colors[1] } } ,{ y: 6.8, color: colors[2], drilldown: { name: 'SkyTeam (16)', categories: ['KLM Royal Dutch Airlines','Air France','Others'], data: [3.8,1.7,1.2], color: colors[2] } } ,{ y: 38.1, color: colors[3], drilldown: { name: 'No Alliance (90)', categories: ['Monarch','Thomas Cook (MT)','Bmibaby','Emirates','Air Malta','EasyJet','Thomson Airways','Ryanair','FlyBe','Thomas Cook (TCX)','Jet2','Others'], data: [5.1,1.7,3.4,5.1,5.1,1.7,1.7,5.1,4.2,1.7,1.7,1.6], 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 ""; } }