Giter VIP home page Giter VIP logo

Comments (5)

vasturiano avatar vasturiano commented on May 10, 2024

Hi @lothorp. You already have those coordinates, if you look in each of the node objects in your graphData structure, you'll find each has been annotated with x, y and z attributes representing its current coordinates. You can extract those values to feed to a different system.

Example:

{ 
  nodes: [{
    "id": "1",
    "x":-15.31939841608478,
    "y":26.545855541061,
    "z":78.58912678726857,
    ...
    },
    ...
  ],
  links: [...]
}

Just a note, this is only true if you're using the d3 engine. ngraph does not function with coordinate object annotation.

from 3d-force-graph.

 avatar commented on May 10, 2024

This is an example of me attempting to access the graphData in console.

I get the print out in console however the object is empty.

<head>
  <style> body { margin: 0; } </style>
  <script src="//unpkg.com/3d-force-graph"></script>
  <!--<script src="../../dist/3d-force-graph.js"></script>-->
</head>

<body>
  <div id="3d-graph"></div>
  <button id="graph-btn">Button</button>
</body>

<script>
    const elem = document.getElementById('3d-graph');
    const Graph = ForceGraph3D()(elem)
      .forceEngine('d3')
      .nodeResolution(8)
      .jsonUrl('pcap_export.json')
      .warmupTicks(10)
      .nodeAutoColorBy('group')
      .nodeLabel( node => `${node.id}`)
      .onNodeHover(node => elem.style.cursor = node ? 'pointer' : null);

    document.getElementById("graph-btn").addEventListener("click", get_node_locs);

    function get_node_locs() {
        var x = Graph.graphData()
        console.log(x)
    }
</script>

Your repos are great by the way, keep it up!

from 3d-force-graph.

vasturiano avatar vasturiano commented on May 10, 2024

@lothorp you're right. This is a bug in the lib, related to how graphData is exposed when using the internal fetch in jsonUrl. There's nothing wrong with your code. I'll fix the lib when I have just a bit of time.
If you want get unblocked immediately, you can switch back to using the graphData(<data>) method to input the data, instead of jsonUrl().

And thanks for the report!

from 3d-force-graph.

vasturiano avatar vasturiano commented on May 10, 2024

@lothorp this is now fixed from v1.28.11. Let me know if you run into any other issues.

from 3d-force-graph.

 avatar commented on May 10, 2024

Wow! What a fast turn around. You really do value feedback, thanks a lot for your help and keep up the good work. I will be using your repos for a long time to come.

from 3d-force-graph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.