AdeelK93 / collapsibleTree

Create Interactive Collapsible Tree Diagrams in R using D3.js
https://adeelk93.github.io/collapsibleTree/
158 stars 41 forks source link

Link in tooltip #65

Open ShKlinkenberg opened 2 years ago

ShKlinkenberg commented 2 years ago

Hi @AdeelK93

I want to create a collapsibleTreeNetwork with a link in the tooltip. I have forked your repo so I could change the mouseout function for hiding the tooltip. I now have some time to actually go to the link. Though the link is not clickable. My three can be found here, and the code here.

I have read this article so I would think it would be possible in D3. Though while looking at the code i do not see a difference in approach.

Do you have any suggestions to get this to work?

ShKlinkenberg commented 2 years ago

I managed to solve it. Two things needed to be changed

  1. Mouseout needed to be deleted to allow the permanent visibility of the tooltip.
  2. In the CSS for the htmlwidget, collapsibleTree.css, the pointer-event needed to be deleted to allow mouse click.

It would be cool to add tooltipPermanent as an additional argument in the collapsibleTree function.

rlderi commented 2 years ago

@ShKlinkenberg thank you, I have tried to do this previously and failed.

askarlupka commented 2 years ago

@ShKlinkenberg I'm wanting to add a tooltipHTML to my tree, but one that is made with the collapsibleTree() function instead of collapsibleTreeNetwork() function. Currently, collapsibleTree() only allows for numeric tooltips, unless it's in the flat network format and paired with collapsibleTreeNetwork(). However, my nodes do not have unique names and are in a nested lists.

Any suggestions on trying to get strings/HTML to show up for collapsibleTree()? I'm attempting to either make a dataframe that can be read into collapsibleTreeNetwork, or change the underlying code for collapsibleTree to allow for character class arguements for tooltip. But I'm not sure which will be doable.

askarlupka commented 2 years ago

@ShKlinkenberg I think I figured it out. For future reference I changed the code for collapsibleTree.Node in line 18 from

if(!is.null(tooltipHtml)) if(!(tooltipHtml %in% df$attributes)) stop("tooltipHtml column name is incorrect") to if(!is.null(tooltipHtml)) if(!(tooltipHtml %in% df$attributesAll)) stop("tooltipHtml column name is incorrect")

So far it seems to be working as expected.

AdeelK93 commented 2 years ago

@askarlupka good catch. I know I haven't been great at maintaining this, but if you want to PR that, I can put out a release