问题
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?
回答1:
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} />
来源:https://stackoverflow.com/questions/53642760/react-vega-and-react-vega-tooltips