Implement victory-tooltip
Requirements:
- similar to label in that tooltips get positioned by their parents and are provided with data
- should be positioned above other components (react-gateway? react-portal?)
- should have some automatic events like hover
- Integration into parents should be flexible i.e. should be able to pass custom tooltip components.
+1
+1
If we're going to be rendering the tooltip outside of the svg context, react-gateway may be of interest.
:+1: Would love to see this.
Hi,
I think it could be helpful to have a callback function like onMouseHoverData={({mouseX, mouseY, values=[...]}) => {...}} as a low level api, so we can implement some custom tooltips.
is there any work being done with this?
@luisrudge yes. There is work going on in victory to support event handling generally, and @dandelany I believe is working on a specific tooltip component.
:+1: Only thing holding me back from using Victory right now :)
Awesooooooome. Thanks everyone.
Requirements:
- similar to label in that tooltips get positioned by their parents and are provided with data
- should be positioned above other components (react-gateway? react-portal?)
- should have some automatic events like hover
- Integration into parents should be flexible i.e. should be able to pass custom tooltip components.
:+1:
@dandelany has kindly shared some of his tooltip implementations that we might reference.
https://gist.github.com/dandelany/bd2fc7d9af96d50b53dd
https://github.com/dandelany/vector-toy/blob/master/src/components/SimpleTooltip.jsx
https://github.com/dandelany/vector-toy/blob/master/src/components/TippedComponent.jsx
Agree with others about passing a custom component for tooltip being nice.
Would also be nice if tooltip had an optional "crosshairs" attribute for adding a line on x and/or y axis that would point to hovered data point from the axis. If this is outside scope, maybe a separate victory component for this.
The folks at recharts done this already, maybe worth iterating on their work or getting some ideas, see: https://github.com/recharts/recharts/blob/master/src/component/Tooltip.js
seems to work pretty well.
Any updates on this? :)
This will be in the next release!
👍
This is getting pushed back on more release (mid June). Sorry everyone! This release (today) will have support for controlling events between Victory Components, so the pieces are all in place for a flexible tooltip implementation. For a quick fix, you should be able to create tooltips scoped to a single Victory Component with the current event system and custom label components.
Thanks for the update @boygirl. I've been using Victory but tooltips are not very easy to implement as of how the code is structured (or was structured). Could you provide a simple example implementation for having tooltips scoped to a Victory component?
@syrusakbary so long as you don't also need labels you can pass in a custom labelComponent and trigger events as you would on label. I'll get some examples up next week.