// color scale for the scatter plot (maps each cluster to a different color from d3.schemeCategory10)
colorScatter=d3.scaleOrdinal()
.domain(gapminder2000.map(d=>d.cluster))
.range(d3.schemeCategory10)
scatterplot={
constsvg=d3.create("svg")
.attr("width",chartWidth)
.attr("height",chartHeight);
svg.selectAll("circle")
.data(gapminder2000)
.join("circle")
// TODO: to reach the target image you need to define the attributes cx, cy, r (radius), and fill (color)
// - you can use a radius of 5 pixels for example
// - for the fill make use of the color scale defined above "colorScatter"
// .attr("cx", ...)
// .attr("cy", ...)
// .attr("r", ...)
// .attr("fill", ...);
// TODO: add x and y axes to the scatter plot.
returnsvg.node();
}
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.