chart = {
if (box==true) { console.log("true") }
const svg = d3.create("svg")
.attr("viewBox", [-width / 2, -height / 2, width, height])
.style("background-color", "#000")
.attr("stroke-linejoin", "round")
.attr("stroke-linecap", "round");
let step = 10000000;
const planets = svg
.selectAll("g")
.data(data)
.join("g")
.attr("class","planet-object")
.attr("data-book-title", d => d.book)
planets
.append("circle")
.attr("class", "planets")
.attr("data-book-title", d => d.book)
.attr("data-date", d => d.pub_date)
.attr("fill", "#fff")
.attr("fill-opacity", i => 0.7+ (Math.random()*0.3))
.attr("stroke", "#5C12A6")
.attr("stroke-width", 0.5)
.attr("stroke-opacity", 1)
.attr("r", d => z(d.nb_ratings))
.attr("cx", d => y(d.pub_date) * Math.cos(y(d.pub_date) * d.review_score/3 * step/50000 * Math.PI / data.length))
.attr("cy", d => y(d.pub_date) * Math.sin(y(d.pub_date) * d.review_score/3 * step/50000 * Math.PI / data.length))
planets
.append("text")
.attr("class", "text-book")
.style("visibility", (box!="toggle") ? "visible" : "hidden")
.style("font-style", "italic")
.attr("font-size", 8)
.attr("x", d => y(d.pub_date) * Math.cos(y(d.pub_date) * d.review_score/3 * step/50000 * Math.PI / data.length) + 10)
.attr("y", d => y(d.pub_date) * Math.sin(y(d.pub_date) * d.review_score/3 * step/50000 * Math.PI / data.length) + 10)
.attr("fill", "#fff")
.text(d => `${d.book}`)
planets
.on("mousemove", mousemove)
.on("mouseleave", mouseleave)
function rotating() {
step+=1
planets
.selectAll("circle.planets")
.attr("cx", d => y(d.pub_date) * Math.cos(y(d.pub_date) * d.review_score/3 * step/50000 * Math.PI / data.length))
.attr("cy", d => y(d.pub_date) * Math.sin(y(d.pub_date) * d.review_score/3 * step/50000 * Math.PI / data.length))
planets
.selectAll(".text-book")
.attr("x", d => y(d.pub_date) * Math.cos(y(d.pub_date) * d.review_score/3 * step/50000 * Math.PI / data.length) + 10)
.attr("y", d => y(d.pub_date) * Math.sin(y(d.pub_date) * d.review_score/3 * step/50000 * Math.PI / data.length) + 10)
}
setInterval(rotating, 10);
svg.append("g")
.call(yAxis);
return svg.node();
}