Published
Edited
Oct 23, 2020
Insert cell
md`# Data Visualization Messes`
Insert cell
import { vl } from "@vega/vega-lite-api"
Insert cell
import { table } from "@tmcw/tables/2"
Insert cell
import { select } from "@jashkenas/inputs"
Insert cell
d3 = require("d3-dsv")
Insert cell
import { data as ProvinceData } from "@bulbil/part1-using-vega-lite-api"
Insert cell
ProvinceData
Insert cell
md` The columns of ProvinceData, which is from the [JHU CSSE COVID-19 Dataset](https://github.com/CSSEGISandData/COVID-19/tree/master/csse_covid_19_data), are as follows:

| FIPS (US) | Province_State | Country_Region | Lat and Long_ | Confirmed | Deaths | Recovered | Active | Incidence_Rate | Case-Fatality Ratio |
| ----- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |---- | ---- |
| Federal Information Processing Standards | province, state | country, region | MM/DD/YYYY HH:mm:ss | Dot locations on the dashboard | confirmed and probable counts of cases | confirmed and probable counts of deaths | estimated, may be skewed right | total cases - total recovered - total deaths | cases per 100K | (%) # recorded deaths/# cases |


<font size="1">All cases, deaths, and recoveries reported are based on the date of initial report. Exceptions to this are noted in the "Data Modification" and "Retrospective reporting of (probable) cases and deaths" subsections below.</font>
`
Insert cell
md` <h1>Nicer Table Formatting</h1> `
Insert cell
table(parsedData)
Insert cell
Insert cell
parsedData = d3.csvParse(ProvinceData)
Insert cell
Insert cell
Insert cell

vl.markBar()
.data(parsedData)
.encode(
vl.x().fieldN("FIPS"),
vl.y().fieldQ("Active"),
vl.color().fieldN("Province_State")
)
.render()
Insert cell

vl.markPoint()
.data(parsedData)
.encode(
vl.x().fieldN("FIPS"),
vl.y().fieldQ("Active"),
vl.color().fieldN("Province_State")
)
.render()
Insert cell
Insert cell
alphabet = d3.csvParse(await FileAttachment("alphabet.csv").text()) // about file attachments https://observablehq.com/@observablehq/file-attachments
Insert cell
// about viewof https://observablehq.com/@observablehq/a-brief-introduction-to-viewof
viewof simpleBar = vl.markBar() // Make a bar chart
.data(alphabet) // Using the alphabet data
.encode(
vl.x().fieldO("letter"), // .sort(vl.fieldQ("frequency").order("descending")), // Letters are ordinal on the x-axis
vl.y().fieldQ("frequency").axis({ format: "%" }) // Frequency on the y-axis, formatted as percent
//vl.color().fieldN("vowel").scale({ range: ["green", "gold", "lightgray", "darkgray", "red", "blue"] })
)
.render()
Insert cell
viewof horizontalBar = vl.markBar()
.data(alphabet)
.encode(
vl.y().fieldO("letter"),
vl.x().fieldQ("frequency").axis({ format: "%" })
)
vl.color().fieldN("
.render()
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