Public
Edited
Aug 8, 2024
1 fork
2 stars
Also listed in…
Political Issues
Maps
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
rows = 20
Insert cell
Insert cell
guns_by_country_name.get("me") !== undefined
Insert cell
gun_deaths_by_country.map(function (o) {
let gun_info = guns_by_country_name.get(o.country);
if (typeof gun_info != "undefined") {
return o;
}
})
Insert cell
gun_deaths_by_country = FileAttachment("gun_deaths_by_country.csv").csv()
Insert cell
FileAttachment("guns_by_country@1.csv").csv()
Insert cell
function get_guns_per100(c) {
let guns = guns_by_country_abbr.get(c.properties.ISO_A3);
if (guns) {
let per100 = guns.per100;
return per100;
} else if (c.properties.ISO_A3 == "-99") {
let guns = guns_by_country_name.get(c.properties.ADMIN);
if (guns) {
let per100 = guns.per100;
return per100;
} else {
return -1;
}
} else {
return -1;
}
}
Insert cell
countries = {
let countries = await FileAttachment("countries@2.json").json();
return topojson.feature(countries, countries.objects.countries);
}
Insert cell
max = d3.max(Array.from(guns_by_country_abbr.values(), (o) => o.per100))
Insert cell
guns_by_country_abbr = d3.rollup(
guns_and_countries,
(a) => a[0],
(o) => o.cca3
)
Insert cell
guns_by_country_name = d3.rollup(
guns_and_countries,
(a) => a[0],
(o) => o.country
)
Insert cell
guns_and_countries = FileAttachment("guns_by_country@1.csv").csv({
typed: true
})
Insert cell
import { Legend, Swatches } from "@d3/color-legend"
Insert cell
tippy = require("tippy.js")
Insert cell
<link rel="stylesheet" href="${await require.resolve(
`tippy.js/themes/light-border.css`
)}">
Insert cell
require.resolve(`tippy.js/themes/light-border.css`)
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