Skip to content

Instantly share code, notes, and snippets.

@oshikryu
Created January 30, 2014 19:19
Show Gist options
  • Save oshikryu/8716669 to your computer and use it in GitHub Desktop.
Save oshikryu/8716669 to your computer and use it in GitHub Desktop.
resize legend based on width and bbox pos
_spaceLines: ->
keys = d3.selectAll('.key')[0]
extraRows = 0
_lineSpacer = (d, i) =>
keyPos = keys[i].getBBox().x
keyEdge = keyPos + keys[i].getBBox().width
edge = @w - @m*2
console.log keyEdge
console.log edge
if keyEdge > edge
extraRows += 1
val = "#{(extraRows - 1) * @gridOffset*6}, #{@gridOffset * 6 }"
else
val = "#{i*@gridOffset*6}, 0"
return val
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment