re-render on window resize

This commit is contained in:
Radek Stepan 2013-08-21 17:33:10 +01:00
parent b36ca9d87b
commit 6828a158f8
2 changed files with 7 additions and 2 deletions

View File

@ -76,8 +76,10 @@ module.exports =
# Render the D3 chart. # Render the D3 chart.
'render': ([ actual, ideal ], cb) -> 'render': ([ actual, ideal ], cb) ->
(target = document.querySelector('#graph')).innerHTML = ''
# Get available space. # Get available space.
{ height, width } = document.querySelector('#graph').getBoundingClientRect() { height, width } = target.getBoundingClientRect()
margin = { top: 30, right: 30, bottom: 40, left: 50 } margin = { top: 30, right: 30, bottom: 40, left: 50 }
width -= margin.left + margin.right width -= margin.left + margin.right

View File

@ -80,6 +80,9 @@ class exports.Repo
render '#progress', 'progress', { progress } render '#progress', 'progress', { progress }
# Render the chart. # Render the chart.
graph.render values, cb do doit = -> graph.render values, cb
# Watch window resize?
window.onresize = doit if 'onresize' of window
], cb ], cb