问题
Hi I'm doing something like this http://bl.ocks.org/mbostock/1283663
But in this exemple, parent's size are the sum of there children's size, I would like that the parent's size will be the average of there children's size. So i need to Implement a function to calculate the averages as I wish -- function average(d) in my example -- and replace all occurrences of
.attr("width", function(d) { return x(d.value); })
with
.attr("width", function(d) { return x(average(d)); }).
But i don't know how to implement it . Can you help me please ? Thanks in advance
来源:https://stackoverflow.com/questions/25499957/function-to-calculate-the-averages-of-childrens-size-d3-js