wordCloud = {
const fontFamily = "Fira Sans";
const svg = d3.create("svg")
.attr("id", "word-cloud")
.attr("viewBox", [0, -10, 900, 500])
.attr("font-family", fontFamily)
.attr("text-anchor", "middle");
const displaySelection = svg.append("text")
.attr("font-family", "Fira Sans")
.attr("font-size", 20)
.attr("font-weight", "bold")
.attr("text-anchor", "start")
.attr("alignment-baseline", "hanging")
.attr("x", 350)
.attr("y", 0)
.text("Clouds of Answers");
const cloud = d3.cloud()
.size([900, 500])
.words(testData)
.padding(3)
.rotate(() => wordRotate(Math.random()))
.font(fontFamily)
.fontSize(d => wordScale(d.freq))
.on("end", draw)
function draw(words) {
console.log(words)
var wordG = svg
.append("g")
.attr("id", "wordCloudG")
.attr("transform","translate(350,250)");
wordG.selectAll("text")
.data(words)
.enter()
.append("text")
.style("font-size", d => d.size + "px")
.style("fill", "#4F442B")
.attr("text-anchor", "middle")
.attr("transform", d => "translate(" + [d.x + 10, d.y] + ")rotate(" + d.rotate + ")")
.text(d => d.word);
};
cloud.start();
invalidation.then(() => {cloud.stop()});
return svg.node();
}