WestHealth / pyvis

Python package for creating and visualizing interactive network graphs.
http://pyvis.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
984 stars 165 forks source link

Edge titles does not work? #268

Open zkutasi opened 10 months ago

zkutasi commented 10 months ago

The documentation states that add_edge(...) has a parameter, title (str) – The title is shown in a pop-up when the mouse moves over the edge. I have tried to set a string to this, I eventually wanted to be a HTML fragment the same way node title works, but it seems the code behind is only prepared for Node hover-tooltips.

Uncaught TypeError: nodeData[0] is undefined
    showPopup file:///home/ezolkut/localmnt/eea/EEA/cnint/dep.html:176
    drawGraph file:///home/ezolkut/localmnt/eea/EEA/cnint/dep.html:159
    emit https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js:26
    value https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js:26
    popupTimer https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js:26
    setTimeout handler*value https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js:26
    value https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js:26
    value https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js:26
    value https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js:26
    xT https://cdnjs.cloudflare.com/ajax/libs/vis-network/9.1.2/dist/vis-network.min.js:26
    drawGraph file:///home/ezolkut/localmnt/eea/EEA/cnint/dep.html:129
    <anonymous> file:///home/ezolkut/localmnt/eea/EEA/cnint/dep.html:207

When I look into the html code, I do not see showPopup(...) has even a way to be called with an edge:

function showPopup(nodeId) {
                          // get the data from the vis.DataSet
                          var nodeData = nodes.get([nodeId]);
                          popup.innerHTML = nodeData[0].title;
...

How is this supposed to work? Using PyVis 0.3.2. In the template HTML code I cannot even see anything related to this. The "edges" variable is not even read in a meaningful way. Is this broken, or a feature that was prematurely documented, but never implemented?

txu-7777 commented 6 months ago

I am having the same problem when my node title contains an href, I thought the problem was fixed based on comments here: https://github.com/WestHealth/pyvis/pull/133

But doesn't seem like the case. I deleted the following code from the HTML file for the network:

.vis-tooltip {display:none;}

And then the edge title showed up, but the node titles become duplicated like this: image

Would also like to know if there is away around this right now. Thank you!

norweeg commented 6 months ago

Are your node IDs numeric? Wondering if this is related to #272. It seems a LOT of things are ignored when node IDs are numeric

txu-7777 commented 6 months ago

Hey @norweeg, my node IDs are strings in this case

norweeg commented 6 months ago

Hey @norweeg, my node IDs are strings in this case

right, but are the strings numeric in that they contain only numeric characters?? Pyvis silently casts numeric strings to int for no reason causing issues if your node IDs are numeric strings, but does not do the same cast-as-int when adding edges containing numeric node ID strings. I fixed this in https://github.com/WestHealth/pyvis/pull/277 which addresses my issue, #276

txu-7777 commented 6 months ago

Oh, I see your point. In my case, the node IDs don't contain any numeric strings, they are BQ table names in the following format project.dataset.table

lucca-miorelli commented 5 months ago

In addition to this issue:

I'm encountering a similar problem. When I set the node title to HTML that includes an href, the edges' tooltips mysteriously disappear, even though the titles are present in the HTML file.