0

My question is about the d3.json()-call from d3.js. The context is a hierarchical edge bundling diagram (you can view the source-code on blocks.org but I can't link to it because I'm not allowed to post more than 2 links because of my reputation). I'm currently using for my project. As I wanted to modify it a little bit and write a documentation about it, I wanted to fully understand it. That's the point I'm struggling with:

in my source code, the line

d3.json('http://localhost:1337/xyz', function(error, data){ \\process data });

sends a get request to my rest-service. The REST response is this JSON-string. So basically what I would expect if I insert console.log(data); as the first line in the callback function, would be those two objects seen in the JSON-string. When I go into the developer tool and look what's actually logged in the console it shows both objects, but I don't have a clue where the attributes "depth, key, parent, x, and y" are coming from. Is the d3.json-function computing something by itself? Or is the data somehow computed before the console.log-line although it's the first line in the callback-function? Where do those attributes come from? Are methods from somewhere else in the source-code executed on the JSON-array before the console.log-line is executed? I'm totally confused.

Dixit
  • 1,359
  • 3
  • 18
  • 39
Michzor
  • 11
  • 3
  • Can stringify the data to see it as snapshot : `console.log(JSON.stringify(data, null, 4));` – charlietfl Jun 25 '17 at 23:01
  • This question doesn't seem to be a duplicate to me (I mean, it's not about console.log). OP wants to know where those properties are come from. @Michzor, you are using a hierarchy method somewhere. Is this method that creates those properties. – Gerardo Furtado Jun 26 '17 at 00:42
  • yes I'm using the hierachy method. But I'm using it directly AFTER logging the JSON-array into the console. But it seems as if at least the hierachy method (and maybe even additional methods) are called upon the array before and the console.log() is executed afterwards. Maybe it's really a problem with lazy evaluating arrays (?) I'll read through the linked thread and let you know if I find a solution about it. – Michzor Jun 26 '17 at 07:04

0 Answers0