var legendsectorAirline = {}; var legendsectorAlliance = {}; legendsectorAlliance['OneWorld'] = 0; legendsectorAlliance['Star Alliance'] = 21; legendsectorAlliance['SkyTeam'] = 2; legendsectorAlliance['No Alliance'] = 16; legendsectorAirline['Singapore Airlines'] = 19; legendsectorAirline['Scoot'] = 5; legendsectorAirline['Air Asia'] = 1; legendsectorAirline['Vueling'] = 1; legendsectorAirline['Thai Lion Air'] = 1; legendsectorAirline['Firefly'] = 3; legendsectorAirline['Ryanair UK'] = 2; legendsectorAirline['Turkish Airlines'] = 2; legendsectorAirline['Thai Air Asia'] = 1; legendsectorAirline['VietJet Air'] = 1; legendsectorAirline['Vietnam Airlines'] = 2; legendsectorAirline['Indonesia AirAsia'] = 1; legendsectorAirline['OneWorld'] = 0; legendsectorAirline['Star Alliance'] = 21; legendsectorAirline['SkyTeam'] = 2; legendsectorAirline['No Alliance'] = 16; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['Star Alliance','SkyTeam','No Alliance'], name = 'Carriers', data = [{ y: 53.8, color: colors[1], drilldown: { name: 'Star Alliance (21)', categories: ['Singapore Airlines','Turkish Airlines'], data: [48.7,5.1], color: colors[1] } } ,{ y: 5.1, color: colors[2], drilldown: { name: 'SkyTeam (2)', categories: ['Vietnam Airlines'], data: [5.1], color: colors[2] } } ,{ y: 41, color: colors[3], drilldown: { name: 'No Alliance (16)', categories: ['Scoot','Air Asia','Vueling','Thai Lion Air','Firefly','Ryanair UK','Thai Air Asia','VietJet Air','Indonesia AirAsia'], data: [12.8,2.6,2.6,2.6,7.7,5.1,2.6,2.6,2.6], 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 ""; } }