Comments (5)
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.
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.
@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.
@lothorp this is now fixed from v1.28.11
. Let me know if you run into any other issues.
from 3d-force-graph.
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)
- Nodes start disappearing after awhile and get computed radius is NaN error. HOT 2
- Latest release seems to elicit new warning in browser console HOT 1
- How do I turn off `setTimeout` and `requestAnimationFrame` from the last render HOT 1
- Node border HOT 1
- black holes HOT 1
- How to use StereoCamera in renderControl? HOT 10
- breaking changes: node color & plane color issue HOT 1
- Forces re-calculating when doing incremental updates with no changes. HOT 4
- Redo/Undo feature HOT 3
- link arrow size become adjustable HOT 2
- adding a hover or click listener to an external asset HOT 3
- Dynamic Particles do not appear for fixed Nodes HOT 1
- Issue with scene hyper-intensive illumination (probably after 1.73.0) HOT 2
- Shadow for links and nodes HOT 1
- How to add a loader to the node HOT 1
- Html rerendering on drag
- continuous scale node color
- 我画布上的所有节点都没有链接,点击节点之后,节点会向外扩散
- LOD for abnormally large graphs
- onNodeClick work error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 3d-force-graph.