var legendsectorAirline = {}; var legendsectorAlliance = {}; legendsectorAlliance['OneWorld'] = 11; legendsectorAlliance['Star Alliance'] = 63; legendsectorAlliance['SkyTeam'] = 2; legendsectorAlliance['No Alliance'] = 77; legendsectorAirline['Norwegian Air UK'] = 6; legendsectorAirline['Swiss'] = 16; legendsectorAirline['Lufthansa'] = 39; legendsectorAirline['Germania Express'] = 3; legendsectorAirline['Air Berlin'] = 5; legendsectorAirline['Ryanair'] = 7; legendsectorAirline['AIRPORT-OPERATED'] = 23; legendsectorAirline['Tuifly'] = 8; legendsectorAirline['GermanWings'] = 9; legendsectorAirline['Condor'] = 10; legendsectorAirline['Aer Lingus'] = 1; legendsectorAirline['HapagFly'] = 6; legendsectorAirline['Iberia'] = 2; legendsectorAirline['Norwegian Air Shuttle'] = 2; legendsectorAirline['Wizz Air'] = 2; legendsectorAirline['LOT Polish Airlines'] = 5; legendsectorAirline['Austrian Airlines'] = 1; legendsectorAirline['SAS'] = 1; legendsectorAirline['Spanair'] = 1; legendsectorAirline['Delta'] = 2; legendsectorAirline['British Airways'] = 4; legendsectorAirline['OneWorld'] = 11; legendsectorAirline['Star Alliance'] = 63; legendsectorAirline['SkyTeam'] = 2; legendsectorAirline['No Alliance'] = 77; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['OneWorld','Star Alliance','SkyTeam','No Alliance'], name = 'Carriers', data = [{ y: 7.2, color: colors[0], drilldown: { name: 'OneWorld (11)', categories: ['Air Berlin','Iberia','British Airways'], data: [3.3,1.3,2.6], color: colors[0] } } ,{ y: 41.2, color: colors[1], drilldown: { name: 'Star Alliance (63)', categories: ['Swiss','Lufthansa','LOT Polish Airlines','Others'], data: [10.5,25.5,3.3,2.1], color: colors[1] } } ,{ y: 1.3, color: colors[2], drilldown: { name: 'SkyTeam (2)', categories: ['Delta'], data: [1.3], color: colors[2] } } ,{ y: 50.3, color: colors[3], drilldown: { name: 'No Alliance (77)', categories: ['Norwegian Air UK','Germania Express','Ryanair','AIRPORT-OPERATED','Tuifly','GermanWings','Condor','HapagFly','Norwegian Air Shuttle','Wizz Air','Others'], data: [3.9,2,4.6,15,5.2,5.9,6.5,3.9,1.3,1.3,0.7], 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 ""; } }