A tooltip plugin for Vega and Vega-Lite visualizations. This plugin implements a custom tooltip handler for Vega that uses custom HTML tooltips instead of the HTML title
attribute. Vega Tooltip is installed in the Vega Editor.
Vega Tooltip 0.9 and above use a new API as described below. Learn what has changed at https://github.com/vega/vega-tooltip/wiki/Changes-in-Vega-Tooltip-0.9.
http://vega.github.io/vega-tooltip/
Use npm install vega-tooltip
or yarn add vega-tooltip
.
You can import vega-tooltip
directly from jsDelivr
. Replace [VERSION]
with the version that you want to use.
<!-- Import Vega 3 & Vega-Lite 2 (does not have to be from CDN) -->
<script src="https://cdn.jsdelivr.net/npm/vega@3"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@2"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-tooltip@[VERSION]"></script>
If you use Vega-Embed, you don't need to install Vega Tooltip! Vega Embed already comes with Vega Tooltip. You can however pass tooltip customizations.
vegaEmbed("#vis", spec, {tooltip: {theme: 'dark'}})
.then(function(result) {
// result.view contains the Vega view
})
.catch(console.error);
If you want to ue a different version of the tooltip handler, you can override the default handler with the handler from Vega Tooltip (and you need to install it separately).
var handler = new vegaTooltip.Handler();
vegaEmbed("#vis", spec, {tooltip: handler.call})
.then(function(result) {
// result.view contains the Vega view
})
.catch(console.error);
See the API documentation for details.
- In the project folder
vega-tooltip
, type commandyarn
to install dependencies. - Then, type
yarn start
. This will build the library and start a web server. - In your browser, navigate to
http://localhost:8000/
, where you can see various Vega-Lite and Vega visualizations with tooltip interaction.
To release a new version, make sure that everything works. Then run yarn version
and bump the version number. Lastly, push to GitHub (with the release tag). Travis will build a bundle and make the npm release automatically.