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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more