var legendsectorAirline = {}; var legendsectorAlliance = {}; legendsectorAlliance['OneWorld'] = 145; legendsectorAlliance['Star Alliance'] = 238; legendsectorAlliance['SkyTeam'] = 21; legendsectorAlliance['No Alliance'] = 24; legendsectorAirline['Cathay Pacific'] = 92; legendsectorAirline['Air Canada'] = 67; legendsectorAirline['Singapore Airlines'] = 75; legendsectorAirline['Air New Zealand'] = 36; legendsectorAirline['Qantas'] = 10; legendsectorAirline['British Airways'] = 27; legendsectorAirline['BMI British Midland'] = 2; legendsectorAirline['Asiana Airlines'] = 6; legendsectorAirline['All Nippon Airways'] = 10; legendsectorAirline['Thai'] = 17; legendsectorAirline['SAS'] = 9; legendsectorAirline['Air France'] = 4; legendsectorAirline['Malaysia Airlines'] = 2; legendsectorAirline['Swiss'] = 11; legendsectorAirline['Southwest'] = 4; legendsectorAirline['Japan Airlines'] = 4; legendsectorAirline['American Airlines'] = 6; legendsectorAirline['Lufthansa'] = 2; legendsectorAirline['Cathay Dragon'] = 2; legendsectorAirline['KLM Royal Dutch Airlines'] = 1; legendsectorAirline['Korean Air'] = 15; legendsectorAirline['Scoot'] = 3; legendsectorAirline['Etihad'] = 1; legendsectorAirline['LATAM Chile'] = 1; legendsectorAirline['Pacific Blue'] = 4; legendsectorAirline['Alaska Airlines'] = 1; legendsectorAirline['Bangkok Airways'] = 2; legendsectorAirline['Jetstar Airways'] = 2; legendsectorAirline['Alitalia'] = 1; legendsectorAirline['Hong Kong Airlines'] = 1; legendsectorAirline['United Airlines'] = 1; legendsectorAirline['Austrian Airlines'] = 2; legendsectorAirline['Cebu Pacific'] = 1; legendsectorAirline['Garuda Indonesia'] = 2; legendsectorAirline['IcelandAir'] = 2; legendsectorAirline['Air Asia'] = 2; legendsectorAirline['OneWorld'] = 145; legendsectorAirline['Star Alliance'] = 238; legendsectorAirline['SkyTeam'] = 21; legendsectorAirline['No Alliance'] = 24; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['OneWorld','Star Alliance','SkyTeam','No Alliance'], name = 'Carriers', data = [{ y: 33.9, color: colors[0], drilldown: { name: 'OneWorld (145)', categories: ['Cathay Pacific','Qantas','British Airways','American Airlines','Others'], data: [21.5,2.3,6.3,1.4,2.3], color: colors[0] } } ,{ y: 55.6, color: colors[1], drilldown: { name: 'Star Alliance (238)', categories: ['Air Canada','Singapore Airlines','Air New Zealand','Asiana Airlines','All Nippon Airways','Thai','SAS','Swiss','Others'], data: [15.7,17.5,8.4,1.4,2.3,4,2.1,2.6,1.7], color: colors[1] } } ,{ y: 4.9, color: colors[2], drilldown: { name: 'SkyTeam (21)', categories: ['Korean Air','Others'], data: [3.5,1.3], color: colors[2] } } ,{ y: 5.6, color: colors[3], drilldown: { name: 'No Alliance (24)', categories: ['Others'], data: [5.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 ""; } }