var legenddistanceAirline = {}; var legenddistanceAlliance = {}; legenddistanceAlliance['OneWorld'] = 122093; legenddistanceAlliance['Star Alliance'] = 792; legenddistanceAlliance['SkyTeam'] = 0; legenddistanceAlliance['No Alliance'] = 25152; legenddistanceAirline['British Airways'] = 117475; legenddistanceAirline['Oman Air'] = 2944; legenddistanceAirline['Iberia'] = 774; legenddistanceAirline['Austrian Airlines'] = 792; legenddistanceAirline['Thomson Airways'] = 22208; legenddistanceAirline['Cathay Pacific'] = 1594; legenddistanceAirline['Finnair'] = 2250; legenddistanceAirline['OneWorld'] = 122093; legenddistanceAirline['Star Alliance'] = 792; legenddistanceAirline['SkyTeam'] = 0; legenddistanceAirline['No Alliance'] = 25152; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['OneWorld','Star Alliance','No Alliance'], name = 'Carriers', data = [{ y: 82.5, color: colors[0], drilldown: { name: 'OneWorld (122093)', categories: ['British Airways','Cathay Pacific','Finnair','Others'], data: [79.4,1.1,1.5,0.5], color: colors[0] } } ,{ y: 0.5, color: colors[1], drilldown: { name: 'Star Alliance (792)', categories: ['Others'], data: [0.5], color: colors[1] } } ,{ y: 17, color: colors[3], drilldown: { name: 'No Alliance (25152)', categories: ['Oman Air','Thomson Airways'], data: [2,15], 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 ""; } }