chart2 = {
const svg = d3.create("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom);
const node = svg.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
const split_data = {};
for (let i = 0; i < dimensions2.length; ++i) {
const next = i < dimensions2.length-1 ? i+1 : i-1;
split_data[dimensions2[i]] = [];
for (const d of data.nodes) {
split_data[dimensions2[i]].push({
"from": +d[dimensions2[i]],
"to": +d[dimensions2[next]]
});
}
}
function addLines(dim, next, data) {
node.append("g")
.selectAll("path")
.data(data)
.enter().append("path")
.attr("d", (d) => paths2[selectedEncoding2](d, dim, next))
.style("stroke", (d) => line_color2[dim](d.from))
.style("fill", "none")
.style("stroke-width", 1.5);
}
for (let i = 0; i < dimensions2.length; ++i) {
const next = i < dimensions2.length-1 ? i+1 : i-1;
addLines(dimensions2[i], dimensions2[next], split_data[dimensions2[i]])
}
node.selectAll("axis")
.data(dimensions2).enter()
.append("g")
.attr("transform", function(d) { return "translate(" + x2(d) + ")"; })
.each(function(d) { d3.select(this).call(d3.axisLeft().scale(y2[d])); })
.append("text")
.style("text-anchor", "middle")
.attr("y2", -9)
.text(function(d) { return d; })
.style("fill", "black");
return svg.node();
}