99 fluViewRegions ,
1010 gftLocations ,
1111 ghtLocations ,
12- nidssDenqueLocations ,
12+ nidssDengueLocations ,
1313 nidssFluLocations ,
1414 nowcastLocations ,
1515 quidelLocations ,
@@ -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 [ ] = [ ] ;
@@ -91,7 +93,11 @@ function loadEpidata(
9193 }
9294 points . push ( new EpiPoint ( date , row [ col ] as number ) ) ;
9395 }
94- datasets . push ( new DataSet ( points , col , params ) ) ;
96+ if ( points . length > 0 ) {
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 ) ) ;
100+ }
95101 }
96102 return new DataGroup ( name , datasets ) ;
97103}
@@ -112,6 +118,7 @@ export function loadDataSet(
112118 fixedParams : Record < string , unknown > ,
113119 userParams : Record < string , unknown > ,
114120 columns : string [ ] ,
121+ columnRenamings : Record < string , string > = { } ,
115122) : Promise < DataGroup | null > {
116123 const duplicates = get ( expandedDataGroups ) . filter ( ( d ) => d . title == title ) ;
117124 if ( duplicates . length > 0 ) {
@@ -135,7 +142,18 @@ export function loadDataSet(
135142 url . searchParams . set ( 'format' , 'json' ) ;
136143 return fetchImpl < Record < string , unknown > [ ] > ( url )
137144 . then ( ( res ) => {
138- return loadEpidata ( title , res , columns , { _endpoint : endpoint , ...params } ) ;
145+ const data = loadEpidata ( title , res , columns , columnRenamings , { _endpoint : endpoint , ...params } ) ;
146+ if ( data . datasets . length == 0 ) {
147+ return UIkit . modal
148+ . alert (
149+ `
150+ <div class="uk-alert uk-alert-error">
151+ <a href="${ url . href } ">API Link</a> returned no data.
152+ </div>` ,
153+ )
154+ . then ( ( ) => null ) ;
155+ }
156+ return data ;
139157 } )
140158 . catch ( ( error ) => {
141159 console . warn ( 'failed fetching data' , error ) ;
@@ -318,7 +336,7 @@ export function importFluView({
318336 auth ?: string ;
319337} ) : Promise < DataGroup | null > {
320338 const regionLabel = fluViewRegions . find ( ( d ) => d . value === regions ) ?. label ?? '?' ;
321- const title = appendIssueToTitle ( `[API] FluView: ${ regionLabel } ` , { issues, lag } ) ;
339+ const title = appendIssueToTitle ( `[API] ILINet (aka FluView) : ${ regionLabel } ` , { issues, lag } ) ;
322340 return loadDataSet (
323341 title ,
324342 'fluview' ,
@@ -339,6 +357,10 @@ export function importFluView({
339357 'num_age_4' ,
340358 'num_age_5' ,
341359 ] ,
360+ {
361+ wili : '%wILI' ,
362+ ili : '%ILI' ,
363+ } ,
342364 ) ;
343365}
344366
@@ -378,9 +400,9 @@ export function importGHT({
378400 ) ;
379401}
380402
381- export function importNIDSSDenque ( { locations } : { locations : string } ) : Promise < DataGroup | null > {
382- const regionLabel = nidssDenqueLocations . find ( ( d ) => d . value === locations ) ?. label ?? '?' ;
383- const title = `[API] NIDSS-Denque : ${ regionLabel } ` ;
403+ export function importNIDSSDengue ( { locations } : { locations : string } ) : Promise < DataGroup | null > {
404+ const regionLabel = nidssDengueLocations . find ( ( d ) => d . value === locations ) ?. label ?? '?' ;
405+ const title = `[API] NIDSS-Dengue : ${ regionLabel } ` ;
384406 return loadDataSet (
385407 title ,
386408 'nidss_dengue' ,
0 commit comments