question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dynamically determine best tooltip anchor

See original GitHub issue

Version of nivo tested: 0.58.0

Is your feature request related to a problem? Please describe. Our concern/feature request is primarily related to the line chart, but this affects other chart types too.

After upgrading to a recent version of nivo, the tooltips stopped being positioned relatively such that they don’t overflow the bounding box. In a previous version we were using (0.31.0, specifically), the tooltip would adjust by anchoring itself on the opposite side of the cursor when the pointer reached the midpoint. Now it seems the scheme has changed and an anchor attribute must be provided.

I don’t think this option will let us dynamically position the tooltip to avoid colliding with the boundary.

Describe the solution you’d like It would be better for us if the tooltip would dynamically anchor itself like it used to. Alternatively, we’d like to be able to use a hook to determine the best anchor dynamically

Describe alternatives you’ve considered I considered sending a PR to modify the positioning logic, but I don’t feel comfortable with this approach.

https://github.com/plouc/nivo/blob/master/packages/tooltip/src/hooks.js#L29-L41

const bounds = container.current.getBoundingClientRect()
let x = event.clientX - bounds.left
let y = event.clientY - bounds.top

if (anchor === 'left' || anchor === 'right') {
  if (x < bounds.width / 2) anchor = 'right'
  else anchor = 'left'
}

Basically, I cannot imagine something like this being mergeable, although it does work well for my application.

I would like to solve this problem by potentially allowing an “auto” option for anchor, or something like that.

Additional context I sincerely hope this is a feature request, and not simply a demonstration of ignorance on my part. I tried to figure this out myself before resorting to this request

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:33
  • Comments:33 (1 by maintainers)

github_iconTop GitHub Comments

25reactions
chirgjncommented, Jul 26, 2019

Hey if no one is working on this, should I submit a PR I need this fix for a project at work 😁

2reactions
hadasmaimoncommented, Jun 29, 2021

you can workaround with breaking word:

word-wrap: break-word; /* All browsers since IE 5.5+ */
overflow-wrap: break-word; /* Renamed property in CSS3 draft spec */
max-width: 10rem;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic Tooltip in Unity! (Resizable, Follows Mouse, Edge ...
Let's build a Dynamic Tooltip that can resize itself to fit whatever text we give it. This is essential for any game that...
Read more >
How do I bind Twitter Bootstrap tooltips to dynamically created ...
This works fine, but I add <a> elements dynamically and the tooltips aren't showing up for those dynamic elements. I know it's because...
Read more >
Dynamic ToolTip using AJAX and possibly "Title" Attribute ...
Dynamic ToolTip using AJAX and possibly "Title" Attribute from anchor. ... I thought this would be a better option though another option would...
Read more >
Tooltip dynamically assigned in repeater somewhat intermittent
Pretty simple: In a asp.net repeater I have an anchor tag which gets a unique id from a databind: <a id="<%# ((Item)Container.DataItem).
Read more >
Understanding Tooltips | Chameleon Help Center
The Builder will open on your website and you will be prompted to select an element on the page to anchor your Tooltip...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found