Public
Edited
May 10, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
projection: {
type: "albers-usa", // this can be set static like this
},
width,
color: {
scheme: "reds"
},
r: {range: [1,30]},
marks: [
Plot.geo(nation, {fill: "#eee", stroke: "black"}),
//Plot.geo(states, {fill: "lightblue"}),
Plot.geo(statemesh, {strokeOpacity: 0.2}),
// Plot.graticule(),
Plot.sphere( {stroke: "#ddd"} ),
Plot.dot(filteredData, {
x: "longitude",
y: "latitude",
r:d=>d.total_victims,
//r : 50,
fill:"red",
stroke: "#eee",
title: (d) =>
`${d.location} \n fatality: ${d.fatalities} \n injured: ${d.injured} \n age of shooter: ${d.age_of_shooter}`
})
]
})

Insert cell
filteredData = shootingdata.filter(d =>
{if (ShowAllYears)
{return (location === 'All' || d['location.1'] === location)
&& (age === 'All' || d['age_group'] === age)}
else{
return d.year == Year && (location === 'All' || d['location.1'] === location) && (age === 'All' || d['age_group'] === age)}});
Insert cell
us = FileAttachment("us-counties-10m.json").json()
Insert cell
states = topojson.feature(us, us.objects.states)
Insert cell
nation = topojson.feature(us, us.objects.nation)
Insert cell
statemesh = topojson.mesh(us, us.objects.states, (a, b) => a !== b)
Insert cell
shooting = FileAttachment("shooting_1982-2023_cleaned.csv").csv()
Insert cell
shootingdata = shooting
Insert cell
shootingdata
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
import {Plot} from "@mkfreeman/plot-tooltip"
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