var legendsectorAirline = {}; var legendsectorAlliance = {}; legendsectorAlliance['OneWorld'] = 357; legendsectorAlliance['Star Alliance'] = 3; legendsectorAlliance['SkyTeam'] = 44; legendsectorAlliance['No Alliance'] = 27; legendsectorAirline['British Airways'] = 336; legendsectorAirline['Virgin Atlantic'] = 28; legendsectorAirline['JetBlue'] = 2; legendsectorAirline['Virgin America'] = 8; legendsectorAirline['BMI British Midland'] = 1; legendsectorAirline['Norwegian Air Shuttle'] = 7; legendsectorAirline['Cityjet'] = 3; legendsectorAirline['American Airlines'] = 6; legendsectorAirline['LATAM Chile'] = 5; legendsectorAirline['Norwegian Air International'] = 1; legendsectorAirline['Delta'] = 1; legendsectorAirline['Finnair'] = 9; legendsectorAirline['Iberia'] = 1; legendsectorAirline['FlyBe'] = 3; legendsectorAirline['KLM Royal Dutch Airlines'] = 15; legendsectorAirline['SAS'] = 2; legendsectorAirline['Norwegian Air UK'] = 1; legendsectorAirline['Norse Atlantic Airways'] = 2; legendsectorAirline['OneWorld'] = 357; legendsectorAirline['Star Alliance'] = 3; legendsectorAirline['SkyTeam'] = 44; legendsectorAirline['No Alliance'] = 27; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['OneWorld','Star Alliance','SkyTeam','No Alliance'], name = 'Carriers', data = [{ y: 82.8, color: colors[0], drilldown: { name: 'OneWorld (357)', categories: ['British Airways','American Airlines','LATAM Chile','Finnair','Others'], data: [78,1.4,1.2,2.1,0.2], color: colors[0] } } ,{ y: 0.7, color: colors[1], drilldown: { name: 'Star Alliance (3)', categories: ['Others'], data: [0.7], color: colors[1] } } ,{ y: 10.2, color: colors[2], drilldown: { name: 'SkyTeam (44)', categories: ['Virgin Atlantic','KLM Royal Dutch Airlines','Others'], data: [6.5,3.5,0.2], color: colors[2] } } ,{ y: 6.3, color: colors[3], drilldown: { name: 'No Alliance (27)', categories: ['Virgin America','Norwegian Air Shuttle','Others'], data: [1.9,1.6,2.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 ""; } }