chart2 = {
const margin = ({top: 20, right: 30, bottom: 30, left: 40})
const origin = projection([0, 0]);
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
let image = svg
.append("g")
.attr("pointer-events", "none")
.selectAll("image");
const tile = d3.tile()
.size([width, height])
.scale(projection.scale() * 2 * Math.PI)
.translate(projection([0, 0]).map(Math.round))
.tileSize(512)
const tiles = tile();
image
.data(tiles, d => d)
.join("image")
.attr("xlink:href", d => url(...d3.tileWrap(d)))
.attr("x", ([x]) => (x + tiles.translate[0]) * tiles.scale)
.attr("y", ([, y]) => (y + tiles.translate[1]) * tiles.scale)
.attr("width", tiles.scale)
.attr("height", tiles.scale);
const x = d3.scaleLinear()
.domain(d3.extent(pts, d => d[0]))
.range([margin.left, width - margin.right])
const y = d3.scaleLinear()
.domain(d3.extent(pts, d => d[1]))
.range([margin.top, height - margin.bottom])
svg.selectAll(".line").data(Array.from(d3.range(graph.targets.length))).enter()
.append("line")
.attr("class", "line")
.attr("x1", function(d, i) { return x(pts[graph.sources[i]][0]); })
.attr("x2", function(d, i) { return x(pts[graph.targets[i]][0]); })
.attr("y1", function(d, i) { return y(pts[graph.sources[i]][1]); })
.attr("y2", function(d, i) { return y(pts[graph.targets[i]][1]); })
.attr("stroke", function(d, i) {
console.log(graph.sources[i])
if(typeof values_inverted[graph.sources[i]] != "undefined") {
console.log(values_inverted[graph.sources[i]])
return "black"
} else {
return "black"
}
})
.attr("stroke-width", 2)
return svg.node();
}