Published
Edited
Jan 24, 2021
Fork of Circle Chart
1 fork
Insert cell
Insert cell
discGauge (data, width, 350, radiusScale, 'steelblue')
Insert cell
Insert cell
Insert cell
function discGauge (data, width, height, radiusScale, color) {
const svg = d3.select(DOM.svg(width, height));
svg.selectAll('g')
.data(data)
.enter().append("g")
.attr("transform", (d,i) => "translate(" + xScale(i) + "," + (height - margin.bottom - margin.top) / 2 + ")")
.call(g => g
.append("circle")
.attr("r", maxRadius)
.attr("fill", color)
.attr('fill-opacity', 0.15))
.call(g => g
.append("circle")
.attr("r", d => radiusScale(d))
.attr("fill", color)
.attr('fill-opacity', 0.85)
.append("title")
.text(d => Math.round(d * 100).toFixed(0) + '%'))
return Object.assign(svg.node())
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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