var legendsectorAirline = {}; var legendsectorAlliance = {}; legendsectorAlliance['OneWorld'] = 70; legendsectorAlliance['Star Alliance'] = 1; legendsectorAlliance['SkyTeam'] = 0; legendsectorAlliance['No Alliance'] = 47; legendsectorAirline['British Airways'] = 54; legendsectorAirline['Air Southwest (of UK)'] = 13; legendsectorAirline['Aer Lingus'] = 9; legendsectorAirline['American Airlines'] = 15; legendsectorAirline['Pacific Blue'] = 2; legendsectorAirline['Qantas'] = 1; legendsectorAirline['United Airlines'] = 1; legendsectorAirline['FlyBe'] = 20; legendsectorAirline['TUI Airways'] = 2; legendsectorAirline['Thomson Airways'] = 1; legendsectorAirline['OneWorld'] = 70; legendsectorAirline['Star Alliance'] = 1; legendsectorAirline['SkyTeam'] = 0; legendsectorAirline['No Alliance'] = 47; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['OneWorld','Star Alliance','No Alliance'], name = 'Carriers', data = [{ y: 59.3, color: colors[0], drilldown: { name: 'OneWorld (70)', categories: ['British Airways','American Airlines','Others'], data: [45.8,12.7,0.8], color: colors[0] } } ,{ y: 0.8, color: colors[1], drilldown: { name: 'Star Alliance (1)', categories: ['Others'], data: [0.8], color: colors[1] } } ,{ y: 39.8, color: colors[3], drilldown: { name: 'No Alliance (47)', categories: ['Air Southwest (of UK)','Aer Lingus','Pacific Blue','FlyBe','TUI Airways','Others'], data: [11,7.6,1.7,16.9,1.7,0.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 ""; } }