与http://bl.ocks.org/cgdnorth/7144137中的示例一样,我希望将创建的每个箱线图翻译成它对应的月份。我知道我可以在创建时移动每个箱线图.attr("transform...
:
svg.selectAll(".box")
.data(data)
.enter().append("svg")
.attr("class", "box")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.bottom + margin.top)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")") // Need to translate each boxplot by e from data[e] in the csv.foreach
.call(chart);
我想知道如何访问在数据循环中定义的data
键值,以便我可以乘以框的宽度,例如:e
csv.forEach(function(x) {
svg.selectAll(".box")
.data(data)
.enter().append("svg")
.attr("class", "box")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.bottom + margin.top)
.append("g")
.attr("transform", "translate(" + (width + margin.left + margin.right)*e + "," + margin.top + ")") // Need to translate each boxplot by e from data[e] in the csv.foreach
.call(chart);
这也是用于绘制每个箱线图的数组键。谢谢!