var legendsectorAirline = {}; var legendsectorAlliance = {}; legendsectorAlliance['OneWorld'] = 22; legendsectorAlliance['Star Alliance'] = 0; legendsectorAlliance['SkyTeam'] = 0; legendsectorAlliance['No Alliance'] = 18; legendsectorAirline['Emirates'] = 4; legendsectorAirline['Qantas'] = 13; legendsectorAirline['Virgin Australia'] = 3; legendsectorAirline['AIRPORT-OPERATED'] = 2; legendsectorAirline['Rex'] = 9; legendsectorAirline['British Airways'] = 5; legendsectorAirline['Qatar Airways'] = 4; legendsectorAirline['OneWorld'] = 22; legendsectorAirline['Star Alliance'] = 0; legendsectorAirline['SkyTeam'] = 0; legendsectorAirline['No Alliance'] = 18; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['OneWorld','No Alliance'], name = 'Carriers', data = [{ y: 55, color: colors[0], drilldown: { name: 'OneWorld (22)', categories: ['Qantas','British Airways','Qatar Airways'], data: [32.5,12.5,10], color: colors[0] } } ,{ y: 45, color: colors[3], drilldown: { name: 'No Alliance (18)', categories: ['Emirates','Virgin Australia','AIRPORT-OPERATED','Rex'], data: [10,7.5,5,22.5], 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 ""; } }