javascript - Generate layout histogram with specified parent values -


i new d3, project of d3 rough problem me , need help, have been search solutions days.

the problem is, want draw hierarchical bar chart, every time 1 clicks bar, sub layout of bar shown, 1 http://bl.ocks.org/mbostock/1283663, however, value of parent node sum value of children node. want set parent value myself , keep layout. json file is:

{     "name": "flare",     "children": [     {         "name": "analytics",         "children": [         {             "name": "cluster",             "children": [                 {"name": "agglomerativecluster", "size": 3938},                 {"name": "communitystructure", "size": 3812},                 {"name": "hierarchicalcluster", "size": 6714},                 {"name": "mergeedge", "size": 743}             ]         }, 

i want edit parent value, edit file :

{     "name": "flare",     "children": [     {         "name": "analytics",size:555555 //i want set value myself rather sum of children value         "children": [         {             "name": "cluster",             "children": [                 {"name": "agglomerativecluster", "size": 3938},                 {"name": "communitystructure", "size": 3812},                 {"name": "hierarchicalcluster", "size": 6714},                 {"name": "mergeedge", "size": 743}             ]     }, 

however, not work. knows how set parent's value? searched days , got nothing, hope can me, , appreciate help!

is issue using parent element sizes draw bars? if so, should scale (to 0 100) , multiply constant appropriate parent value. after all, if edit each parent value, won't proportional.

here's example of scale:

edit: (fixed domain)

var myscale = d3.scale.linear()                 .domain([0, maxparentwidth])                 .range([0,y]);   // .range([0,1]) default range 

this scale "parents" on domain 0 largest parent value range of [0,y], y whatever want (i.e., 100). let's want largest parent bar 300px. now, have multiply scaled value constant, in case, 3.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -