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

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