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.

Toggling visibility of links

See original GitHub issue

extends https://github.com/anvaka/ngraph.pixel/issues/6

I also love this tool, thanks so much @anvaka.

I’m making a graph has dense links, and I want to reveal link links for a given node only when I hover over that node. Like this :

selection_138 (this is a community living on a decentralised database scuttlebutt)

In this setup, I’ve got dark links and light links, but would rather hide links.

The new API for hiding links is great :

var renderer = renderGraph(graph, {
  link: function createLinkUI(link) {
    if (link.data === 'hidden') return; // don't need to render!
    // otherwise return default link:
    return {
      fromColor: 0xFFFFFF,
      toColor: 0xFFFFFF
    };
  }
});

When we set up a renderer.on('nodehover', (node) => {...} ), it’s then hard/ impossible to make make the links visible. (I’m not actually sure if they got created, I couldn’t quite follow the code). I’ve noticed that the node in that context has links which each have an id, but these can’t be fetched using renderer.getLink

renderer.forEachLink also does nothing, suggesting there are no edges / links registered in the renderer.

Would appreciate any suggestions / ideas about how best to approach this.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
anvakacommented, Dec 19, 2021

Thank you for the ping @mixmix !

I played with this and to my surprise was able to achieve hover-only links with small amount of code. Here is a demo

If link’s position changes while the links are visible (and you want to update it), you’d have to call

var edgeView = renderer.edgeView();

// sequence of this mostly identical names is important
// Also note that 5 years younger me was not able to write
// readable code - I can't explain otherwise such a poor
// choice of function names :D
edgeView.refresh();
edgeView.update();

PS: I am not using this repository anymore, and all my latest graph drawings are done with graph-start repository - please check it out if you haven’t yet.

1reaction
mixmixcommented, Dec 19, 2021

(I’d be prepared to chip in some money too)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Toggle Visibility When Hiding Elements - CSS-Tricks
The development team at Medium have discussed some bad practices that break accessibility. In one example, they argue that opacity is not ...
Read more >
How To Toggle Between Hiding And Showing an Element
Toggle between hiding and showing an element with JavaScript. Toggle Hide and Show. Click the button! Toggle (Hide/Show) an Element. Step 1) Add...
Read more >
Toggle DIV visibility based on Link click using jquery
This binds an event for each letter and then has to search the DOM every time a letter is clicked. It would be...
Read more >
Toggle visibility of a link? - Gazebo: Q&A Forum
4 Answers. You can use Gazebo's transport mechanism to publish a visual message to toggle visibility.
Read more >
Toggle visibility after a link is followed - JavaScript - SitePoint ...
Hi there! I would REALLY appreciate any help! I've got a script that toggles the visibility of a div on "dashboard.html": $(document).ready(function(){ ...
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