i have the following bit of d3
(cubism) code in a coffeescript class:
d3.select("view").selectAll(".horizon")
.data( @metrics )
.enter()
.insert("div", ".bottom")
.attr("class", "horizon")
.call( @ctx.horizon() )
and everything works great. however, i would like to pass the following data structure into my class to instantiate the 'view':
metricGroup =
cpu:
extent: [0,100]
temperature:
extent: [0,80]
power:
scale: d3.scale.ordinal( [0,1,2] ).range( [-2,1,-1] )
extent: [-2,1]
as you can see, i wish to associate certain scale
and extent
s to each metric. each metric (would) define specific calls to each horizon
object that needs to be chained in the above d3
code such that:
.call(
@ctx.horizon()
.scale(@metricGroup.power.scale)
.extent(@metricGroup.power.extent)
)
so for the 'power' metric, it would be
.call(
@ctx.horizon()
.scale(d3.scale.ordinal( [0,1,2] ).range( [-2,1,-1] ))
.extent( [-2,1] )
)
how could i keep the elegance of the select/enter/call method chain, yet provide the customisation i want?