fix clearing of target

This commit is contained in:
Radek Stepan 2013-08-21 17:59:42 +01:00
parent 6828a158f8
commit 3a8c0a3c09
2 changed files with 4 additions and 3 deletions

View File

@ -76,10 +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 = '' document.querySelector('#svg').innerHTML = ''
# Get available space. # Get available space.
{ height, width } = target.getBoundingClientRect() { height, width } = document.querySelector('#graph').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
@ -115,7 +115,7 @@ module.exports =
y.domain([ 0, ideal[0].points ]).nice() y.domain([ 0, ideal[0].points ]).nice()
# Add an SVG element with the desired dimensions and margin. # Add an SVG element with the desired dimensions and margin.
svg = d3.select("#graph").append("svg") svg = d3.select("#svg").append("svg")
.attr("width", width + margin.left + margin.right) .attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom) .attr("height", height + margin.top + margin.bottom)
.append("g") .append("g")

View File

@ -2,6 +2,7 @@
<h1><%- @name %></h2> <h1><%- @name %></h2>
<div id="graph"> <div id="graph">
<div id="tooltip"></div> <div id="tooltip"></div>
<div id="svg"></div>
</div> </div>
<div id="progress"></div> <div id="progress"></div>
</div> </div>