我正在使用 Rickshaw 框架,它使用 D3 进行可视化。我正在创建一个变量节点,我在其中附加了矩形。只要满足特定条件,我希望 Padding 为 20。
var nodes = graph.vis.selectAll("path").data(series.stack.filter(function(d) {
return d.y !== null
})).enter().append("svg:rect").attr("x", function(d) {
console.log(brandCount[v])
if(d.x == brandCount[v]) {
console.log("called2")
v++;
var z = 0;
padding = 10;
} else {
padding = 0;
}.attr("y", function(d) {
return (graph.y(d.y0 + Math.abs(d.y))) * (d.y < 0 ? -1 : 1 )
}).attr("width", 30).attr("height", function(d) {
return graph.y.magnitude(Math.abs(d.y))
}).attr("rx", 4).attr("transform", transform);
我应该怎么做才能访问变量并将属性添加到变量?
品牌数,数组有很多值([1, 4, 1, 4, 1, 6, 1, 5, 1, 1, 1, 1, 1, 6, 1, 1, 1, 6, 4, 1, 2, 2, 1, 1, 1, 5, 8, 4, 1, 6, 3, 1, 9, 1, 1, 4, 2, 1, 1, 5, 1, 1, 1, 7, 1, 1, 2, 3, 1, 2, 2, 1, 1, 2, 1, 3, 2, 1, 1, 1, 1, 5, 1, 1, 1, 1, 7, 1, 1, 2, 6, 1, 6, 1, 3, 2, 2, 1, 4, 2, 1])
。在每个值之后我需要一个空间。我只是试图循环它..作为brand_count [v]并将其增加v ++。