d3-cloud Về sự kiện click Can nó có thể sử dụng nhấp kiện trong đám mây từ khóa của D3 và Nếu có như thế nàoCó thể sử dụng sự kiện nhấp trong đám mây thẻ của D3 và Nếu có thì làm cách nào?
<!DOCTYPE html>
<meta charset="utf-8">
<script src="../lib/d3/d3.js"></script>
<script src="../d3.layout.cloud.js"></script>
<body>
<script>
var fill = d3.scale.category20();
var zz= ["Hello", "world", "normally", "you", "want", "more", "words", "than", "this"];
d3.layout.cloud().size([300, 300])
.words((zz).map(function(d) {
return {text: d, size: 10 + Math.random() * 90};
}))
.rotate(function() { return ~~(Math.random() * 2) * 90; })
.font("Impact")
.fontSize(function(d) { return d.size; })
.on("end", draw)
.start();
function draw(words) {
d3.select("body").append("svg")
.attr("width", 300)
.attr("height", 300)
.append("g")
.attr("transform", "translate(150,150)")
.selectAll("text")
.data(words)
.enter().append("text")
.style("font-size", function(d) { return d.size + "px"; })
.style("font-family", "Impact")
.style("fill", function(d, i) { return fill(i); })
.attr("text-anchor", "middle")
.attr("transform", function(d) {
return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")";
})
.text(function(d) { return d.text; });
}
</script>
(Tôi muốn "Hello", "Thế giới", "bình thường", "bạn" , "muốn", "nhiều hơn", "chữ", "hơn", "này" lời được nhấp)
Câu trả lời cho câu hỏi của bạn gần như chắc chắn là có, nhưng không có bất kỳ lời giải thích nào về ý nghĩa của bạn bằng "đám mây từ khóa" (ví dụ: chúng tôi sẽ không thể cung cấp thêm chi tiết cho bạn. –