index.i=Math.round(dx.invert(index.x));updateZero()}functiondragEnd(d,i){d3.select(chart.container).style("cursor","auto");state.index=index.i;dispatch.stateChange(state)}if(!data||!data.length||!data.filter(function(d){returnd.values.length}).length){varnoDataText=container.selectAll(".nv-noData").data([noData]);noDataText.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle");noDataText.attr("x",margin.left+availableWidth/2).attr("y",margin.top+availableHeight/2).text(function(d){returnd});returnchart}else{container.selectAll(".nv-noData").remove()}x=lines.xScale();y=lines.yScale();if(!rescaleY){varseriesDomains=data.filter(function(series){return!series.disabled}).map(function(series,i){varinitialDomain=d3.extent(series.values,lines.y());if(initialDomain[0]<-.95)initialDomain[0]=-.95;return[(initialDomain[0]-initialDomain[1])/(1+initialDomain[1]),(initialDomain[1]-initialDomain[0])/(1+initialDomain[0])]});varcompleteDomain=[d3.min(seriesDomains,function(d){returnd[0]}),d3.max(seriesDomains,function(d){returnd[1]})];lines.yDomain(completeDomain)}else{lines.yDomain(null)}dx.domain([0,data[0].values.length-1]).range([0,availableWidth]).clamp(true);vardata=indexify(index.i,data);varwrap=container.selectAll("g.nv-wrap.nv-cumulativeLine").data([data]);vargEnter=wrap.enter().append("g").attr("class","nvd3 nv-wrap nv-cumulativeLine").append("g");varg=wrap.select("g");gEnter.append("g").attr("class","nv-x nv-axis");gEnter.append("g").attr("class","nv-y nv-axis");gEnter.append("g").attr("class","nv-background");gEnter.append("g").attr("class","nv-linesWrap");gEnter.append("g").attr("class","nv-avgLinesWrap");gEnter.append("g").attr("class","nv-legendWrap");gEnter.append("g").attr("class","nv-controlsWrap");if(showLegend){legend.width(availableWidth);g.select(".nv-legendWrap").datum(data).call(legend);if(margin.top!=legend.height()){margin.top=legend.height();availableHeight=(height||parseInt(container.style("height"))||400)-margin.top-margin.bottom}g.select(".nv-legendWrap").attr("transform","translate(0,"+-margin.top+")")}if(showControls){varcontrolsData=[{key:"Re-scale y-axis",disabled:!rescaleY}];controls.width(140).color(["#444","#444","#444"]);g.select(".nv-controlsWrap").datum(controlsData).attr("transform","translate(0,"+-margin.top+")").call(controls)}wrap.attr("transform","translate("+margin.left+","+margin.top+")");vartempDisabled=data.filter(function(d){returnd.tempDisabled});wrap.select(".tempDisabled").remove();if(tempDisabled.length){wrap.append("text").attr("class","tempDisabled").attr("x",availableWidth/2).attr("y","-.71em").style("text-anchor","end").text(tempDisabled.map(function(d){returnd.key}).join(", ")+" values cannot be calculated for this time period.")}gEnter.select(".nv-background").append("rect");g.select(".nv-background rect").attr("width",availableWidth).attr("height",availableHeight);lines.y(function(d){returnd.display.y}).width(availableWidth).height(availableHeight).color(data.map(function(d,i){returnd.color||color(d,i)}).filter(function(d,i){return!data[i].disabled&&!data[i].tempDisabled}));varlinesWrap=g.select(".nv-linesWrap").datum(data.filter(function(d){return!d.disabled&&!d.tempDisabled}));linesWrap.call(lines);data.forEach(function(d,i){d.seriesIndex=i});varavgLineData=data.filter(function(d){return!d.disabled&&!!average(d)});varavgLines=g.select(".nv-avgLinesWrap").selectAll("line").data(avgLineData,function(d){returnd.key});avgLines.enter().append("line").style("stroke-width",2).style("stroke-dasharray","10,10").style("stroke",function(d,i){returnlines.color()(d,d.seriesIndex)}).attr("x1",0).attr("x2",availableWidth).attr("y1",function(d){returny(average(d))}).attr("y2",function(d){returny(average(d))});avgLines.attr("x1",0).attr("x2",availableWidth).attr("y1",function(d){returny(average(d))}).attr("y2",function(d){returny(average(d))});avgLines.exit().remove();varindexLine=linesWrap.selectAll(".nv-indexLine").data([index]);indexLine.enter().append("rect").attr("class","nv-indexLine").attr("width",3).attr("x
groups.attr("class",function(d,i){return"nv-group nv-series-"+i}).classed("hover",function(d){returnd.hover}).style("fill",function(d,i){returncolor(d,i)}).style("stroke",function(d,i){returncolor(d,i)});d3.transition(groups).style("stroke-opacity",1).style("fill-opacity",.5);varareaPaths=groups.selectAll("path.nv-area").data(function(d){returnisArea(d)?[d]:[]});areaPaths.enter().append("path").attr("class","nv-area").attr("d",function(d){returnd3.svg.area().interpolate(interpolate).defined(defined).x(function(d,i){returnx0(getX(d,i))}).y0(function(d,i){returny0(getY(d,i))}).y1(function(d,i){returny0(y.domain()[0]<=0?y.domain()[1]>=0?0:y.domain()[1]:y.domain()[0])}).apply(this,[d.values])});d3.transition(groups.exit().selectAll("path.nv-area")).attr("d",function(d){returnd3.svg.area().interpolate(interpolate).defined(defined).x(function(d,i){returnx(getX(d,i))}).y0(function(d,i){returny(getY(d,i))}).y1(function(d,i){returny(y.domain()[0]<=0?y.domain()[1]>=0?0:y.domain()[1]:y.domain()[0])}).apply(this,[d.values])});d3.transition(areaPaths).attr("d",function(d){returnd3.svg.area().interpolate(interpolate).defined(defined).x(function(d,i){returnx(getX(d,i))}).y0(function(d,i){returny(getY(d,i))}).y1(function(d,i){returny(y.domain()[0]<=0?y.domain()[1]>=0?0:y.domain()[1]:y.domain()[0])}).apply(this,[d.values])});varlinePaths=groups.selectAll("path.nv-line").data(function(d){return[d.values]});linePaths.enter().append("path").attr("class","nv-line").attr("d",d3.svg.line().interpolate(interpolate).defined(defined).x(function(d,i){returnx0(getX(d,i))}).y(function(d,i){returny0(getY(d,i))}));d3.transition(groups.exit().selectAll("path.nv-line")).attr("d",d3.svg.line().interpolate(interpolate).defined(defined).x(function(d,i){returnx(getX(d,i))}).y(function(d,i){returny(getY(d,i))}));d3.transition(linePaths).attr("d",d3.svg.line().interpolate(interpolate).defined(defined).x(function(d,i){returnx(getX(d,i))}).y(function(d,i){returny(getY(d,i))}));x0=x.copy();y0=y.copy()});returnchart}chart.dispatch=scatter.dispatch;chart.scatter=scatter;d3.rebind(chart,scatter,"id","interactive","size","xScale","yScale","zScale","xDomain","yDomain","sizeDomain","forceX","forceY","forceSize","clipVoronoi","clipRadius","padData");chart.margin=function(_){if(!arguments.length)returnmargin;margin.top=typeof_.top!="undefined"?_.top:margin.top;margin.right=typeof_.right!="undefined"?_.right:margin.right;margin.bottom=typeof_.bottom!="undefined"?_.bottom:margin.bottom;margin.left=typeof_.left!="undefined"?_.left:margin.left;returnchart};chart.width=function(_){if(!arguments.length)returnwidth;width=_;returnchart};chart.height=function(_){if(!arguments.length)returnheight;height=_;returnchart};chart.x=function(_){if(!arguments.length)returngetX;getX=_;scatter.x(_);returnchart};chart.y=function(_){if(!arguments.length)returngetY;getY=_;scatter.y(_);returnchart};chart.clipEdge=function(_){if(!arguments.length)returnclipEdge;clipEdge=_;returnchart};chart.color=function(_){if(!arguments.length)returncolor;color=nv.utils.getColor(_);scatter.color(color);returnchart};chart.interpolate=function(_){if(!arguments.length)returninterpolate;interpolate=_;returnchart};chart.defined=function(_){if(!arguments.length)returndefined;defined=_;returnchart};chart.isArea=function(_){if(!arguments.length)returnisArea;isArea=d3.functor(_);returnchart};returnchart};nv.models.lineChart=function(){varlines=nv.models.line(),xAxis=nv.models.axis(),yAxis=nv.models.axis(),legend=nv.models.legend();varmargin={top:30,right:20,bottom:50,left:60},color=nv.utils.defaultColor(),width=null,height=null,showLegend=true,tooltips=true,tooltip=function(key,x,y,e,graph){return"<h3>"+key+"</h3>"+"<p>"+y+" at "+x+"</p>"},x,y,state={},defaultState=null,noData="No Data Available.",dispatch=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState");xAxis.orient("bottom").tickPadding(7);yAxis.orient("left");varshowTooltip=function(e,offsetElement){if(offsetElement){varsvg=d3.select(offsetElement).select("svg");varviewBox=svg.node()?svg.at