Published
Edited
Feb 2, 2021
2 forks
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
IllinoisCumulativeCovidChartEN = IllinoisCovidChart(
["confirmed_cases_minus_deaths", "deaths"],
"en",
160
)
Insert cell
IllinoisNewCaseCovidChartEN = IllinoisCovidChart(
["confirmed_cases_change", "deaths_change"],
"en",
90
)
Insert cell
IllinoisCumulativeCovidChartES = IllinoisCovidChart(
["confirmed_cases_minus_deaths", "deaths"],
"es",
160
)
Insert cell
IllinoisNewCaseCovidChartES = IllinoisCovidChart(
["confirmed_cases_change", "deaths_change"],
"es",
90
)
Insert cell
Insert cell
maxWidth = 700
Insert cell
graphicWidth = width >= maxWidth ? maxWidth : 500
Insert cell
height = 400
Insert cell
Insert cell
Insert cell
Insert cell
dateRangeDivided = [
IllnoisDailyCovidCountsFiltered[0].date,
IllnoisDailyCovidCountsFiltered[
Math.floor(IllnoisDailyCovidCountsFiltered.length / 4)
].date,
IllnoisDailyCovidCountsFiltered[
Math.floor(IllnoisDailyCovidCountsFiltered.length / 2)
].date,
IllnoisDailyCovidCountsFiltered[
Math.floor((3 * IllnoisDailyCovidCountsFiltered.length) / 4)
].date,
IllnoisDailyCovidCountsFiltered[IllnoisDailyCovidCountsFiltered.length - 1]
.date
]
Insert cell
line = d3.line()
Insert cell
//height = 400
Insert cell
margin = ({ top: 20, right: 40, bottom: 30, left: 70 })
Insert cell
Insert cell
Insert cell
Insert cell
DataLastUpdated = new Date(IllnoisDailyCovidCountsFiltered.slice(-1)[0].date)
Insert cell
IllnoisDailyCovidCountsFiltered = {
const query = `
query getStateTestingResults($startDate: date!) {
state_testing_results_change(order_by: {date: asc}, where:{date:{_gte:$startDate}}) {
date
confirmed_cases
confirmed_cases_change
confirmed_cases_change_pct
confirmed_cases_minus_deaths
deaths
deaths_change
deaths_change_pct
total_tested
total_tested_change
total_tested_change_pct
}
state_testing_results_change_aggregate {
aggregate {
max {
date
}
}
}
}
`;

return graphql({
query,
operation: "getStateTestingResults",
variables: {
startDate
}
}).then(({ state_testing_results_change }) =>
state_testing_results_change.map(
({ date, confirmed_cases_change, ...row }) => ({
...row,
// The state changed how it reports out cases, including probable in the count starting on 11/6,
// so we're manually modifying the change number here (since it was from a backlog of cases), but
// leaving the total as of that date in place to match the state's overall numbers
// http://www.dph.illinois.gov/news/public-health-officials-announce-10376-new-confirmed-cases-coronavirus-disease
confirmed_cases_change:
date === "2020-11-06" ? 10376 : confirmed_cases_change,
dateString: date,
date: new Date(date)
})
)
);
}
Insert cell
Insert cell
lodash = require("lodash")
Insert cell
Insert cell
import { messageFormatter } with {
translations
} from "@chicagoreporter/formatjs-helpers"
Insert cell
import { IllinoisDailyCovidCounts } from "@chicagoreporter/coronavirus-illinois-historical-counts"
Insert cell
d3 = require("d3", "d3-array")
Insert cell
import { date, select, color } from "@jashkenas/inputs"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more