Accepted answer

The d3.json API call does not return a value as you expect. I cannot find documentation to specify what is the return of the d3.json method is. From your example, it seems always return a undefined value.

You could do it like this:

var jsondata;
d3.json(dataPath, function(dataFromServer) {
  jsondata = dataFromServer;

Related Query

More Query from same tag