var legendsectorAirline = {}; var legendsectorAlliance = {}; legendsectorAlliance['OneWorld'] = 12; legendsectorAlliance['Star Alliance'] = 375; legendsectorAlliance['SkyTeam'] = 11; legendsectorAlliance['No Alliance'] = 45; legendsectorAirline['Air New Zealand'] = 353; legendsectorAirline['TWay Air'] = 2; legendsectorAirline['Asiana Airlines'] = 2; legendsectorAirline['Singapore Airlines'] = 6; legendsectorAirline['Qantas'] = 10; legendsectorAirline['Pacific Blue'] = 7; legendsectorAirline['Jetstar Airways'] = 15; legendsectorAirline['LATAM Chile'] = 2; legendsectorAirline['Fiji Airways'] = 2; legendsectorAirline['China Airlines'] = 4; legendsectorAirline['United Airlines'] = 14; legendsectorAirline['JetBlue'] = 1; legendsectorAirline['Virgin America'] = 1; legendsectorAirline['Emirates'] = 1; legendsectorAirline['Virgin Australia'] = 11; legendsectorAirline['Etihad'] = 4; legendsectorAirline['KLM Royal Dutch Airlines'] = 2; legendsectorAirline['Ryanair'] = 1; legendsectorAirline['ITA Airways'] = 1; legendsectorAirline['Korean Air'] = 4; legendsectorAirline['OneWorld'] = 12; legendsectorAirline['Star Alliance'] = 375; legendsectorAirline['SkyTeam'] = 11; legendsectorAirline['No Alliance'] = 45; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['OneWorld','Star Alliance','SkyTeam','No Alliance'], name = 'Carriers', data = [{ y: 2.7, color: colors[0], drilldown: { name: 'OneWorld (12)', categories: ['Qantas','Others'], data: [2.3,0.5], color: colors[0] } } ,{ y: 84.7, color: colors[1], drilldown: { name: 'Star Alliance (375)', categories: ['Air New Zealand','Singapore Airlines','United Airlines','Others'], data: [79.7,1.4,3.2,0.5], color: colors[1] } } ,{ y: 2.5, color: colors[2], drilldown: { name: 'SkyTeam (11)', categories: ['Others'], data: [2.5], color: colors[2] } } ,{ y: 10.2, color: colors[3], drilldown: { name: 'No Alliance (45)', categories: ['Pacific Blue','Jetstar Airways','Virgin Australia','Others'], data: [1.6,3.4,2.5,2.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 ""; } }