Accident Stats

Graphs and stats on accidents

Created by Admin User on Thu May 05 2016 12:45:11 GMT+0000 (UTC)
Last updated: Thu Dec 02 2021 21:24:35 GMT+0000 (UTC)

You can embed the project by including the followng script into your HTML page:

<div id='mainpart'></div>

<script src='https://quips.anbdata.com/project/prod/d5a52d312a0044ca48d1130cf6504d4a074c3edb/script.js'></script>

You can view the deployed project on this test page

You can embed that page as a iframe directly as well by including the followng code into your HTML page:

<iframe src='https://quips.anbdata.com/project/prod/d5a52d312a0044ca48d1130cf6504d4a074c3edb/page.html' onload="this.style.height=this.contentDocument.body.scrollHeight +'px';"/>

Read more about integrations

Packages

Libraries and Stylesheets (CSS) which are loaded at start-up

Content

Jade, Javascript, Data and CSS files used in this app

Jade

Link to file

.container(style="width:800px") p Select a Group or Country select#groupsel !{groups.html} #yearcum(style="width:500px;height:400px;margin:auto") #accidentrate(style="width:500px;height:400px;margin:auto") //#statedist(style="width:500px;height:400px;margin:auto") table(style="width:100%"): tbody: tr td: #accidents(style="width:400px;height:400px;margin:auto") td: #fatalities(style="width:400px;height:400px;margin:auto") table(style="width:100%"): tbody: tr td: #riskaccidents(style="width:400px;height:400px;margin:auto") td: #riskfatalities(style="width:400px;height:400px;margin:auto") table(style="width:100%"): tbody: tr td: #riskcomb5(style="width:400px;height:400px;margin:auto") td: #riskcomparison(style="width:400px;height:400px;margin:auto") h2.text-center List of Occurrences .list-group-item p Filter the list using the following fields form#qform #state.form-group label(style="padding-right:10px") View data by State of .btn-group button.btn.btn-sm.btn-default.active(value="StateOfOccurrence",disabled='disabled') Occurrence button.btn.btn-sm.btn-default(value="StateOfRegistry",disabled='disabled') Registry button.btn.btn-sm.btn-default(value="StateOfOperator",disabled='disabled') Operator i(style='font-size:11px') &nbsp; Coming later... #aircraft.form-group label(style="padding-right:10px") *Aircraft Category .btn-group button.btn.btn-sm.btn-default.active(value='{"Airplane":true}') Airplane button.btn.btn-sm.btn-default(value='{"Helicopter":true}') Helicopter button.btn.btn-sm.btn-default(value="") Any #scheduled.form-group label(style="padding-right:10px") *Scheduled Commercial Only .btn-group button.btn.btn-sm.btn-default.active(value='{"ScheduledCommercial":true}') Yes button.btn.btn-sm.btn-default(value="") No #over57.form-group label(style="padding-right:10px") *Over 5.7t Only .btn-group button.btn.btn-sm.btn-default.active(value='{"Over5700":true}') Yes button.btn.btn-sm.btn-default(value="") No #accidents.form-group label(style="padding-right:10px") *Accidents only .btn-group button.btn.btn-sm.btn-default.active(value='{"Class":"Accident"}') Yes button.btn.btn-sm.btn-default(value="") No #fatal.form-group label(style="padding-right:10px") With Fatalities only .btn-group button.btn.btn-sm.btn-default(value='{"Fatalities":{"$gt":0}}') Yes button.btn.btn-sm.btn-default.active(value="") No #risk.form-group label(style="padding-right:10px") *Risk category .btn-group button.btn.btn-sm.btn-default(value='{"Risk":"RS"}') Runway Safety button.btn.btn-sm.btn-default(value='{"Risk":"CFIT"}') Controlled Flight Into Terrain (CFIT) button.btn.btn-sm.btn-default(value='{"Risk":"LOC-I"}') Loss of Control - Inflight (LOC-I) button.btn.btn-sm.btn-default.active(value="") Any #year.form-group label(style="padding-right:10px") Year of occurrence label.radio-inline | Between select.from option(value="2008") 2008 option(value="2009") 2009 option(value="2010") 2010 option(value="2011") 2011 option(value="2012") 2012 option(value="2013") 2013 option(value="2014") 2014 option(value="2015") 2015 option(value="2016") 2016 option(value="2017") 2017 option(value="2018") 2018 option(value="2019") 2019 option(value="2020",selected) 2020 | and select.to option(value="2008") 2008 option(value="2009") 2009 option(value="2010") 2010 option(value="2011") 2011 option(value="2012") 2012 option(value="2013") 2013 option(value="2014") 2014 option(value="2015") 2015 option(value="2016") 2016 option(value="2017") 2017 option(value="2018") 2018 option(value="2019") 2019 option(value="2020",selected) 2020 #official.form-group label(style="padding-right:10px") *Data of official stats for past years only .btn-group button.btn.btn-sm.btn-default.active(value="official") Yes button.btn.btn-sm.btn-default(value="") No p i(style='font-size:11px') * Please Note: br | When "Data of official stats for past years only" is set to "Yes", "Accidents only" and "Over 5.7t Only" would be set to "Yes" by default. br | When "Data of official stats for past years only" is set to "No", all events including those reported by media are shown. | That information was obtained from publicly available aviation-related websites and is provided for the convenience of addressees for informational purposes only. ICAO assumes no responsibility or liability of any kind for any errors, omissions, or inaccuracies contained herein or for any discrepancies between this information and that released by the official accident investigation authority. br | When "Aircraft Category" is set to "Helicopter", please set "Scheduled Commercial Only" to "No", "Over 5.7t Only" to "No", "Risk category" to "Any" and "Data of official stats for past years only" to "No". br | We are currently working on improving the user interface for the list of occurrences. button#submitform.btn.btn-sm.btn-info Search span#loading(style="display:none") Be patient, data is loading ... #datatable(style="width:750px;margin-top:20px")

