1
我想立刻使用D3创建多个图表 - 代码是在这里:http://jsfiddle.net/jgilfillan/W85ut/如何通过数据连接将多个x轴添加到d3图表中?
我有这些对象的数组bulletDataX
:
function BulletObject(name, actual, target, ranges, bulletWidth) {
this.name = name;
this.actual = actual;
this.target = target;
this.ranges = ranges;
this.maxX = ranges[2];
this.bulletWidth = bulletWidth;
this.scale = d3.scale.linear().domain([0, this.maxX]).range([0, this.bulletWidth]);
this.xAxis = d3.svg.axis().scale(this.scale).orient("bottom");
}
这是我想获得工作的代码。 ..
//axes??? not working
svg.selectAll(".xaxis")
.data(bulletDataX)
.enter()
.append("g")
.attr("id", function(d) { return d.name; })
.attr("class", "x axis")
.attr("transform", function(d, i) { return "translate(0, " + ((bulletHeight + bulletPadding) * i + .25 * bulletHeight).toString() + ")"; })
.call(function(d, i) { return d.xAxis; });
我知道我不得不摆弄转换属性有点,但我甚至无法得到轴显示。我认为这个问题与.call(function(d, i) { return d.xAxis; })
有关,但我无法弄清楚如何让它起作用。任何想法将不胜感激。
天才。这很好。非常感谢。 – Josh