Search code examples
reactjstooltipvegavega-lite

react-vega and react-vega tooltips


I'm using react-vega-lite.

In official examples:

https://vega.github.io/vega-lite/

https://vega.github.io/react-vega-lite/

https://vega.github.io/react-vega/

vega-lite (without react) has a tooltip by default react-vega allows to handle onSignalTooltip event.

So, I have 2 questions: 1) Is it possible to turn on tooltip with react-vega (react-vega-lite)? 2) Does react-vega-lite support onSignalTooltip or I need to switch to Vega?


Solution

  • Add vega-tooltip package as a dependency, then import the Handler class from it and pass an instance through the tooltip parameter of the VegaLite component:

    import { Handler } from 'vega-tooltip';
    
    ...
    
    <VegaLite spec={spec} data={barData} tooltip={new Handler().call} />