+d3.selection::layout = (direction) ->
- x = if el.attr "x" is null then 0 else el.attr "x"
- y = if el.attr "y" is null then 0 else el.attr "y"
- if direction == "vertical" or direction == "both"
+ if direction in ["vertical","both"]
el_height = d3.select(this).node().getBBox().height
- if direction == "horizontal" or direction == "both"
+ if direction in ["horizontal","both"]
el_width = d3.select(this).node().getBBox().width
- el.attr "transform", "translate("+x+" "+y+")"
-d3.selection.prototype.layout = layout
+ el.attr "transform", "translate(#{x} #{y})"