scatterplot_matrix = {
const svg = d3
.select(DOM.svg(width, height))
.attr("viewBox", `${-padding} 0 ${width} ${height}`)
.style("max-width", "100%")
.style("height", "auto")
.style("background-color", "white");
const g = svg.append("g").call(xAxis);
svg.append("g").call(yAxis);
const cell = svg
.append("g")
.selectAll("g")
.data(
triangular(d3.range(scatterplot_matrix_columns.length))
)
.join("g")
.attr("transform", ([i, j]) => `translate(${i * size},${j * size})`);
cell
.append("rect")
.attr("fill", "none")
.attr("stroke", "#aaa")
.attr("x", padding / 2 + 0.5)
.attr("y", padding / 2 + 0.5)
.attr("width", size - padding)
.attr("height", size - padding);
cell.each(function([i, j]) {
d3.select(this)
.selectAll("circle")
.data(
data.filter(
d =>
!isNaN(d[scatterplot_matrix_columns[i]]) &&
!isNaN(d[scatterplot_matrix_columns[j]])
)
)
.join("circle")
.attr("cx", d => x[i](d[scatterplot_matrix_columns[i]]))
.attr("cy", d => y[j](d[scatterplot_matrix_columns[j]]));
});
const circle = cell
.selectAll("circle")
.attr("r", 3)
.attr("fill-opacity", 0.4)
.attr("fill", d => z(d[s_m_color_column]));
svg
.append("g")
.style("font", "bold 10px sans-serif")
.selectAll("text")
.data(
scatterplot_matrix_columns.map(
e => properties.filter(d => d.key === e)[0].title
)
)
.join("text")
.attr("transform", (d, i) => `translate(${i * size},${i * size})`)
.attr("x", padding)
.attr("y", padding)
.attr("dy", ".71em")
.text(d => d);
svg
.append("g")
.attr("transform", "translate(610,20)")
.append(() => swatches({ color: z }));
return svg.node();
}