var legendsectorAirline = {}; var legendsectorAlliance = {}; legendsectorAlliance['OneWorld'] = 99; legendsectorAlliance['Star Alliance'] = 110; legendsectorAlliance['SkyTeam'] = 8; legendsectorAlliance['No Alliance'] = 5; legendsectorAirline['BMI British Midland'] = 60; legendsectorAirline['Air New Zealand'] = 43; legendsectorAirline['TAP Portugal'] = 2; legendsectorAirline['British Airways'] = 71; legendsectorAirline['Qantas'] = 7; legendsectorAirline['Malev'] = 2; legendsectorAirline['Turkish Airlines'] = 1; legendsectorAirline['Virgin Atlantic'] = 1; legendsectorAirline['Air France'] = 7; legendsectorAirline['American Airlines'] = 6; legendsectorAirline['Finnair'] = 8; legendsectorAirline['Cathay Pacific'] = 5; legendsectorAirline['Swiss'] = 4; legendsectorAirline['Pacific Blue'] = 5; legendsectorAirline['OneWorld'] = 99; legendsectorAirline['Star Alliance'] = 110; legendsectorAirline['SkyTeam'] = 8; 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: 44.6, color: colors[0], drilldown: { name: 'OneWorld (99)', categories: ['British Airways','Qantas','American Airlines','Finnair','Cathay Pacific','Others'], data: [32,3.2,2.7,3.6,2.3,0.9], color: colors[0] } } ,{ y: 49.5, color: colors[1], drilldown: { name: 'Star Alliance (110)', categories: ['BMI British Midland','Air New Zealand','Swiss','Others'], data: [27,19.4,1.8,1.4], color: colors[1] } } ,{ y: 3.6, color: colors[2], drilldown: { name: 'SkyTeam (8)', categories: ['Air France','Others'], data: [3.2,0.5], color: colors[2] } } ,{ y: 2.3, color: colors[3], drilldown: { name: 'No Alliance (5)', categories: ['Pacific Blue'], data: [2.3], 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 ""; } }