d3.js - D3 treemap json data format -


i'm new d3js. i've gone through several examples of treemap visualization , noticed data has same hierarchical structure:

{  "name": "flare",   "children": [       ...    ]       ... } 

but if have array of objects same set of properties without nesting:

[   {     "courseid": "15.010b",    "subject": "15.01",    "section": "b",    "department": "managerial economics",    "professor": "doyle",       ...   },   {     "courseid": "15.010b",    "subject": "15.01",    "section": "b",       ...   },       ... ] 

should make hierarchical myself? can provide me visual treemap example type of data format. in advance.

d3's built-in nest feature can create type of hierarchical data you, example:

var nest = d3.nest()     .key(function(d) { return d.department; })     .key(function(d) { return d.subject; })     .key(function(d) { return d.section; })     .entries(_dataset_name_); 

will create suitably hierarchical dataset.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -