vasturiano / d3-force-3d

Force-directed graph layout in 1D, 2D or 3D using velocity Verlet integration.
https://observablehq.com/@vasturiano/multi-dimensional-d3-force-simulation
MIT License
373 stars 54 forks source link

Uncaught ReferenceError: ForceGraph3D is not defined #1

Closed kristianmandrup closed 6 years ago

kristianmandrup commented 6 years ago

Having just forked the repo and copied the Miserable example from bl.ocks.org/vasturiano

I run a local file server using serve and have everything configured as it should. I even encapsulated the index.js code in a drawGraph function:

function drawGraph() {
  const Graph = ForceGraph3D()
    (document.getElementById("3d-graph"));

  // ...
}

So I could use a callback  `document.addEventListener("DOMContentLoaded", cb)` to make sure that the DOM and all script dependencies are loaded before attempting to draw the graph.

```html
  <script src="index.js"></script>
  <script>
    document.addEventListener("DOMContentLoaded", function (event) {
      console.log("DOM fully loaded and parsed");
      drawGraph();
    });
  </script>

However, when searching for ForceGraph3D in the entire project, I find no match. What am I missing? I presume the example on your blog is out of date?

Please advice. Thanks.

kristianmandrup commented 6 years ago

PS: My fork/changes can be found here

kristianmandrup commented 6 years ago

Googling ForceGraph3D turned up the 3d-force-graph library, so I guess I'd have to add that as a dependency then...

kristianmandrup commented 6 years ago

Now I get a failure to load the JSON file for the miserables data:

:5000/miserables/.miserables.json Failed to load resource: the server responded with a status of 404 (Not Found)

kristianmandrup commented 6 years ago

Ah, I finally found it here

kristianmandrup commented 6 years ago

Unfortunately miserables data comes invarious formats, and your data-set-loader.js also requires a .blocks.json file. Where can I get these sample data or formats that seem to be used in many of the d3 force graph examples?? Cheers.

vasturiano commented 6 years ago

@kristianmandrup it seems like you may be looking for the 3d-force-graph library instead. This library (d3-force-3d) is just the force directed layout.

The examples folder is a good place to start. It also includes the datasets folder you're looking for.

kristianmandrup commented 6 years ago

Ah sweet :) Exactly! Would be awesome if you could update the Readme and/or blog post to include these pointers ;) Thanks!