Ich denke, das auf einem Streudiagramm nur ein ziemlich beteiligt Tooltip ist. Hier ist ein einfacher example:
// Define the div for the tooltip
var div = d3.select("body").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
// Add the scatterplot
svg.selectAll("dot")
.data(data)
.enter().append("circle")
.attr("r", 5)
.attr("cx", function(d) { return x(d.date); })
.attr("cy", function(d) { return y(d.close); })
.on("mouseover", function(d) {
div.transition()
.duration(200)
.style("opacity", .9);
div .html(formatTime(d.date) + "<br/>" + d.close)
.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");
})
.on("mouseout", function(d) {
div.transition()
.duration(500)
.style("opacity", 0);
});
Sie könnten auch this other example nützlich finden.
https://gia.guim.co.uk/2013/02/sotu/js/main.js ist der Link zu ihren js. – reptilicus
Danke. Ich werde versuchen, es zu verstehen. – TamKh