shootings = {
const svg = d3
.create("svg")
.attr("viewBox", [0, 0, width, height])
.style("background", "white");
svg.append("g").call(xAxis);
svg.append("g").call(yAxis);
svg.append("g").call(yAxisRight);
const shootingsGroup = svg.append("g");
const blendMode = "multiply";
const series = [
{
yScale: yLaws,
prop: "laws",
color: colors[0]
},
{
yScale: yShootings,
prop: "shootings",
color: colors[1]
}
];
series.forEach((conf) => {
shootingsGroup
.append("path")
.attr("fill", conf.color)
.attr("fill-opacity", 0.1)
.style("mix-blend-mode", blendMode)
.attr("d", area(conf.yScale, conf.prop)(data));
shootingsGroup
.append("path")
.attr("stroke", conf.color)
.attr("stroke-width", 2)
.attr("opacity", 0.7)
.attr("fill", "none")
.attr("d", line(conf.yScale, conf.prop)(data));
});
return svg.node();
}