How do I redraw a path using D3.js methodology?
===

I can't seem to get the .enter() and .exit for a path to work correctly. For the code below, everytime I try to redraw the path, it keeps the old path. 

I would venture to guess that what's wrong is the .attr("d",stepline(csProg)).  I was thinking it should be something more like .attr("d",function(d) { stepline(d); }) or something like that, but I couldn't get it to work.  Any suggestions?

    function drawCloseChart(mysvg,mydata,cx1,cx2,cy1,cy2,oq)
    {
	
	var x = d3.scale.linear().domain([360*60, 390*60]).range([cx1, cx2]), 
	    y = d3.scale.linear().domain([0,oq]).range([cy1,cy2]),
	    z = d3.scale.category10();
	
	
	var targetg = mysvg.append("svg:g");
	
        //code to draw x-axis
        //code to draw y-axis
	
	var stepline = d3.svg.line()
		.x(function(d) { return x(d.time); })
		.y(function(d) { return y(d.val); })
		.interpolate("step-after");
	
	var chartData = [];
	chartData.redraw = function()
	{


		var cpg = cprog.selectAll("path").data(csProg);
		cpg.enter()
			.append("path")
			.attr("d",stepline(csProg))
			.attr("fill","none")
			.attr("stroke-width","2")
			.attr("stroke","black");
			
		cpg.exit().remove();		
			
	}
	chartData.redraw();
	return chartData;
    }