var legendsectorAirline = {}; var legendsectorAlliance = {}; legendsectorAlliance['OneWorld'] = 90; legendsectorAlliance['Star Alliance'] = 0; legendsectorAlliance['SkyTeam'] = 1; legendsectorAlliance['No Alliance'] = 18; legendsectorAirline['British Airways'] = 78; legendsectorAirline['Air Malta'] = 2; legendsectorAirline['EasyJet'] = 2; legendsectorAirline['Dan Air'] = 2; legendsectorAirline['Ryanair'] = 2; legendsectorAirline['Virgin Atlantic'] = 1; legendsectorAirline['Finnair'] = 2; legendsectorAirline['Aer Lingus'] = 2; legendsectorAirline['Easyjet'] = 4; legendsectorAirline['Norwegian Air International'] = 2; legendsectorAirline['Qatar Airways'] = 6; legendsectorAirline['Sri Lankan Airlines'] = 4; legendsectorAirline['EasyJet'] = 2; legendsectorAirline['OneWorld'] = 90; legendsectorAirline['Star Alliance'] = 0; legendsectorAirline['SkyTeam'] = 1; legendsectorAirline['No Alliance'] = 18; $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, categories = ['OneWorld','SkyTeam','No Alliance'], name = 'Carriers', data = [{ y: 82.6, color: colors[0], drilldown: { name: 'OneWorld (90)', categories: ['British Airways','Finnair','Qatar Airways','Sri Lankan Airlines'], data: [71.6,1.8,5.5,3.7], color: colors[0] } } ,{ y: 0.9, color: colors[2], drilldown: { name: 'SkyTeam (1)', categories: ['Others'], data: [0.9], color: colors[2] } } ,{ y: 16.5, color: colors[3], drilldown: { name: 'No Alliance (18)', categories: ['Air Malta','EasyJet','Dan Air','Ryanair','Aer Lingus','Easyjet','Norwegian Air International','EasyJet'], data: [1.8,1.8,1.8,1.8,1.8,3.7,1.8,1.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 ""; } }