var legenddistanceAirline = {}; var legenddistanceAlliance = {}; legenddistanceAlliance['OneWorld'] = 6777; legenddistanceAlliance['Star Alliance'] = 18729; legenddistanceAlliance['SkyTeam'] = 6010; legenddistanceAlliance['No Alliance'] = 1738; legenddistanceAirline['EasyJet'] = 1392; legenddistanceAirline['Swiss'] = 1456; legenddistanceAirline['British Airways'] = 753; legenddistanceAirline['Air Southwest (of UK)'] = 346; legenddistanceAirline['Air France'] = 6010; legenddistanceAirline['United Airlines'] = 4112; legenddistanceAirline['Qantas'] = 6024; legenddistanceAirline['Air New Zealand'] = 7326; legenddistanceAirline['Singapore Airlines'] = 5504; legenddistanceAirline['BMI British Midland'] = 331; legenddistanceAirline['OneWorld'] = 6777; legenddistanceAirline['Star Alliance'] = 18729; legenddistanceAirline['SkyTeam'] = 6010; legenddistanceAirline['No Alliance'] = 1738; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['OneWorld','Star Alliance','SkyTeam','No Alliance'], name = 'Carriers', data = [{ y: 20.4, color: colors[0], drilldown: { name: 'OneWorld (6777)', categories: ['British Airways','Qantas'], data: [2.3,18.1], color: colors[0] } } ,{ y: 56.3, color: colors[1], drilldown: { name: 'Star Alliance (18729)', categories: ['Swiss','United Airlines','Air New Zealand','Singapore Airlines','BMI British Midland'], data: [4.4,12.4,22,16.6,1], color: colors[1] } } ,{ y: 18.1, color: colors[2], drilldown: { name: 'SkyTeam (6010)', categories: ['Air France'], data: [18.1], color: colors[2] } } ,{ y: 5.2, color: colors[3], drilldown: { name: 'No Alliance (1738)', categories: ['EasyJet','Air Southwest (of UK)'], data: [4.2,1], 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 ""; } }