function WordCloud(data, height=400, { invalidation } = {}) {
const margin = {top: 10, right: 10, bottom: 10, left: 10};
const fontScale = 10;
const sizeMax = d3.max(data, d => d.size);
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height])
.attr("width", width)
.attr("text-anchor", "middle")
const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
const cloud = d3Cloud()
.size([width - margin.left - margin.right, height - margin.top - margin.bottom])
.words(data)
.padding(20)
.rotate(0)
.fontSize(d => Math.sqrt(d.size) * fontScale)
.on("word", d => g.append("text")
.attr("font-size", d.size)
.attr("transform", `translate(${d.x},${d.y}) rotate(${d.rotate})`)
.attr("fill-opacity", `${(d.size/sizeMax)*100}%`)
.text(d.text))
console.log(cloud)
cloud.start();
invalidation && invalidation.then(() => cloud.stop());
return svg.node();
}