1

I have switched my d3 from version 3 to version 4 and as you know there are a lot of breaking changes in between them. In version 4, I had created following d3 graph: http://next.plnkr.co/edit/C0n0GZvYpppWjx3R

This actually works well, but a challange what I have is, when I do double click of a node, I want this to focus only on the clicked node and all its directly connected node... something like this: enter image description here

I am here confused how I can do that... a. Do I need to remove all other node and redraw the charts? b. Shall i hide the nodes and links somehow (how?) and only let the focussed (and connected to it) node visible at central.

Can anyone please help here.

kaounKaoun
  • 601
  • 1
  • 9
  • 21
  • A starting point for you could be here: https://stackoverflow.com/questions/41905384/d3-focus-on-node-on-click – ksav Sep 09 '18 at 10:55

1 Answers1

2

Very confused by this question. You have coded a tremendous graph and the feature you are asking about is 99% coded but its just missing two things:

  1. A small typo (forEach being used as a keyword, instead of a method, line 228)
  2. And is never assigned via an event handler (line 137)

Fixing these two things.

Mark
  • 106,305
  • 20
  • 172
  • 230
  • I am sorry, I just missed to change that...to create plunkr, i copied my workspace . Here forEach was actually _.forEach... your changes looks good... but I think its just making the nodes/ links invisible, which I already had tried... I was actually looking for something like above image where node is at center of the screen and all connected nodes at almost equal distance. I am little new to this, so not sure how I can actually do that – kaounKaoun Sep 09 '18 at 14:46