Trouble with d3.json when using type 2 referencing

Hi,

I am finding that in a lot of projects where i use Type 2 referencing, that randomly d3.json stops working. It doesn’t throw any errors, it just doesn’t run
I can console.log the line before successfuly, but then the d3.json on the following line fails to execute.

For example, it works on line 53 in this project
but doesnt work on line 62 of this project despite seeming identical

Why? Is that me, or an issue?

Ok, so more investigation reveals the identical code in two repos, with identical files, in one d3.json works, and in the second, the d3 statement blocks is completely ignored!!!

I have console log statements before and after, as well as within the d3.json, including the error, yet nothing fires from within, only before and after logs fine. In this second repo, the code block Iines 62-70 is ignored!! Why, How??

In this second repo, you can see how the file being referenced is actually there, yet the d3.json does not fire OS-Threat UI (vizhub.com)

In the first repo, exactly the same code is used and the same file names, and it works perfectly. But the difference is d3v4 is used this time. Brett’s Type Refinery D3v4 and Webcola Controls (vizhub.com)
What am i doing wrong? Can you advise please?


Brett’s Type Refinery D3v4 and Webcola Controls (vizhub.com)

Crazily @curran you have already fixed this issue on the d3 github here https://github.com/d3/d3/issues/3559#issuecomment-1061186269

Thanks

Ah yes! The newer version returns a Promise, whereas the older version uses callbacks. This can definitely be a tricky thing to debug. I’m glad you were able to get it working!

Hi @curran,

Actually it only works for the first pane (left-hand trree diagram), that only imports a single file.

But the working pane does not work, because there is nothing in the data object.

We tried using async/await but I couldn’t get it working.

If you look in the console, you can see the console.log statements at lines 150-155 working.js. This shows that the error on the following line is because the data has not arrived.

Can you please show how it should please? I cannot get the middle part of the window to work. How can i wait till the data is loaded, as the conventional answers??

I think I may have put a second question about issues with asynch await, which is really the same question as this. How to open 3 files at the same time, as shown in index.js, lines 141-146

how to get multiple files in and wait for the promise ?

how to get multiple files in and wait for the promise ?

Aha! That’s a great question. You can either load them in sequence or in parallel. If you load them in parallel, it’s typically faster. You can load them in parallel using Promise.all, documented here:

1 Like