我有一个 d3.nest 函数,它为我提供以下格式的数据。
[ { "key": "Level1", “价值观”:[ { “x”:118, “y”:106, “尺寸”:1.113207547 }, { “x”:111, “y”:137, “尺寸”:0.810218978 }, { “x”:144, “y”:195, “大小”:0.738461538 }, { “x”:116, “y”:129, “大小”:0.899224806 }, { “x”:117, “y”:119, “大小”:0.983193277 }, { “x”:145, “y”:122, “大小”:1.18852459 } ], “坡度”:0.52289599949494, “拦截”:0.2795214697252959 }, { "key": "Level2", “价值观”:[ { “x”:172, “y”:193, “尺寸”:0.89119171 }, { “x”:138, “y”:114, “大小”:1.210526316 }, { “x”:106, “y”:189, “大小”:0.560846561 }, { “x”:123, “y”:141, “大小”:0.872340426 }, { “x”:129, “y”:110, “大小”:1.172727273 }, { “x”:162, “y”:198, “尺寸”:0.818181818 } ], “坡度”:0.52289599949494, “拦截”:0.2795214697252959 }, { "key": "Level3", “价值观”:[ { “x”:191, “y”:104, “大小”:1.836538462 }, { “x”:177, “y”:186, “尺寸”:0.951612903 }, { “x”:106, “y”:140, “大小”:0.757142857 }, { “x”:131, “y”:161, “大小”:0.813664596 }, { “x”:111, “y”:128, “大小”:0.8671875 }, { “x”:149, “y”:122, “大小”:1.221311475 }, { “x”:200, “y”:126, “尺寸”:1.587301587 } ], “坡度”:0.52289599949494, “拦截”:0.2795214697252959 } ]
我只想从值中排除“类型”。有人帮助我如何做到这一点。
我用来获取该数据的函数如下。
d3.csv(“数据.csv”,函数(数据){ data.forEach(函数(d){ dx = +dx dy = +dy d.size = +d.size }) var 巢 = d3.nest() .key(function(d) {return d.type;}) .rollup(function(v) {return v.map(function(d) {return d})}) .条目(数据); d3.select('body').append('pre') .text(JSON.stringify(nest, null, ' ')); })