Public
Edited
Apr 13, 2023
5 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
beeswarmSettings = ({
x: (d) => d.x,
y: () => 0,
r: (d) => 5,
gap: 1,
ticks: 2,
//stroke: '#ccc',
strokeWidth: 0.5,
dynamic: true,
title: getTitle
})
Insert cell
plotProps = ({ marginLeft:100, marginRight: 100})
Insert cell
data = FileAttachment("ukr-civharm-2023-04-13.json").json()
Insert cell
marginLeft = 100
Insert cell
parseDate = d3.timeParse('%m/%d/%Y')
Insert cell
getTitle = (d) => `
${d.date}
${d.location}
${d.description}
`;
Insert cell
timeExtent = d3.extent(data, d => parseDate(d.date))
Insert cell
numDays = d3.timeDay.count(timeExtent[0], timeExtent[1])
Insert cell
xScale = d3.scaleTime().domain(timeExtent).range([0, numDays])
Insert cell
pointsData = data.map(d => ({
...d,
x: (parseDate(d.date)),
weaponType: d.filters?.find(f => f.key === 'Weapon System')?.value ?? "Unknown",
areaType: d.filters?.find(f => f.key === 'Type of area affected')?.value ?? "Undefined",
}))

Insert cell
xScale.domain()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
weaponTypeColor.domain(weaponTypes)
Insert cell
locations = new Set(pointsData.map(d => d.location))
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
import {beeswarmX} from "@fil/experimental-plot-beeswarm"
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