@@ -13,13 +13,13 @@ function fetchDataAndRender(dataFormat) {
1313
1414 //sort data alphabetically
1515 let sortedResult = [ ...tidy ] . sort ( ( a , b ) => {
16- return a . death . localeCompare ( b . death ) ;
16+ return a . name . localeCompare ( b . name ) ;
1717 } ) ;
1818
1919 //check if "remove plague" is checked; if so remove plague from tidy and sorted data
2020 //make the graphs
2121 let checkbox = document . getElementById ( "plague" ) ;
22- let noPlague = sortedResult . filter ( ( d ) => d . death != "plague" ) ;
22+ let noPlague = sortedResult . filter ( ( d ) => d . name != "plague" ) ;
2323 d3 . select ( "#facets" ) . selectAll ( "*" ) . remove ( ) ;
2424 if ( checkbox . checked ) {
2525 makeGraphs ( dataFormat , checkbox , noPlague ) ;
@@ -68,12 +68,12 @@ function tidyFormat(data) {
6868
6969 // Accumulate totals using Map with composite key
7070 for ( const item of data ) {
71- const key = `${ item . year } -${ item . death } ` ;
71+ const key = `${ item . year } -${ item . name } ` ;
7272
7373 if ( ! resultMap . has ( key ) ) {
7474 resultMap . set ( key , {
7575 year : item . year ,
76- death : item . death ,
76+ name : item . name ,
7777 count : 0 ,
7878 } ) ;
7979 }
@@ -90,7 +90,7 @@ function makeGraphs(dataFormat, countType, data) {
9090 const plot = Plot . plot (
9191 ( ( ) => {
9292 const n = 5 ; // number of facet columns
93- const keys = Array . from ( d3 . union ( data . map ( ( d ) => d . death ) ) ) ;
93+ const keys = Array . from ( d3 . union ( data . map ( ( d ) => d . name ) ) ) ;
9494 const index = new Map ( keys . map ( ( key , i ) => [ key , i ] ) ) ;
9595 const fx = ( key ) => index . get ( key ) % n ;
9696 const fy = ( key ) => Math . floor ( index . get ( key ) / n ) ;
@@ -119,8 +119,8 @@ function makeGraphs(dataFormat, countType, data) {
119119 Plot . normalizeY ( "mean" , {
120120 x : "year" ,
121121 y : "count" ,
122- fx : ( d ) => fx ( d . death ) ,
123- fy : ( d ) => fy ( d . death ) ,
122+ fx : ( d ) => fx ( d . name ) ,
123+ fy : ( d ) => fy ( d . name ) ,
124124 fill : "red" ,
125125 stroke : "red" ,
126126 tip : {
@@ -136,8 +136,8 @@ function makeGraphs(dataFormat, countType, data) {
136136 ? Plot . barY ( data , {
137137 x : "year" ,
138138 y : ( d ) => Math . log10 ( d . count + 1 ) ,
139- fx : ( d ) => fx ( d . death ) ,
140- fy : ( d ) => fy ( d . death ) ,
139+ fx : ( d ) => fx ( d . name ) ,
140+ fy : ( d ) => fy ( d . name ) ,
141141 fill : "red" ,
142142 stroke : "red" ,
143143 tip : {
@@ -151,8 +151,8 @@ function makeGraphs(dataFormat, countType, data) {
151151 : Plot . barY ( data , {
152152 x : "year" ,
153153 y : "count" ,
154- fx : ( d ) => fx ( d . death ) ,
155- fy : ( d ) => fy ( d . death ) ,
154+ fx : ( d ) => fx ( d . name ) ,
155+ fy : ( d ) => fy ( d . name ) ,
156156 fill : "red" ,
157157 stroke : "red" ,
158158 tip : {
0 commit comments