var legendsectorAirline = {}; var legendsectorAlliance = {}; legendsectorAlliance['OneWorld'] = 69; legendsectorAlliance['Star Alliance'] = 30; legendsectorAlliance['SkyTeam'] = 14; legendsectorAlliance['No Alliance'] = 48; legendsectorAirline['Emirates'] = 4; legendsectorAirline['British Airways'] = 1; legendsectorAirline['Etihad'] = 6; legendsectorAirline['Pacific Blue'] = 26; legendsectorAirline['Singapore Airlines'] = 22; legendsectorAirline['Qantas'] = 56; legendsectorAirline['Cathay Pacific'] = 4; legendsectorAirline['Cathay Dragon'] = 8; legendsectorAirline['Air France'] = 2; legendsectorAirline['Air China'] = 4; legendsectorAirline['Virgin Atlantic'] = 12; legendsectorAirline['Jetstar Airways'] = 12; legendsectorAirline['Thai'] = 4; legendsectorAirline['OneWorld'] = 69; legendsectorAirline['Star Alliance'] = 30; legendsectorAirline['SkyTeam'] = 14; legendsectorAirline['No Alliance'] = 48; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['OneWorld','Star Alliance','SkyTeam','No Alliance'], name = 'Carriers', data = [{ y: 42.9, color: colors[0], drilldown: { name: 'OneWorld (69)', categories: ['Qantas','Cathay Pacific','Cathay Dragon','Others'], data: [34.8,2.5,5,0.6], color: colors[0] } } ,{ y: 18.6, color: colors[1], drilldown: { name: 'Star Alliance (30)', categories: ['Singapore Airlines','Air China','Thai'], data: [13.7,2.5,2.5], color: colors[1] } } ,{ y: 8.7, color: colors[2], drilldown: { name: 'SkyTeam (14)', categories: ['Air France','Virgin Atlantic'], data: [1.2,7.5], color: colors[2] } } ,{ y: 29.8, color: colors[3], drilldown: { name: 'No Alliance (48)', categories: ['Emirates','Etihad','Pacific Blue','Jetstar Airways'], data: [2.5,3.7,16.1,7.5], 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 ""; } }