Published
Edited
Jan 14, 2021
Also listed in…
D3 Class
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
let svgElement = DOM.svg(width,height);
let svg = d3.select(svgElement);
let chart = svg.append('g')
.attr("transform",`translate(10,${height/2-10})`)
.attr("stroke","black")
.attr("fill","none")
.attr("font-size", 12)
.attr('text-anchor', 'middle')
.attr('alignment-baseline', 'middle')
let data = [4000, 8000, 20000, 40000, 80000]
const sqrt=d3.scaleSqrt().domain([1, 100000]).range([1,width/10-2]).nice();
chart.selectAll("circle")
.data(data)
.join("circle")
.attr("cx",d=>sqrt(d))
.attr("r",d=>sqrt(d))
chart.selectAll("text")
.data(data)
.join("text")
.attr("x",d=>sqrt(d)*2)
.attr("r",d=>sqrt(d))
.style("fill", "black")
.style("stroke", "none")
.text(d=>d3.format(".0s")(d))
return svgElement
}
Insert cell
height = 250
Insert cell
md`### External Libraries`
Insert cell
import {select} from "@jashkenas/inputs"
Insert cell
import {columns} from "@bcardiff/observable-columns"
Insert cell
d3 = require("d3")
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