Skip to content

Commit

Permalink
fix(ca-dashboard): covid chart breaks if no data points are returned (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wallace41290 authored Aug 9, 2021
1 parent 23d60fe commit 96d1632
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/examples/ca-dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { MDCFormField } from '@material/form-field';
import { MDCRadio } from '@material/radio';

import { AmchartsDataSet, HttpResponse } from '@rds/sdk';

import {
AmChartsClusteredBarUtil,
AmChartsLineUtil,
Expand All @@ -13,9 +11,9 @@ import {
import { SelectUtil } from '~/shared/material/select.util';

import { MONTH_NAMES, PROVINCES } from './constants';
import { LabourData, LABOUR_CHART_ELEMENT_ID, LABOUR_SETUP, canadaLabour } from './labour-constants';
import { PERSPECTIVES, canadaPerspective, PERCEIVED_SETUP } from './perspective-constants';
import { COVID_TAB_SETUP, canadaCovid, CovidData, COVID_CHART_ELEMENT_ID } from './covid-constants';
import { canadaCovid, COVID_CHART_ELEMENT_ID, COVID_TAB_SETUP, CovidData } from './covid-constants';
import { canadaLabour, LABOUR_CHART_ELEMENT_ID, LABOUR_SETUP, LabourData } from './labour-constants';
import { canadaPerspective, PERCEIVED_SETUP, PERSPECTIVES } from './perspective-constants';

let selectedBar = 'clustered';
let selectedProvince = 'all';
Expand Down Expand Up @@ -191,7 +189,8 @@ function getCovidData(province: string) {
.then((res: HttpResponse<AmchartsDataSet>) => {
const covidData: CovidData[] = res && res.parsedBody ? res?.parsedBody?.dataProvider : [];

currentMonth = MONTH_NAMES[new Date(covidData[covidData.length - 1]['date_stamp']).getMonth()];
const monthIndex = covidData.length ? new Date(covidData[covidData.length - 1]['date_stamp']).getMonth() : 0;
currentMonth = MONTH_NAMES[monthIndex];

let titleUrl = `https://covid19.richdataservices.com/rds-tabengine/analysis/ca/ca_gov_cases/custom-tables;showTotals=true,true,true,true;sortRows=VALUE,ASC;sortCols=NAME,DESC;filterEmpty=true?rows=date_stamp&measure=cnt_confirmed:SUM(cnt_confirmed)`;

Expand Down

0 comments on commit 96d1632

Please sign in to comment.