Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8541287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:47:53+00:00 2026-06-11T11:47:53+00:00

I have a graph on the screen and all the data that is needed

  • 0

I have a graph on the screen and all the data that is needed is in a variable called jsonData, this being my way to avoid a JSON-File stored seperately on a server.
Now the jsonData contains more than i really want to show at the beginning, so I have to select the needed nodes.
The idea is to have a root node and show all the nodes directly connected with it and the conections between them.
Is there any simple possibility to do this?
Maybe I can change the line

var node = svg.selectAll(".node")
  .data(jsonData.nodes)
.enter().append("g")
  .attr("class", "node")
  .call(force.drag);

because it doesn’t need to select all of them, but how can I pick the ones needed?
I have an array in the background that contains all the needed links and I’m up to writing a part that will store the connected nodes.
I can’t give this new array directly to the svg.selectAll-part because otherwise the links will crash (they refer to the number of the node by it’s original position in the bigger array).
Any hints on that? I couldn’t find any examples for this on via Google-research, but if you can spot something out there in the net, just feel free to answer with the link!

Thanks in advance,
David

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:47:54+00:00Added an answer on June 11, 2026 at 11:47 am
    function getNodesIndex(searchedFor){
        for(var i = 0; i < jsonData.nodes.length; i++){
            if(jsonData.nodes[i].name == searchedFor){
                return i;   
            }
        }//for
    }
    
    function getNetParts(searchedFor){
        reqNodes = null;
        reqNodes = [];
        reqLinks = null;
        reqLinks = [];
    
        var index = getNodesIndex(searchedFor);
        reqNodes.push(jsonData.nodes[index]);   
    
        for(var y = 0; y < jsonData.nodes[index].connections.length; y++){
            //stores every node connected with the main node in reqNode
            reqNodes.push(jsonData.nodes[jsonData.nodes[index].connections[y]]);    
        }
    
        for(var z = 1; z < reqNodes.length; z++){                   
            //circle through stored Nodes
            for(var c = 0; c < reqNodes[z].connections.length; c++){    
                //inspect all of their connections
                for(var w = 0; w < reqNodes.length; w++){
                    //check all stored reqNodes for the one linked
                    if(jsonData.nodes[reqNodes[z].connections[c]].name == reqNodes[w].name)           { 
                        //the node is available at reqNodes?
                        var source = null; 
                        var newLink = {
                            "source":z,
                            "target":w,
                            "value":1,
                        };                          
                        reqLinks.push(newLink);                 
                    }
                }   
            }   
        }
    }
    

    And then update() just deletes anything on the screen, gets the new data and rebuilds the visualisation.
    Just in case anyone has the same trouble… 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a graph that contains nodes (groups) composed by inner nodes and when
I have a graph (organigram) how this: digraph G { nodesep=0.3; ranksep=0.2; margin=0.1; node
Need help. I have Graph API code that uses an auth token with offline
I have an app with a login screen with a button that invites users
I have this widget in android, that displays an image and gets updated periodically
I have a Samurize config that shows a CPU usage graph similar to Task
I have a problem with accessing the graph API through my android application that
I have a simple code that finds paths using a graph stored in a
I have a graph representing users and some articles they wrote. I need to
I have 6 graph bars with the prices. Each price number will represent its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.