var legendsectorAirline = {}; var legendsectorAlliance = {}; legendsectorAlliance['OneWorld'] = 92; legendsectorAlliance['Star Alliance'] = 22; legendsectorAlliance['SkyTeam'] = 11; legendsectorAlliance['No Alliance'] = 5; legendsectorAirline['Air Canada'] = 4; legendsectorAirline['Spanair'] = 2; legendsectorAirline['Lufthansa'] = 2; legendsectorAirline['Air Transat'] = 2; legendsectorAirline['Monarch'] = 2; legendsectorAirline['British Airways'] = 39; legendsectorAirline['Air France'] = 2; legendsectorAirline['United Airlines'] = 14; legendsectorAirline['American Airlines'] = 42; legendsectorAirline['KLM Royal Dutch Airlines'] = 3; legendsectorAirline['Delta'] = 6; legendsectorAirline['Iberia'] = 4; legendsectorAirline['US Airways'] = 2; legendsectorAirline['Cathay Pacific'] = 4; legendsectorAirline['JetBlue'] = 1; legendsectorAirline['Air Berlin'] = 1; legendsectorAirline['OneWorld'] = 92; legendsectorAirline['Star Alliance'] = 22; legendsectorAirline['SkyTeam'] = 11; legendsectorAirline['No Alliance'] = 5; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['OneWorld','Star Alliance','SkyTeam','No Alliance'], name = 'Carriers', data = [{ y: 70.8, color: colors[0], drilldown: { name: 'OneWorld (92)', categories: ['British Airways','American Airlines','Iberia','US Airways','Cathay Pacific','Others'], data: [30,32.3,3.1,1.5,3.1,0.8], color: colors[0] } } ,{ y: 16.9, color: colors[1], drilldown: { name: 'Star Alliance (22)', categories: ['Air Canada','Spanair','Lufthansa','United Airlines'], data: [3.1,1.5,1.5,10.8], color: colors[1] } } ,{ y: 8.5, color: colors[2], drilldown: { name: 'SkyTeam (11)', categories: ['Air France','KLM Royal Dutch Airlines','Delta'], data: [1.5,2.3,4.6], color: colors[2] } } ,{ y: 3.8, color: colors[3], drilldown: { name: 'No Alliance (5)', categories: ['Air Transat','Monarch','Others'], data: [1.5,1.5,0.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 ""; } }