@@ -64,9 +64,11 @@ function loadEpidata(
6464 name : string ,
6565 epidata : Record < string , unknown > [ ] ,
6666 columns : string [ ] ,
67+ columnRenamings : Record < string , string > ,
6768 params : Record < string , unknown > ,
6869) : DataGroup {
6970 const datasets : DataSet [ ] = [ ] ;
71+ const colRenamings = new Map ( Object . entries ( columnRenamings ) ) ;
7072
7173 for ( const col of columns ) {
7274 const points : EpiPoint [ ] = [ ] ;
@@ -92,7 +94,9 @@ function loadEpidata(
9294 points . push ( new EpiPoint ( date , row [ col ] as number ) ) ;
9395 }
9496 if ( points . length > 0 ) {
95- datasets . push ( new DataSet ( points , col , params ) ) ;
97+ // overwrite default column name if there's an overwrite in columnRenamings
98+ const title = colRenamings . has ( col ) ? colRenamings . get ( col ) : col ;
99+ datasets . push ( new DataSet ( points , title , params ) ) ;
96100 }
97101 }
98102 return new DataGroup ( name , datasets ) ;
@@ -114,6 +118,7 @@ export function loadDataSet(
114118 fixedParams : Record < string , unknown > ,
115119 userParams : Record < string , unknown > ,
116120 columns : string [ ] ,
121+ columnRenamings : Record < string , string > = { } ,
117122) : Promise < DataGroup | null > {
118123 const duplicates = get ( expandedDataGroups ) . filter ( ( d ) => d . title == title ) ;
119124 if ( duplicates . length > 0 ) {
@@ -137,7 +142,7 @@ export function loadDataSet(
137142 url . searchParams . set ( 'format' , 'json' ) ;
138143 return fetchImpl < Record < string , unknown > [ ] > ( url )
139144 . then ( ( res ) => {
140- const data = loadEpidata ( title , res , columns , { _endpoint : endpoint , ...params } ) ;
145+ const data = loadEpidata ( title , res , columns , columnRenamings , { _endpoint : endpoint , ...params } ) ;
141146 if ( data . datasets . length == 0 ) {
142147 return UIkit . modal
143148 . alert (
@@ -331,7 +336,7 @@ export function importFluView({
331336 auth ?: string ;
332337} ) : Promise < DataGroup | null > {
333338 const regionLabel = fluViewRegions . find ( ( d ) => d . value === regions ) ?. label ?? '?' ;
334- const title = appendIssueToTitle ( `[API] FluView: ${ regionLabel } ` , { issues, lag } ) ;
339+ const title = appendIssueToTitle ( `[API] ILINet (aka FluView) : ${ regionLabel } ` , { issues, lag } ) ;
335340 return loadDataSet (
336341 title ,
337342 'fluview' ,
@@ -352,6 +357,10 @@ export function importFluView({
352357 'num_age_4' ,
353358 'num_age_5' ,
354359 ] ,
360+ {
361+ wili : '%wILI' ,
362+ ili : '%ILI' ,
363+ } ,
355364 ) ;
356365}
357366
0 commit comments