% strUser = Session("handle") If Not Request.QueryString("handle") = "" Then strUser = Request.QueryString("handle") End If If strUser = "" Then strUser = "BA97" End If strMode = "sector" If Not Request.QueryString("mode") = "" Then strMode = Request.QueryString("mode") End If %> var legend<%= strMode %>Airline = {}; var legend<%= strMode %>Alliance = {}; <% Set objAlliance = Server.CreateObject("Scripting.Dictionary") Set objAirlineName = Server.CreateObject("Scripting.Dictionary") Set objAirlineCount = Server.CreateObject("Scripting.Dictionary") Set objAirlineAlliance = Server.CreateObject("Scripting.Dictionary") adoRS.Open "SELECT airline_identifier, airline_name, alliance_name FROM ba97_airlines" Do While Not adoRS.EOF If Not adoRS.fields(2).value = "" And Not objAlliance.Exists(adoRS.fields(2).value) Then objAlliance.Add adoRS.fields(2).value, 0 End If objAirlineAlliance.Add adoRS.fields(0).value, adoRS.fields(2).value objAirlineName.Add adoRS.fields(0).value, adoRS.fields(1).value adoRS.MoveNext Loop adoRS.Close If strMode = "sector" Then strSQL = "SELECT airline_identifier, count(airline_identifier) " _ & "FROM ba97_sectors " _ & "WHERE handle='" & strUser & "' " If Not Request.QueryString("filter") = "" And Not Request.QueryString("filter") = "all" Then strSQL = strSQL & "AND flight_date>='" & Request.QueryString("filter") _ & "-01-01 00:00' AND flight_date<='" & Request.QueryString("filter") _ & "-12-31 23:59' " End If strSQL = strSQL & "GROUP BY airline_identifier" strSQLTwo = "SELECT airline_identifier, count(airline_identifier) " _ & "FROM ba97_sectors_archive " _ & "WHERE handle='" & strUser & "' " If Not Request.QueryString("filter") = "" And Not Request.QueryString("filter") = "all" Then strSQLTwo = strSQLTwo & "AND flight_date>='" & Request.QueryString("filter") _ & "-01-01 00:00' AND flight_date<='" & Request.QueryString("filter") _ & "-12-31 23:59' " End If strSQLTwo = strSQLTwo & "GROUP BY airline_identifier" Else strSQL = "SELECT airline_identifier, sum(distance) " _ & "FROM ba97_sectors " _ & "WHERE handle='" & strUser & "' " If Not Request.QueryString("filter") = "" And Not Request.QueryString("filter") = "all" Then strSQL = strSQL & "AND flight_date>='" & Request.QueryString("filter") _ & "-01-01 00:00' AND flight_date<='" & Request.QueryString("filter") _ & "-12-31 23:59' " End If strSQL = strSQL & "GROUP BY airline_identifier" strSQLTwo = "SELECT airline_identifier, sum(distance) " _ & "FROM ba97_sectors_archive " _ & "WHERE handle='" & strUser & "' " If Not Request.QueryString("filter") = "" And Not Request.QueryString("filter") = "all" Then strSQLTwo = strSQLTwo & "AND flight_date>='" & Request.QueryString("filter") _ & "-01-01 00:00' AND flight_date<='" & Request.QueryString("filter") _ & "-12-31 23:59' " End If strSQLTwo = strSQLTwo & "GROUP BY airline_identifier" End If adoRS.Open strSQL blnFutureSectors = true If adoRS.EOF then blnFutureSectors = false Else Do While Not adoRS.EOF objAirlineCount.Add adoRS.fields(0).value, adoRS.fields(1).value If blnDEBUG Then Response.Write "//" & adoRS.fields(0).value & " --> " & adoRS.fields(1).value & vbcrlf End If adoRS.MoveNext Loop End If adoRS.Close adoRS.Open strSQLTwo If adoRS.EOF And blnFutureSectors = false Then Response.Write "
" & strUser & " has no past or future sectors booked!" Response.End Else Do While Not adoRS.EOF If objAirlineCount.Exists(adoRS.fields(0).value) Then If blnDEBUG Then Response.Write "//" & adoRS.fields(0).value & " --> " & CDbl(objAirlineCount.Item(adoRS.fields(0).value)) & " adding to " & CDbl(adoRS.fields(1).value) End If objAirlineCount.Item(adoRS.fields(0).value) = CDbl(objAirlineCount.Item(adoRS.fields(0).value)) + CDbl(adoRS.fields(1).value) If blnDEBUG Then Response.Write " = " & objAirlineCount.Item(adoRS.fields(0).value) & vbcrlf End If Else objAirlineCount.Add adoRS.fields(0).value, adoRS.fields(1).value If blnDEBUG Then Response.Write "//" & adoRS.fields(0).value & " --> " & adoRS.fields(1).value & vbcrlf End If End If adoRS.MoveNext Loop End If adoRS.Close arrAirlines = objAirlineCount.Keys arrAlliances = objAlliance.Keys strAlliances = "" ' Build stats - number of sectors per alliance, and count all sectors For Each strAlliance In arrAlliances For Each strAirline In arrAirlines If objAirlineAlliance.Item(strAirline) = strAlliance Then objAlliance.Item(strAlliance) = CDbl(objAlliance.Item(strAlliance)) _ + CDbl(objAirlineCount.Item(strAirline)) intTotalSectors = intTotalSectors + CDbl(objAirlineCount.Item(strAirline)) End If Next Response.Write "legend" & strMode & "Alliance['" & strAlliance & "'] = " & objAlliance.Item(strAlliance) & ";" & vbcrlf Next For Each strAirline In arrAirlines Response.Write "legend" & strMode & "Airline['" & objAirlineName.Item(strAirline) & "'] = " _ & objAirlineCount.Item(strAirline) & ";" & vbcrlf objAirlineCount.Item(strAirline) = _ Round(CDbl(objAirlineCount.Item(strAirline)) / intTotalSectors,3) * 100 ' If this is <1% then bucket them up into a per-alliance 'other' If objAirlineCount.Item(strAirline) < 1 Then If objAirlineCount.Exists(objAirlineAlliance.Item(strAirline)) Then objAirlineCount.Item(objAirlineAlliance.Item(strAirline)) = _ CDbl(objAirlineCount.Item(objAirlineAlliance.Item(strAirline))) _ + CDbl(objAirlineCount.Item(strAirline)) Else objAirlineCount.Add objAirlineAlliance.Item(strAirline), _ CDbl(objAirlineCount.Item(strAirline)) objAirlineAlliance.Add objAirlineAlliance.Item(strAirline), _ objAirlineAlliance.Item(strAirline) objAirlineName.Add objAirlineAlliance.Item(strAirline), _ "Others" End If objAirlineCount.Remove(strAirline) End If Next For Each strAlliance In arrAlliances Response.Write "legend" & strMode & "Airline['" & strAlliance & "'] = " _ & objAlliance.Item(strAlliance) & ";" & vbcrlf Next %> $(function () { var chart; $(document).ready(function() { var colors = Highcharts.getOptions().colors, <% For Each strAlliance In arrAlliances If Not objAlliance.Item(strAlliance) = 0 Then objAlliance.Item(strAlliance) = _ CDbl(objAlliance.Item(strAlliance)) / intTotalSectors strAlliances = strAlliances & "'" & strAlliance & "'," End If Next Response.Write " categories = [" & Left(strAlliances, Len(strAlliances)-1) & "]," & vbcrlf Response.Write " name = 'Carriers'," & vbcrlf Response.Write " data = [" ' Update stats - percentages by alliance arrAirlines = objAirlineCount.Keys For intCount = 0 To UBound(arrAlliances) strAirlines = "" strPercentages = "" For Each strAirline In arrAirlines ' Airlines <1% on a per-alliance basis get bucketed together into a pseudo-airline ' named the same as the alliance itself, so we change this to "Others" at this point If objAirlineAlliance.Item(strAirline) = arrAlliances(intCount) Then If objAirlineName.Item(strAirline) = arrAlliances(intCount) Then strAirlines = strAirlines & "'Others'," Else strAirlines = strAirlines & "'" & objAirlineName.Item(strAirline) & "'," End If strPercentages = strPercentages & objAirlineCount.Item(strAirline) & "," End If Next If Not strAirlines = "" Then strAirlines = Left(strAirlines, Len(strAirlines)-1) strPercentages = Left(strPercentages, Len(strPercentages)-1) Response.Write "{" %> y: <%= Round(objAlliance.Item(arrAlliances(intCount))*100,1) %>, color: colors[<%= intCount %>], drilldown: { name: '<%= arrAlliances(intCount) %> (<%= objAlliance.Item(arrAlliances(intCount))*intTotalSectors %>)', categories: [<%= strAirlines %>], data: [<%= strPercentages %>], color: colors[<%= intCount %>] } } <% If Not intCount = UBound(arrAlliances) Then Response.Write "," End If %> <% End If Next %> ]; // 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_<%= strMode %>', 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 + '%' + getCount<%= strMode %>(this.point.name) : null; } } }] }); }); }); function getCount<%= strMode %>(airline) { if(legend<%= strMode %>Airline[airline]) { return " (" + parseInt(legend<%= strMode %>Airline[airline]).toLocaleString() + ")"; } else { return ""; } }