<% 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 %> = {}; <% Set objAircraftCount = Server.CreateObject("Scripting.Dictionary") intTotal = 0 If strMode = "sector" Then strSQL = "SELECT aircraft, count(*) FROM ba97_sectors_archive 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 aircraft" strSQLTwo = "SELECT aircraft, count(*) FROM ba97_sectors 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 aircraft" Else strSQL = "SELECT aircraft, sum(distance) FROM ba97_sectors_archive 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 aircraft" strSQLTwo = "SELECT aircraft, sum(distance) FROM ba97_sectors 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 aircraft" End If adoRS.Open strSQL Do While Not adoRS.EOF strAircraft = adoRS.fields(0).value If Trim(strAircraft) = "" Then strAircraft = "Unspecified" End If objAircraftCount.Add strAircraft, adoRS.fields(1).value intTotal = intTotal + CDbl(adoRS.fields(1).value) adoRS.MoveNext Loop adoRS.Close adoRS.Open strSQLTwo Do While Not adoRS.EOF strAircraft = adoRS.fields(0).value If Trim(strAircraft) = "" Then strAircraft = "Unspecified" End If If objAircraftCount.Exists(strAircraft) Then objAircraftCount.Item(strAircraft) = _ CDbl(objAircraftCount.Item(strAircraft)) + CDbl(adoRS.fields(1).value) Else objAircraftCount.Add strAircraft, adoRS.fields(1).value End If intTotal = intTotal + CDbl(adoRS.fields(1).value) adoRS.MoveNext Loop adoRS.Close arrAircraft = objAircraftCount.Keys For Each strAircraft In arrAircraft objAircraftCount.Item(strAircraft) = _ Round(CDbl(objAircraftCount.Item(strAircraft)) / intTotal,3) * 100 If strMode = "sector" Then Response.Write "legend" & strMode & "['" & strAircraft & "'] = " & Round(objAircraftCount.Item(strAircraft)/100*intTotal) & vbcrlf Else Response.Write "legend" & strMode & "['" & strAircraft & "'] = " & Round(objAircraftCount.Item(strAircraft)/100*intTotal) & vbcrlf End If Next %> $(function () { var chart; $(document).ready(function() { // Build the chart chart = new Highcharts.Chart({ chart: { renderTo: 'aircraft_<%= strMode %>', plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false }, title: { text: '' }, tooltip: { pointFormat: '{series.name}: {point.percentage}%', percentageDecimals: 1 }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: true, color: '#000000', connectorColor: '#000000', formatter: function() { return ''+ this.point.name +': '+ Math.round(this.percentage*10)/10 +' % (' + legend<%= strMode %>[this.point.name].toLocaleString() + ')'; } } } }, series: [{ type: 'pie', name: 'Sectors by Aircraft', data: [ <% For intCount = 0 To UBound(arrAircraft) strOutput = " ['" & arrAircraft(intCount) & "'," & objAircraftCount.Item(arrAircraft(intCount)) & "]" If intCount < UBound(arrAircraft) Then strOutput = strOutput & "," End If Response.Write strOutput & vbcrlf Next %> ] }] }); }); });