Published
Edited
Feb 3, 2021
1 star
Insert cell
md`# Weighted Circle Packing`
Insert cell
Insert cell
// viewof size = slider({min: "150", max: 700, step:10, title: "Size:"})
size = 900
Insert cell
// viewof marginSize = slider({min: 0 , max:50, step:10, title: "Margin:"})
Insert cell
// margin = ({top: marginSize, right: marginSize, bottom: marginSize, left: marginSize })
Insert cell
Insert cell
colorDepth = d3.scaleLinear()
.domain([0, 5])
.range([fromColor,toColor])
.interpolate(d3.interpolateHcl)
Insert cell
ramp(d3.interpolateHcl(fromColor, toColor))
Insert cell
Insert cell
viewof toColor = color({
value: "#2171b5",
title: "To Color"
})
Insert cell
Insert cell
Insert cell
Insert cell
pack = data => d3.pack()
.size([size, size])
.padding(3)
(d3.hierarchy(data)
.sum(d => d.value)
.sort((a, b) => b.value - a.value))
Insert cell
md`# Library`
Insert cell
import {ramp} from "@mbostock/color-ramp"
Insert cell
d3 = require("d3@6")
Insert cell
import {slider, radio, text, select, color} from '@jashkenas/inputs'
Insert cell
md`## Reference
* https://observablehq.com/@d3/zoomable-circle-packing
* https://observablehq.com/@d3/working-with-color
`
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