Interactive Data Visualization for the Web by Murray Scott;

Interactive Data Visualization for the Web by Murray Scott;

Author:Murray, Scott;
Language: eng
Format: epub
Publisher: O'Reilly Media, Incorporated
Published: 2017-08-09T04:00:00+00:00


//Create the tooltip label svg.append("text") .attr("id", "tooltip") .attr("x", xPosition) .attr("y", yPosition) .attr("text-anchor", "middle") .attr("font-family", "sans-serif") .attr("font-size", "11px") .attr("font-weight", "bold") .attr("fill", "black") .text(d); })

Yes, this is based on our earlier value label code, simply adapted slightly. Note that the x and y attributes are set to the new position values we just calculated, and the actual text content of the label is set to d, the datum passed into the event listener function.

Also note that I assigned this next text element an ID of tooltip. This is so we can easily select (and delete!) the element when we’re done with it—on mouseout:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.