var legendsectorAirline = {}; var legendsectorAlliance = {}; legendsectorAlliance['OneWorld'] = 22; legendsectorAlliance['Star Alliance'] = 27; legendsectorAlliance['SkyTeam'] = 1; legendsectorAlliance['No Alliance'] = 5; legendsectorAirline['Air Berlin'] = 13; legendsectorAirline['Swiss'] = 19; legendsectorAirline['American Airlines'] = 1; legendsectorAirline['Thai'] = 4; legendsectorAirline['Qatar Airways'] = 8; legendsectorAirline['SAS'] = 2; legendsectorAirline['United Airlines'] = 2; legendsectorAirline['Norwegian Air Shuttle'] = 1; legendsectorAirline['Delta'] = 1; legendsectorAirline['Norwegian Air International'] = 1; legendsectorAirline['Maldivian Air Taxi'] = 2; legendsectorAirline['EasyJet'] = 1; legendsectorAirline['OneWorld'] = 22; legendsectorAirline['Star Alliance'] = 27; legendsectorAirline['SkyTeam'] = 1; 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: 40, color: colors[0], drilldown: { name: 'OneWorld (22)', categories: ['Air Berlin','American Airlines','Qatar Airways'], data: [23.6,1.8,14.5], color: colors[0] } } ,{ y: 49.1, color: colors[1], drilldown: { name: 'Star Alliance (27)', categories: ['Swiss','Thai','SAS','United Airlines'], data: [34.5,7.3,3.6,3.6], color: colors[1] } } ,{ y: 1.8, color: colors[2], drilldown: { name: 'SkyTeam (1)', categories: ['Delta'], data: [1.8], color: colors[2] } } ,{ y: 9.1, color: colors[3], drilldown: { name: 'No Alliance (5)', categories: ['Norwegian Air Shuttle','Norwegian Air International','Maldivian Air Taxi','EasyJet'], data: [1.8,1.8,3.6,1.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 ""; } }