var legenddistanceAirline = {}; var legenddistanceAlliance = {}; legenddistanceAlliance['OneWorld'] = 215681; legenddistanceAlliance['Star Alliance'] = 6799; legenddistanceAlliance['SkyTeam'] = 19538; legenddistanceAlliance['No Alliance'] = 14911; legenddistanceAirline['British Airways'] = 196002; legenddistanceAirline['American Airlines'] = 14045; legenddistanceAirline['Iberia'] = 2300; legenddistanceAirline['Finnair'] = 2718; legenddistanceAirline['Virgin Atlantic'] = 6832; legenddistanceAirline['Air France'] = 7174; legenddistanceAirline['Aer Lingus'] = 199; legenddistanceAirline['Lufthansa'] = 4006; legenddistanceAirline['KLM Royal Dutch Airlines'] = 5004; legenddistanceAirline['Ryanair'] = 2560; legenddistanceAirline['Tarom'] = 528; legenddistanceAirline['Azerbaijan Airlines'] = 4726; legenddistanceAirline['DAT - Danish Air Transport'] = 2258; legenddistanceAirline['Royal Air Maroc'] = 248; legenddistanceAirline['Austrian Airlines'] = 816; legenddistanceAirline['EasyJet'] = 512; legenddistanceAirline['Air Dolomiti'] = 756; legenddistanceAirline['Cityjet'] = 1102; legenddistanceAirline['Jet2'] = 1275; legenddistanceAirline['TUI Airways'] = 1275; legenddistanceAirline['SAS'] = 1977; legenddistanceAirline['Alaska Airlines'] = 616; legenddistanceAirline['OneWorld'] = 215681; legenddistanceAirline['Star Alliance'] = 6799; legenddistanceAirline['SkyTeam'] = 19538; legenddistanceAirline['No Alliance'] = 14911; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['OneWorld','Star Alliance','SkyTeam','No Alliance'], name = 'Carriers', data = [{ y: 83.9, color: colors[0], drilldown: { name: 'OneWorld (215681)', categories: ['British Airways','American Airlines','Finnair','Others'], data: [76.3,5.5,1.1,1.1], color: colors[0] } } ,{ y: 2.6, color: colors[1], drilldown: { name: 'Star Alliance (6799)', categories: ['Lufthansa','Others'], data: [1.6,1.1], color: colors[1] } } ,{ y: 7.6, color: colors[2], drilldown: { name: 'SkyTeam (19538)', categories: ['Virgin Atlantic','Air France','KLM Royal Dutch Airlines','Others'], data: [2.7,2.8,1.9,0.2], color: colors[2] } } ,{ y: 5.8, color: colors[3], drilldown: { name: 'No Alliance (14911)', categories: ['Ryanair','Azerbaijan Airlines','Others'], data: [1,1.8,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_distance', 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 + '%' + getCountdistance(this.point.name) : null; } } }] }); }); }); function getCountdistance(airline) { if(legenddistanceAirline[airline]) { return " (" + parseInt(legenddistanceAirline[airline]).toLocaleString() + ")"; } else { return ""; } }