Published
Edited
Sep 3, 2020
Insert cell
Insert cell
Insert cell
markWidth
Insert cell
legendConfig = ({
title: "Share of Pop.",
labelExpr: "join(['1 in ', datum.value, if(datum.value >= 250, '+', '')], '')",
orient: "none",
direction: (markWidth >= 600 ? "vertical" : "horizontal"),
legendX: (markWidth >= 600 ? markWidth - 100 : markWidth - 125),
legendY: 10
})
Insert cell
mark = vl.markGeoshape(
{
stroke: '#aaa',
strokeWidth: 0.25,
}
)
.data(jurisdictions)
.encode(
vl.tooltip([
{type: 'nominal', field: 'name', title: "Name"},
{type: 'quantitative', field: 'shareOfPop', title: "Share of Pop", format: ","},
{type: 'quantitative', field: 'cases', title: 'Cases', format: ","},
{type: 'quantitative', field: 'population', title: 'Population', format: ","},
]),
vl.color()
.fieldQ('shareOfPop')
.scale(
{
scheme: "yelloworangered",
domain: [250, 20],
clamp: true,
}
)
.legend(legendConfig)
)
.project(vl.projection('albersUsa'))
.height(markHeight)
.width(markWidth)
.autosize(
{
type: "fit",
contains: "padding",
resize: true
}
)
Insert cell
url = getURL('Attack_Rate_Automated')
Insert cell
layer = arcGIS.getLayer({url: url})
Insert cell
lastEdit = new Date(layer.editingInfo.lastEditDate)
Insert cell
sinceLastEdit = moment(lastEdit).fromNow()
Insert cell
queryResults = arcGIS.queryFeatures(
{url: url, f: "geojson"}
)
Insert cell
queryResults.features[0]
Insert cell
jurisdictions = queryResults.features.map(
d => ({
type: "Feature",
id: d.id,
geometry: d.geometry,
name: d.properties.County,
cases: d.properties.Cases,
population: d.properties.Population,
shareOfPop: Math.round(d.properties.Population / d.properties.Cases)
})
)
Insert cell
statewideCases = d3_arrays.sum(
queryResults.features, d => d.properties.Cases
)
Insert cell
statewidePopulation = d3_arrays.sum(
queryResults.features, d => d.properties.Population
)
Insert cell
shareOfStatePop = d3_format.format(",")(Math.round(statewidePopulation / statewideCases))
Insert cell
title = `1 in every ${shareOfStatePop} people in Missouri confirmed Covid-19 positive`
Insert cell
domain = [
d3_arrays.max(jurisdictions, d => d.shareOfPop),
d3_arrays.min(jurisdictions, d => d.shareOfPop),
]
Insert cell
d3.histogram()(jurisdictions)
Insert cell
d3 = require("d3")
Insert cell
vl.markBar()
.data(jurisdictions)
.encode(
vl.x().fieldO("shareOfPop").bin({maxbins: 30}).sort("descending"),
vl.y().count()
)
.render()
Insert cell
markRendered = mark.render()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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