Public
Edited
Aug 28, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
scalingComparisonData = {
const getAreaFromRadius = radius => (Math.pow(radius, 2) * Math.PI)
const getRadiusFromArea = area => (Math.sqrt(area / Math.PI))
const defaultNodeArea = getAreaFromRadius(defaultNodeRadius)
return factors.map(factor => {
const radiusScaled = defaultNodeRadius * factor
const areaScaled = defaultNodeArea * factor
return {
scaleFactor: factor,
radiusScaling: {
radius: radiusScaled,
area: getAreaFromRadius(radiusScaled),
radiusScaleFactor: factor,
areaScaleFactor: getAreaFromRadius(radiusScaled) / defaultNodeArea
},
areaScaling: {
radius: getRadiusFromArea(areaScaled),
area: areaScaled,
areaScaleFactor: factor,
radiusScaleFactor: getRadiusFromArea(areaScaled) / defaultNodeRadius
}
}
})
}
Insert cell
elementWidth = width / (factors.length + 1)
Insert cell
width = 900
Insert cell
height = (d3.max(scalingComparisonData.map(d => d.areaScaling.radius)) * 2) + 50
Insert cell
defaultNodeRadius = 25
Insert cell
factors = [0.25, 0.5, 1, 2, 4]
Insert cell
d3 = require("d3@5")
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