diff --git a/src/api/EpiData.ts b/src/api/EpiData.ts index 866063e..b059736 100644 --- a/src/api/EpiData.ts +++ b/src/api/EpiData.ts @@ -91,7 +91,9 @@ function loadEpidata( } points.push(new EpiPoint(date, row[col] as number)); } - datasets.push(new DataSet(points, col, params)); + if (points.length > 0) { + datasets.push(new DataSet(points, col, params)); + } } return new DataGroup(name, datasets); } @@ -135,7 +137,18 @@ export function loadDataSet( url.searchParams.set('format', 'json'); return fetchImpl[]>(url) .then((res) => { - return loadEpidata(title, res, columns, { _endpoint: endpoint, ...params }); + const data = loadEpidata(title, res, columns, { _endpoint: endpoint, ...params }); + if (data.datasets.length == 0) { + return UIkit.modal + .alert( + ` +
+ API Link returned no data. +
`, + ) + .then(() => null); + } + return data; }) .catch((error) => { console.warn('failed fetching data', error);