Adding tooltip to x axis on XY Chart #1413
-
Hi Guys, I'm trying to add a tooltip to x-axis ticks. I have tick labels that can be a really long string, which I truncate. Upon hover, I'd like to present the full label string in a tooltip. I had seen this issue (#944) but I can't seem to reproduce the behaviour for an XYChart. I've created a minimal working codesandbox here (https://codesandbox.io/s/aged-meadow-yl76j?file=/src/App.js:2018-2025). Any ideas what I am doing wrong here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @dalyemmett 👋 thanks for checking out
after those tweaks, it worked! 🎉 hope this helps and makes sense. |
Beta Was this translation helpful? Give feedback.
Hey @dalyemmett 👋 thanks for checking out
visx
. I made a couple of tweaks to your example to get it working (updated sandbox)xychart
theme setspointer-events: 'none'
by default fortickLabel
s so your pointer events weren't getting triggered. I turned this off withtickLabelProps
, but you could also set this at the theme level and pass the custom theme toXYChart
text
element, whereas you were using the@visx/text
Text
component. sincetext
is a standardreact
element, the demo usedref
directly, but the equivalent forText
isinnerRef
. without correctly settingcontainerRef
, theTool…