var legenddistanceAirline = {};
var legenddistanceAlliance = {};
legenddistanceAlliance['OneWorld'] = 22242;
legenddistanceAlliance['Star Alliance'] = 76284;
legenddistanceAlliance['SkyTeam'] = 936;
legenddistanceAlliance['No Alliance'] = 33273;
legenddistanceAirline['EasyJet'] = 862;
legenddistanceAirline['Swiss'] = 24912;
legenddistanceAirline['Thai'] = 27161;
legenddistanceAirline['Singapore Airlines'] = 5283;
legenddistanceAirline['Scoot'] = 609;
legenddistanceAirline['Air Asia'] = 4698;
legenddistanceAirline['Lufthansa'] = 3067;
legenddistanceAirline['Turkish Airlines'] = 6211;
legenddistanceAirline['British Airways'] = 401;
legenddistanceAirline['Jet Airways'] = 12731;
legenddistanceAirline['Aer Lingus'] = 1124;
legenddistanceAirline['Vietnam Airlines'] = 649;
legenddistanceAirline['EasyJet'] = 1011;
legenddistanceAirline['Malaysia Airlines'] = 1227;
legenddistanceAirline['Firefly'] = 451;
legenddistanceAirline['Thai Air Asia'] = 331;
legenddistanceAirline['Asiana Airlines'] = 510;
legenddistanceAirline['United Airlines'] = 783;
legenddistanceAirline['Japan Airlines'] = 1496;
legenddistanceAirline['Jet2'] = 381;
legenddistanceAirline['Ryanair'] = 849;
legenddistanceAirline['Cathay Pacific'] = 17978;
legenddistanceAirline['KLM Royal Dutch Airlines'] = 287;
legenddistanceAirline['Cathay Dragon'] = 1140;
legenddistanceAirline['Etihad'] = 8460;
legenddistanceAirline['Philippine Airlines'] = 1418;
legenddistanceAirline['Air Philippines'] = 348;
legenddistanceAirline['Air China'] = 1237;
legenddistanceAirline['All Nippon Airways'] = 7120;
legenddistanceAirline['OneWorld'] = 22242;
legenddistanceAirline['Star Alliance'] = 76284;
legenddistanceAirline['SkyTeam'] = 936;
legenddistanceAirline['No Alliance'] = 33273;
$(function () {
var chart;
$(document).ready(function() {
var colors = Highcharts.getOptions().colors,
categories = ['OneWorld','Star Alliance','SkyTeam','No Alliance'],
name = 'Carriers',
data = [{
y: 16.8,
color: colors[0],
drilldown: {
name: 'OneWorld (22242)',
categories: ['Japan Airlines','Cathay Pacific','Others'],
data: [1.1,13.5,2.1],
color: colors[0]
}
} ,{
y: 57.5,
color: colors[1],
drilldown: {
name: 'Star Alliance (76284)',
categories: ['Swiss','Thai','Singapore Airlines','Lufthansa','Turkish Airlines','All Nippon Airways','Others'],
data: [18.8,20.5,4,2.3,4.7,5.4,1.9],
color: colors[1]
}
} ,{
y: 0.7,
color: colors[2],
drilldown: {
name: 'SkyTeam (936)',
categories: ['Others'],
data: [0.7],
color: colors[2]
}
} ,{
y: 25.1,
color: colors[3],
drilldown: {
name: 'No Alliance (33273)',
categories: ['Air Asia','Jet Airways','Etihad','Philippine Airlines','Others'],
data: [3.5,9.6,6.4,1.1,4.4],
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 "";
}
}