var legenddistanceAirline = {}; var legenddistanceAlliance = {}; legenddistanceAlliance['OneWorld'] = 0; legenddistanceAlliance['Star Alliance'] = 1436; legenddistanceAlliance['SkyTeam'] = 10708; legenddistanceAlliance['No Alliance'] = 3826; legenddistanceAirline['Ryanair'] = 2654; legenddistanceAirline['EasyJet'] = 1172; legenddistanceAirline['BMI British Midland'] = 610; legenddistanceAirline['Virgin Atlantic'] = 10708; legenddistanceAirline['United Airlines'] = 826; legenddistanceAirline['OneWorld'] = 0; legenddistanceAirline['Star Alliance'] = 1436; legenddistanceAirline['SkyTeam'] = 10708; legenddistanceAirline['No Alliance'] = 3826; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['Star Alliance','SkyTeam','No Alliance'], name = 'Carriers', data = [{ y: 9, color: colors[1], drilldown: { name: 'Star Alliance (1436)', categories: ['BMI British Midland','United Airlines'], data: [3.8,5.2], color: colors[1] } } ,{ y: 67.1, color: colors[2], drilldown: { name: 'SkyTeam (10708)', categories: ['Virgin Atlantic'], data: [67.1], color: colors[2] } } ,{ y: 24, color: colors[3], drilldown: { name: 'No Alliance (3826)', categories: ['Ryanair','EasyJet'], data: [16.6,7.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 ""; } }