In what world is this valid javascript?
You're trying to return a value from a code block which has been assigned to a variable. It almost looks like you're trying to create an arrow function.
Where did you learn to code like this? It's fantastic. I tested some similar code in JSFiddle. Apparently it's totally invalid as javascript. See for yourself. https://jsfiddle.net/4ekrLo5t/
But I see that here, on observablehq, it works.
There is some sort of terrible magic in the air.
in the example above we pass “width” (shorthand for {width: width}, where the width variable is defined—in the context of Observable’s stdlib—as the width of the page. See https://github.com/observablehq/stdlib
I am trying to learn Python and D3, and I am trying to use this code as a standalone python/flask app but I am having problems. I read the instructions above about using this code outside of observable, but I can't get it to work. I created a much smaller sample set of data using the exact same structure as the JSON above, I pass the JSON data into the page and put it into the graph variable. It seems to load OK, I can see the JSON in the graph variable in the debugger, but it complains that "d3.map()" is not a function. It breaks on this line:
const N = d3.map(nodes, nodeId).map(intern);
When I hover over "nodes" it shows it as undefined - so I am trying to figure out what puts the values into the "nodes" variable?
Thanks, I did check and was pulling an older version. Now I have this:
<script src="https://d3js.org/d3.v7.min.js"></script>
but now I get a really obscure error from the d3.v7.min.js. The line in the debugger is huge, but deep in the line I get this:
=typeof t[Symbol.iterator])throw new TypeError("values is not iterable")
Seems like I am still missing some kind of dependency.
If you remove .min from the url you should be able to see better. Please share your code online (as an observable notebook, for example) if you want to help us help you.
I have removed your extremely long comment with the full web page code, and pasted it in a notebook here
https://observablehq.com/@recifs/graph-user-support
As you can see, it works; so I suspect the issue might be that the data you feed to the function doesn't have the right format, maybe? Feel free to fork that notebook and iterate.