@@ -64,9 +64,11 @@ function loadEpidata(
64
64
name : string ,
65
65
epidata : Record < string , unknown > [ ] ,
66
66
columns : string [ ] ,
67
+ columnRenamings : Record < string , string > ,
67
68
params : Record < string , unknown > ,
68
69
) : DataGroup {
69
70
const datasets : DataSet [ ] = [ ] ;
71
+ const colRenamings = new Map ( Object . entries ( columnRenamings ) ) ;
70
72
71
73
for ( const col of columns ) {
72
74
const points : EpiPoint [ ] = [ ] ;
@@ -92,7 +94,9 @@ function loadEpidata(
92
94
points . push ( new EpiPoint ( date , row [ col ] as number ) ) ;
93
95
}
94
96
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 ) ) ;
96
100
}
97
101
}
98
102
return new DataGroup ( name , datasets ) ;
@@ -114,6 +118,7 @@ export function loadDataSet(
114
118
fixedParams : Record < string , unknown > ,
115
119
userParams : Record < string , unknown > ,
116
120
columns : string [ ] ,
121
+ columnRenamings : Record < string , string > = { } ,
117
122
) : Promise < DataGroup | null > {
118
123
const duplicates = get ( expandedDataGroups ) . filter ( ( d ) => d . title == title ) ;
119
124
if ( duplicates . length > 0 ) {
@@ -137,7 +142,7 @@ export function loadDataSet(
137
142
url . searchParams . set ( 'format' , 'json' ) ;
138
143
return fetchImpl < Record < string , unknown > [ ] > ( url )
139
144
. then ( ( res ) => {
140
- const data = loadEpidata ( title , res , columns , { _endpoint : endpoint , ...params } ) ;
145
+ const data = loadEpidata ( title , res , columns , columnRenamings , { _endpoint : endpoint , ...params } ) ;
141
146
if ( data . datasets . length == 0 ) {
142
147
return UIkit . modal
143
148
. alert (
@@ -331,7 +336,7 @@ export function importFluView({
331
336
auth ?: string ;
332
337
} ) : Promise < DataGroup | null > {
333
338
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 } ) ;
335
340
return loadDataSet (
336
341
title ,
337
342
'fluview' ,
@@ -352,6 +357,10 @@ export function importFluView({
352
357
'num_age_4' ,
353
358
'num_age_5' ,
354
359
] ,
360
+ {
361
+ wili : '%wILI' ,
362
+ ili : '%ILI' ,
363
+ } ,
355
364
) ;
356
365
}
357
366
0 commit comments