Public
Edited
May 3, 2023
1 fork
1 star
Insert cell
Insert cell
Insert cell
madatdata = import("https://esm.sh/@madatdata/core@0.0.10")
Insert cell
client = madatdata.makeSplitgraphHTTPContext({credential: null}).client;
Insert cell
result = await client.execute(`
select
to_date(date, 'MM/DD/YYYY') as raw_date,
date_part('year', to_date(date, 'MM/DD/YYYY')) || '-' ||
date_part('week', to_date(date, 'MM/DD/YYYY')) as year_week,
date,
count(state_tribe_territory)
from "cdc-gov/us-state-and-territorial-public-mask-mandates-from-tzyy-aayg:latest"."us_state_and_territorial_public_mask_mandates_from"
where face_masks_required_in_public = 'Yes'
group by date
order by raw_date asc;
`);

Insert cell
states_with_mask_mandates = result.response.rows.map((row) => ({
...row,
raw_date: new Date(row.raw_date),
}));

Insert cell
states_with_mask_mandates
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Plot.plot({
marks: [
Plot.ruleY([0]),
Plot.lineY(states_with_mask_mandates, { x: "raw_date", y: "count" }),
],
});
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