Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using title in node and edge #54

Closed
ivantam4 opened this issue Dec 9, 2019 · 6 comments · Fixed by #133
Closed

Using title in node and edge #54

ivantam4 opened this issue Dec 9, 2019 · 6 comments · Fixed by #133

Comments

@ivantam4
Copy link

ivantam4 commented Dec 9, 2019

This is regarding using title for both node and edge.
When using HTML a tag and href for a local pdf as title in add_node() in Pyvis, it works and allow me to down load and show the pdf in a separate tab, but the separate title that was specified in add_edge is no longer shown when the mouse move over the edge. Using iframe instead of a tag for node works and edge title was shown when the mouse move over it, but the pdf iframe disappear as soon as the mouse move and its hard to use the pdf in the iframe, I prefer to view the pdf, enlarge it and able to moving the mouse around. The generation of the node title html is as follow :

def create_pdf_download (pdf_title,pdf_link):

prefix = "<a target="_tab" href="
postfix = ">"+ pdf_title + ""
return prefix + pdf_link + postfix

I notice that the html code generated for G.html at the edge is a bit different in the two scenarios but I have very little html know-how

Thanks

@boludo00
Copy link
Collaborator

Is the issue that the hover tooltip for the edge is not showing up at all? Or is it just a matter of not being able to click your hyperlink for the edge title since it moves along with your mouse?

@ivantam4
Copy link
Author

Thanks for getting back. The issue was that when hover the tooltip over the edge, the title is not shown if I use href in the node title. I checked the html code and found that when putting href structure in the node title, the following was added at the beginning of the html file 👍

    /* position absolute is important and the container has to be relative or absolute as well. */
        div.popup {
        position:absolute;
        top:0px;
        left:0px;
        display:none;
        background-color:#f5f4ed;
        -moz-border-radius: 3px;
        -webkit-border-radius: 3px;
        border-radius: 3px;
        border: 1px solid #808074;
        box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2);
        }

        /* hide the original tooltip */
        .vis-network-tooltip {
          display:none;
        }

I suspected that last setting where vis-network-tooltip {display:none} may be the reason. The above was not added in the html when I use iframe popup as part of title in the node

At the end i search a bit of vis js and specify 'label' in add_edge call. Now the text is shown at the edge even when I use href in the node title but the font is not what I want. So i brute force amend the edge option in html file by inserting the "strokeWidth" and "color" setting from my program to generate the final html file....

So all in all, the text is shown on the edge now when href is used in the node. I just leave the tooltip display:none generated untouched.

@rthill91
Copy link

Is there any movement on this?

Also #55 is a duplicate

@boludo00
Copy link
Collaborator

Hi, it had been a while since I visited this issue last. I have since upgraded visjs to version 9.0.4 and noticed their tooltip class name changed from vis-network-tooltip to vis-tooltip. Reflecting that change in the template.html seems to hide that tooltip and display the original one supporting the href.

image

This will be included in the next release.

@kk-hiraskar
Copy link

@boludo00, in the last comments image I can see that a search bar kind of thing is present on top of the graph.

I want to add this "select node" to my pyvis graphs also, can you suggest how this is done.

@MaxDXDX
Copy link

MaxDXDX commented Feb 6, 2022

Sorry for my english....

I reviewed for source files and here is what i can guess.
If you are use in at least one node's title any content with "href" text pyvis do following:

  • hide original vis.js tooltip for this node because original popup tooltip is moving with mouse cursor and you're can't click on link in your title!
  • but pyvis hide original tooltip not only for this one, it hide ALL original tooltips for ALL elements of network (even it not contain "href" tag)
  • because original tooltip hided, pyvis insert custom popup algorithm in html page. New custom tooltip position is fixed and you are able to click on href tag. But unfortunately it correctly works ONLY for NODES, not for edges (some javascript errors occurs on edges popup title handling, you can see them in browser console)

It would be great if the pyvis handle only "href"-contained titles without changing original vis.js tooltips for elements, that not contain "href" tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants