All examples By author By category About

alex-r-bigelow

Tooltip demo

A semi-smart function for displaying tooltips with D3.js

Functions

showTooltip([parameters])

Shows a tooltip; assumes the existence of a div with id="tooltip", that is positioned absolutely

hideTooltip()

Shorthand for hiding the tooltip

showTooltip([parameters])

Shows a tooltip; assumes the existence of a div with id="tooltip", that is positioned absolutely

Kind: global function

| Param | Type | Default | Description | | --- | --- | --- | --- | | [parameters] | Object | {} | Parameter object | | [parameters.content] | String | '' | The message that will be displayed. Can be an empty string (hides the tooltip), a non-empty HTML string, or a function (which is called with the d3-selected tooltip div as the first argument) | | [parameters.targetBounds] | Object | | Specifies a bounding box that the tooltip should NOT occlude (typically, the results of a getBoundingClientRect() call) | | [parameters.anchor] | Object | | Specifies -1 to 1 positioning of the tooltip relative to targetBounds; for example, { x: -1 } right-aligns the tooltip to the left edge of targetBounds, { x: 0 } centers the tooltip horizontally, and { x: 1 } left-aligns the tooltip to the right edge of targetBounds | | [parameters.hideAfterMs] | Number | 1000 | Hides the tooltip after a certain delay; set this to zero to disable hiding |

hideTooltip()

Shorthand for hiding the tooltip

Kind: global function