Published
Edited
Jul 19, 2019
2 stars
Insert cell
Insert cell
Insert cell
d3 = require('d3')
Insert cell
{
const svg = d3.select(DOM.svg(size.width, size.height));
svg.append('g')
.attr('transform', `translate(0, ${size.height - margin.bottom})`)
.call(xAxis);
svg.append('g')
.attr('transform', `translate(${margin.left}, 0)`)
.call(yAxis);
svg.append("g")
.attr("stroke", "#000")
.attr("stroke-opacity", 0.2)
.selectAll("circle")
.data(data)
.enter().append("circle")
.attr("cx", d => xScale(d.x))
.attr("cy", d => yScale(d.y))
.attr('fill', d => fillScale(d.y))
.attr("r", 2.5);
return svg.node();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = Array.from({length: dataLength}, () => ({x: Math.random(), y: Math.pow(Math.random(), 2)}))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chroma = require('d3-scale-chromatic')
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