Javascript

Link to file
Main function name

var cat=[] var lastofficial=2020 var currentyear=new Date().getUTCFullYear() var lastyear=currentyear-1 var worlddata=[] for (var i=2008;i<new Date().getUTCFullYear();i++) { cat.push(i) } $("#groupsel").val("518a8adc9a6a436858000001") var accidentrate={ credits:{ enabled:false }, chart: { animation: false }, title: { text: 'Accident Rate' }, subtitle: { text: 'Scheduled Commercial flights on airplanes above 5.7t only' }, xAxis: { categories: cat }, yAxis: { min:0, title: { text: 'Accidents/Million departures' } }, series: [] } var riskaccidents={ chart: { animation: false }, credits:{ enabled:false }, title: { text: 'Accidents by Risk Category' }, subtitle: { text: 'Scheduled Commercial flights on airplanes above 5.7t only' }, xAxis: { categories: cat }, yAxis: { min:0, title: { text: 'Accidents' } }, series: [] } var statedist={ chart: { animation: false }, credits:{ enabled:false }, title: { text: 'State Accident Distribution' }, xAxis:{ type: 'logarithmic' }, series: [{ type: 'scatter', name: 'State Accidents', data: [] }, { type: 'line', name: 'Group Rate', data: [] }, { type: 'line', name: 'Group Upper Limit', data: [] },{ type: 'line', name: 'Group Lower Limit', data: [] }] } var riskaccidentscumm={ chart: { animation: false }, credits:{ enabled:false }, chart:{ type:"column" }, title: { text: 'Share of Fatal Accidents by Risk Category' }, subtitle: { text: 'Scheduled Commercial flights on airplanes above 5.7t only' }, xAxis: { categories: cat }, plotOptions: { series: { stacking: 'percent' } }, yAxis: { min:0, labels:{format:"{value}%"}, title: { text: 'Fatal Accidents' } }, series: [] } var riskfatalities={ chart: { animation: false }, credits:{ enabled:false }, title: { text: 'Fatalities by Risk Category' }, subtitle: { text: 'Scheduled Commercial flights on airplanes above 5.7t only' }, xAxis: { categories: cat }, yAxis: { min:0, title: { text: 'Fatalities' } }, series: [] } var accidents={ chart: { animation: false }, credits:{ enabled:false }, title: { text: 'Accidents' }, subtitle: { text: 'Scheduled Commercial flights on airplanes above 5.7t only' }, xAxis: { categories: cat }, yAxis: { min:0, title: { text: 'Accidents' } }, series: [] } var fatalities={ chart: { animation: false }, credits:{ enabled:false }, title: { text: 'Fatalities' }, subtitle: { text: 'Scheduled Commercial flights on airplanes above 5.7t only' }, xAxis: { categories: cat }, yAxis: { min:0, title: { text: 'Fatalities' } }, series: [] } var riskcomb5={ chart: { animation: false }, credits:{ enabled:false }, chart:{ type:"bar" }, title: { text: 'Risk Distribution' }, subtitle: { text: 'Scheduled Commercial flights on airplanes above 5.7t '+(lastyear-4)+"-"+lastyear }, xAxis: { categories: ["RS","LOC-I","CFIT"] }, yAxis: { min:0, labels:{format:"{value}%"}, title: { text: 'Relative Risk Importance (%)' } }, series: [{color:"orange",name:"Fatalities",data:[]}, {color:"lightblue",name:"Fatal Accidents",data:[]}, {color:"blue",name:"Accidents",data:[]} ] } var yearcum={ chart: { animation: false }, credits:{ enabled:false }, chart:{ zoomType: 'x' }, title: { text: 'Accidents Year-to-date' }, subtitle: { text: 'Scheduled Commercial flights on airplanes above 5.7t only' }, xAxis: { type:"datetime" }, yAxis: { min:0, title: { text: 'Cumulative Accidents' } }, series: [{type:"area",color:"lightgray",name:"Last year",data:[]}, {color:"black",lineWidth:4,name:"Current year",id:"currentyear",data:[]}, {y:-50,name:"Current year fatalities",color:"darkred",type:"flags",shape:"flag",onSeries:"currentyear",data:[]} ] } $("#groupsel").change(function(e){ e.preventDefault() var group=$("#groupsel").val() if (group=="518a8adc9a6a436858000001") { group="" } $.getJSON("https://v4p4sz5ijk.execute-api.us-east-1.amazonaws.com/anbdata/states/accidents/aggregated-stateofoccurrence-stats?callback=?", {api_key:"fbbe6ba0-16ae-11e6-82b4-13b5d4bbe6a0", states:group, format:"json" },function(res){ //stats=JSON.parse(res) stats=res $.getJSON("https://v4p4sz5ijk.execute-api.us-east-1.amazonaws.com/anbdata/states/accidents/aggregated-stateofoccurrence-stats?callback=?", {api_key:"fbbe6ba0-16ae-11e6-82b4-13b5d4bbe6a0", states:group, format:"json",Risk:"RS" },function(res){ //RS=JSON.parse(res) RS=res $.getJSON("https://v4p4sz5ijk.execute-api.us-east-1.amazonaws.com/anbdata/states/accidents/aggregated-stateofoccurrence-stats?callback=?", {api_key:"fbbe6ba0-16ae-11e6-82b4-13b5d4bbe6a0", states:group, format:"json",Risk:"CFIT" },function(res){ //CFIT=JSON.parse(res) CFIT=res $.getJSON("https://v4p4sz5ijk.execute-api.us-east-1.amazonaws.com/anbdata/states/accidents/aggregated-stateofoccurrence-stats?callback=?", {api_key:"fbbe6ba0-16ae-11e6-82b4-13b5d4bbe6a0", states:group, format:"json",Risk:"LOC-I" },function(res){ //LOCI=JSON.parse(res) LOCI=res $.getJSON("https://v4p4sz5ijk.execute-api.us-east-1.amazonaws.com/anbdata/occurrences/official/accidents?callback=?", {api_key:"fbbe6ba0-16ae-11e6-82b4-13b5d4bbe6a0", StateOfOccurrence:group, format:"json" },function(res){ //accidentdata=JSON.parse(res) accidentdata=res console.log(accidentdata) redraw() $("#submitform").trigger("click") }) }) }) }) }) }) var statedata $.getJSON("https://v4p4sz5ijk.execute-api.us-east-1.amazonaws.com/anbdata/states/accidents/flat-stateofoccurrence-stats?callback=?&api_key=fbbe6ba0-16ae-11e6-82b4-13b5d4bbe6a0&states=&format=json&Risk=", function(res){ //console.log(res) //statedata=JSON.parse(res) statedata=res //console.log(statedata) redraw() $("#submitform").trigger("click") } ) function redraw(){ var name=$("#groupsel option:selected").text() if (name=="World") { worlddata=[] } yearcum.series[2]= {y:-50,name:"Current year fatalities",color:"darkred",type:"flags",shape:"flag",onSeries:"currentyear",data:[]} var cat=[],data=[],data2=[],data3=[],rsdata=[],cfitdata=[],locidata=[],rsdata2=[],cfitdata2=[],locidata2=[], rsdata3=[],cfitdata3=[],locidata3=[],otherdata3=[] for (var i=2008;i<new Date().getUTCFullYear();i++) { cat.push(i) var a=stats.filter(function(d){return d.Year==i})[0] data.push((a?Math.round(100*a.AccidentRate)/100:0)) if (name=="World") { worlddata.push((a?Math.round(100*a.AccidentRate)/100:0)) } data2.push((a?a.Accidents:0)) data3.push((a?a.Fatalities:0)) var rs=RS.filter(function(d){return d.Year==i})[0] var cfit=CFIT.filter(function(d){return d.Year==i})[0] var loci=LOCI.filter(function(d){return d.Year==i})[0] rsdata.push((rs?rs.Accidents:0)) cfitdata.push((cfit?cfit.Accidents:0)) locidata.push((loci?loci.Accidents:0)) rsdata3.push((rs?rs.FatalAccidents:0)) cfitdata3.push((cfit?cfit.FatalAccidents:0)) locidata3.push((loci?loci.FatalAccidents:0)) otherdata3.push((a?a.FatalAccidents:0) -rsdata3[rsdata3.length-1] -cfitdata3[cfitdata3.length-1] -locidata3[locidata3.length-1]) rsdata2.push((rs?rs.Fatalities:0)) cfitdata2.push((cfit?cfit.Fatalities:0)) locidata2.push((loci?loci.Fatalities:0)) } var fatrisk=[0,0,0],fataccrisk=[0,0,0],accrisk=[0,0,0],total=[0,0,0] for (var i=lastyear-4;i<=lastyear;i++) { var a=stats.filter(function(d){return d.Year==i})[0] total[0]+=(a?a.Fatalities:0) total[1]+=(a?a.FatalAccidents:0) total[2]+=(a?a.Accidents:0) var rs=RS.filter(function(d){return d.Year==i})[0] var cfit=CFIT.filter(function(d){return d.Year==i})[0] var loci=LOCI.filter(function(d){return d.Year==i})[0] fatrisk[0]+=(rs?rs.Fatalities:0) fatrisk[1]+=(loci?loci.Fatalities:0) fatrisk[2]+=(cfit?cfit.Fatalities:0) fataccrisk[0]+=(rs?rs.FatalAccidents:0) fataccrisk[1]+=(loci?loci.FatalAccidents:0) fataccrisk[2]+=(cfit?cfit.FatalAccidents:0) accrisk[0]+=(rs?rs.Accidents:0) accrisk[1]+=(loci?loci.Accidents:0) accrisk[2]+=(cfit?cfit.Accidents:0) } riskcomb5.series[0].data=[Math.round(100*fatrisk[0]/total[0]),Math.round(100*fatrisk[1]/total[0]),Math.round(100*fatrisk[2]/total[0])] riskcomb5.series[1].data=[Math.round(100*fataccrisk[0]/total[1]),Math.round(100*fataccrisk[1]/total[1]),Math.round(100*fataccrisk[2]/total[1])] riskcomb5.series[2].data=[Math.round(100*accrisk[0]/total[2]),Math.round(100*accrisk[1]/total[2]),Math.round(100*accrisk[2]/total[2])] $("#riskcomb5").highcharts(riskcomb5) var acc=0,dates=[new Date(currentyear,11,31).getTime(),new Date(currentyear,0,1).getTime()], accarr=[[new Date(currentyear,11,31).getTime(),0],[new Date(currentyear,0,1).getTime(),0]] accidentdata.filter(function(d){return d.Year==lastyear}).forEach(function(v){ var val=new Date(currentyear+v.Date.substring(4)).getTime() if (dates.indexOf(val)<0) { dates.push(val) accarr.push([val,1]) } else { accarr.filter(function(d){return d[0]==val})[0][1]++ } }) var n=0 yearcum.series[0].data=[] dates.sort().forEach(function(val){ n+=accarr.filter(function(d){return d[0]==val})[0][1] yearcum.series[0].data.push([val,n]) }) acc=0,dates=[new Date(new Date().toISOString().substring(0,10)).getTime(),new Date(currentyear,0,1).getTime()], accarr=[[new Date(new Date().toISOString().substring(0,10)).getTime(),0],[new Date(currentyear,0,1).getTime(),0]] accidentdata.filter(function(d){return d.Year==currentyear}).forEach(function(v){ var val=Math.floor(new Date(v.Date).getTime()) if (dates.indexOf(val)<0) { dates.push(val) accarr.push([val,1]) } else { accarr.filter(function(d){return d[0]==val})[0][1]++ } }) var n=0 yearcum.series[1].data=[] dates.sort().forEach(function(val){ n+=accarr.filter(function(d){return d[0]==val})[0][1] var fats=0 accidentdata.filter(function(d){return (new Date(d.Date).getTime()==val)}).forEach(function(v){ if(v.Fatalities !="") fats+=v.Fatalities }) yearcum.series[1].data.push([val,n]) if (fats>0) { yearcum.series[2].data.push({x:val,title:fats+"",text:fats+" fatalities"}) } }) //console.log(dates); //console.log(yearcum.series[1].data); var di=yearcum.series[1].data.length-1 yearcum.series[1].data[di]={x:yearcum.series[1].data[di][0], y:yearcum.series[1].data[di][1], dataLabels:{enabled:true} } statedist.series[0].data=[] statedata.filter(function(d){return (d.Year==2015)}).forEach(function(v){ if (v.Departures>0){ statedist.series[0].data.push([v.Departures,v.Accidents])} }) statedist.series[1].data=[[1,2.79/100000],[1000000,2.79]] data[data.length-1]={y:data[data.length-1],dataLabels:{enabled:true}} data2[data2.length-1]={y:data2[data2.length-1],dataLabels:{enabled:true}} data3[data3.length-1]={y:data3[data3.length-1],dataLabels:{enabled:true}} console.log(yearcum.series[2].data) console.log(yearcum.series[1].data) accidentrate.series=[] accidents.series=[] fatalities.series=[] riskaccidents.series=[] riskfatalities.series=[] riskaccidentscumm.series=[] accidentrate.series.push({name:name,data:data}) if (name!="World") { accidentrate.series.push({name:"World",color:"gray",data:worlddata}) } accidents.series.push({name:name,data:data2}) fatalities.series.push({name:name,data:data3}) riskaccidents.series.push({name:"Runway Safety",data:rsdata}) riskaccidents.series.push({name:"CFIT",data:cfitdata}) riskaccidents.series.push({name:"LOC-I",data:locidata}) riskfatalities.series.push({name:"Runway Safety",data:rsdata2}) riskfatalities.series.push({name:"CFIT",data:cfitdata2}) riskfatalities.series.push({name:"LOC-I",data:locidata2}) riskaccidentscumm.series.push({name:"Runway Safety",data:rsdata3}) riskaccidentscumm.series.push({name:"CFIT",data:cfitdata3}) riskaccidentscumm.series.push({name:"LOC-I",data:locidata3}) riskaccidentscumm.series.push({name:"Other",data:otherdata3}) $("#accidentrate").highcharts(accidentrate) $("#accidents").highcharts(accidents) $("#fatalities").highcharts(fatalities) $("#riskaccidents").highcharts(riskaccidents) $("#riskfatalities").highcharts(riskfatalities) $("#riskcomparison").highcharts(riskaccidentscumm) $("#yearcum").highcharts(yearcum) $("#statedist").highcharts(statedist) } $("#qform button").click(function(e){ e.preventDefault() $(this).closest(".btn-group").find("button").removeClass("active") $(this).addClass("active") }) $("#submitform").click(function(e){ e.preventDefault() $("#loading").show() $("#submitform").prop('disabled', true) buildqstring(function(q){ $.getJSON("https://v4p4sz5ijk.execute-api.us-east-1.amazonaws.com/anbdata/occurrences/class/querystring?callback=?", {api_key:"7c3cb620-ed23-11e5-a5f9-adff4fb3e3e1",format:"html", querystring:JSON.stringify(q)}, function(thedata){ $("#datatable").html(thedata.html) $("a.occurrence").click(function(e){ e.preventDefault() var id=$(this).attr("occurrence") $("#"+id).find(".short").hide() $("#"+id).find(".long").show() }) $("button.hidenarrative").click(function(e){ e.preventDefault() var id=$(this).attr("occurrence") $("#"+id).find(".short").show() $("#"+id).find(".long").hide() }) $("#thetable").dataTable({"order": [[ 0, "desc" ]]}) $("#loading").hide() $("#submitform").prop('disabled', false) } ) }) }) function buildqstring(next){ if ($("#groupsel").val().length>3) { $.getJSON("https://v4p4sz5ijk.execute-api.us-east-1.amazonaws.com/anbdata/services/groupcomp?callback=?",{group:$("#groupsel").val()},function(gcomp){ var q={} if ($("#groupsel option:selected").text()!="World") { q[$("#state button.active").attr("value")]={$in:gcomp.Composition} } if ($("#aircraft button.active").attr("value")!="") {jQuery.extend(q,JSON.parse($("#aircraft button.active").attr("value")))} if ($("#scheduled button.active").attr("value")!="") {jQuery.extend(q,JSON.parse($("#scheduled button.active").attr("value")))} if ($("#over57 button.active").attr("value")!="") {jQuery.extend(q,JSON.parse($("#over57 button.active").attr("value")))} if ($("#accidents button.active").attr("value")!="") {jQuery.extend(q,JSON.parse($("#accidents button.active").attr("value")))} if ($("#fatal button.active").attr("value")!="") {jQuery.extend(q,JSON.parse($("#fatal button.active").attr("value")))} if ($("#risk button.active").attr("value")!="") {jQuery.extend(q,JSON.parse($("#risk button.active").attr("value")))} q.Year={$gte:Number($("#year select.from").val()),$lte:Number($("#year select.to").val())} if ($("#official button.active").attr("value")!="") {q["$or"]=[{Official:true},{Year:currentyear}]} next(q) }) } else { var q={} if ($("#groupsel option:selected").text()!="World") { q[$("#state button.active").attr("value")]=$("#groupsel").val() } if ($("#aircraft button.active").attr("value")!="") {jQuery.extend(q,JSON.parse($("#aircraft button.active").attr("value")))} if ($("#scheduled button.active").attr("value")!="") {jQuery.extend(q,JSON.parse($("#scheduled button.active").attr("value")))} if ($("#over57 button.active").attr("value")!="") {jQuery.extend(q,JSON.parse($("#over57 button.active").attr("value")))} if ($("#accidents button.active").attr("value")!="") {jQuery.extend(q,JSON.parse($("#accidents button.active").attr("value")))} if ($("#fatal button.active").attr("value")!="") {jQuery.extend(q,JSON.parse($("#fatal button.active").attr("value")))} if ($("#risk button.active").attr("value")!="") {jQuery.extend(q,JSON.parse($("#risk button.active").attr("value")))} q.Year={$gte:Number($("#year select.from").val()),$lte:Number($("#year select.to").val())} if ($("#official button.active").attr("value")!="") {q["$or"]=[{Official:true},{Year:currentyear}]} next(q) } }

Data on Groups

Variable name groups

Send to Javascript

Data file URL :


HTML Preview

Open in new window