D3 V4 TreeMap error "Uncaught Error: missing: Comedy-Musical D3 V4 TreeMap error "Uncaught Error: missing: Comedy-Musical json json

D3 V4 TreeMap error "Uncaught Error: missing: Comedy-Musical


For d3.v4.js

I was stuck with the same issue for a while.

The follwing thread narrowed down the issue for me:https://github.com/d3/d3-hierarchy/issues/33

Essentially as I understand it you must have the parent nodes specified in the dataset to implement d3.stratify().

In the block you referenced, the data while being in a flat structure has the parent nodes specified for each level. Your data does not.

You have to specify the parent & child nodes yourself. This can be done with d3.nest().

This block http://bl.ocks.org/mbostock/2838bf53e0e65f369f476afd653663a2led me to my solution and should apply to your situation.

In summary I used:

var nest = d3.nest() // allows elements in an array to be grouped into a hierarchical tree structure         .key() // levels in the tree are specified by key functions. can have multiple keys         .rollup() // Specifies a rollup function to be applied on each group of leaf elements. The return value of the rollup function will replace the array of leaf values in either the associative array returned by nest.map or nest.object; for nest.entries, it replaces the leaf entry.values with entry.value.

(comments source: https://github.com/d3/d3-collection)

var root = d3.hierarchy({data:nest.entries(csv_data)},function(d){return d.data;})     .sum(function(d) {return d.value; })treemap(root)

I hope this helps!!!!