1212
1313< body >
1414 < ul class ="navigationBar ">
15- < li > < a href ="/Mainpages/ index.html "> Home</ a > </ li >
16- < li > < a href ="/Mainpages/ mapping.html "> Open Data</ a > </ li >
17- < li class ="right "> < a href ="/Mainpages/ about.html "> About us </ a > </ li >
15+ < li > < a href ="/index.html "> Home</ a > </ li >
16+ < li > < a href ="/mapping.html "> Open Data</ a > </ li >
17+ < li class ="right "> < a href ="/about.html "> About</ a > </ li >
1818 </ ul >
1919
2020 < div class =mappingTitle >
@@ -76,6 +76,7 @@ <h1>Welcome to the Death Data visualization Page!</h1>
7676 < script >
7777 const DeathChartTotalData = '/Datasets/Deaths-Gender-Eng-Wal-1992-2024.csv'
7878 d3 . csv ( DeathChartTotalData ) . then ( function ( datapoints ) {
79+ // Prep the variables and then push data into them.
7980 const totalDeaths = [ ] ;
8081 const deathYear = [ ] ;
8182 const maleDeaths = [ ] ;
@@ -88,7 +89,7 @@ <h1>Welcome to the Death Data visualization Page!</h1>
8889 femaleDeaths . push ( datapoints [ i ] [ 'Females' ] )
8990 } ;
9091
91-
92+ // prep the data for our chart
9293 const deathDataTotal = {
9394 labels : deathYear ,
9495 datasets : [ {
@@ -99,6 +100,7 @@ <h1>Welcome to the Death Data visualization Page!</h1>
99100 tension : 0.1 ,
100101 } ]
101102 }
103+ // draw the chart
102104 const deathRateTotal = new Chart ( deathTot , {
103105 type : 'line' ,
104106 data : deathDataTotal ,
@@ -200,12 +202,13 @@ <h1>Welcome to the Death Data visualization Page!</h1>
200202 maleDeaths . push ( datapoints [ i ] . Males )
201203 femaleDeaths . push ( datapoints [ i ] . Females )
202204 }
203- console . log ( region )
204- console . log ( maleDeaths )
205- console . log ( femaleDeaths )
205+ // **previously had an error with this section, uncomment if logs are needed.
206+ //console.log(region)
207+ //console.log(maleDeaths)
208+ //console.log(femaleDeaths)
206209 const regionLabels = region ;
207210 const deathRegionData = {
208-
211+ // two datasets are needed as the graph used requires two bars, chart.js provides this natively.
209212 labels : regionLabels ,
210213 datasets : [ {
211214 label : 'Male Deaths' ,
@@ -230,7 +233,7 @@ <h1>Welcome to the Death Data visualization Page!</h1>
230233 borderWidth : 1
231234 } ]
232235 } ;
233-
236+ // dual bar-chart instead of line chart
234237 const deathRateRegionChart = new Chart ( deathReg , {
235238 type : 'bar' ,
236239 data : deathRegionData ,
@@ -254,6 +257,7 @@ <h1>Welcome to the Death Data visualization Page!</h1>
254257 } )
255258
256259 } )
260+ // get elementID for drawing chart.
257261 const deathReg = document . getElementById ( 'deathByRegion' ) ;
258262
259263 </ script >
0 commit comments