function to calculate the averages of children's size D3 js

送分小仙女□ 提交于 2020-01-06 15:01:50

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!