scatterplotMatrix = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg.append("style").text("circle.hidden { fill: #000; fill-opacity: 0.1;}");
const cell = svg
.append("g")
.selectAll("g")
.data(d3.cross(d3.range(attributes.length), d3.range(attributes.length)))
.join("g")
.attr(
"transform",
([i, j]) =>
`translate(${padding + i * (padding + cellWidth)},${padding +
j * (padding + cellHeight)})`
);
cell
.append("rect")
.attr("fill", "#ECEFF1")
.attr("stroke", "none")
.attr("width", cellWidth)
.attr("height", cellHeight);
cell.each(function([i, j]) {
d3.select(this)
.selectAll("circle")
.data(data)
.enter()
.append("circle")
.attr ("cx", function (object)
{
var value_x = object [attributes[i]];
value_x = x[i](value_x);
return value_x;
})
.attr ("cy", function (object)
{
var value_y = object [attributes[j]];
value_y = y[j](value_y);
return value_y;
});
d3.select(this)
.append("g")
.attr("transform", `translate(0, ${cellHeight})`)
.call(d3.axisBottom(x[i]).ticks(cellWidth / 50));
d3.select(this)
.append("g")
.call(d3.axisLeft(y[j]).ticks(cellHeight / 30));
});
const circle = cell
.selectAll("circle")
.attr("r", 4.5)
.attr("fill-opacity", 0.5)
.attr("fill", d => color(d.species));
cell.call(brush, circle);
svg
.append("g")
.style("font", "18px Source Serif Pro")
.style("pointer-events", "none")
.selectAll("text")
.data(attributes)
.join("text")
.attr(
"transform",
(d, i) =>
`translate(${padding + i * (padding + cellWidth)},${padding +
i * (padding + cellHeight)})`
)
.attr("x", 10)
.attr("y", 10)
.attr("dy", ".71em")
.text(d => d);
return svg.node();
}