0
我有d3
(立体派)的代码在CoffeeScript的类中的下列位:d3.js选择和调用()难题
d3.select("view").selectAll(".horizon")
.data(@metrics)
.enter()
.insert("div", ".bottom")
.attr("class", "horizon")
.call(@ctx.horizon())
,一切的伟大工程。不过,我想下面的数据结构传递到类实例化“视图”:
metricGroup =
cpu:
extent: [0,100]
temperature:
extent: [0,80]
power:
scale: d3.scale.ordinal([0,1,2]).range([-2,1,-1])
extent: [-2,1]
,你可以看到,我想一定scale
和extent
s到每个指标相关联。每个度量(将)限定到每个horizon
对象需要在上述d3
代码被链接特定的呼叫,使得:
.call(
@ctx.horizon()
.scale(@metricGroup.power.scale)
.extent(@metricGroup.power.extent)
)
所以对于“力量”度量,这将是
.call(
@ctx.horizon()
.scale(d3.scale.ordinal([0,1,2]).range([-2,1,-1]))
.extent([-2,1])
)
我怎么能保持选择/输入/调用方法链的优雅,但提供我想要的定制?
您是否尝试过使用缩放等部分数据传入? – 2013-05-11 20:05:27