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-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);varindexLine=linesWrap.selectAll(".nv-indexLine").data([index]);indexLine.enter().append("rect").attr("class","nv-indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).call(indexDrag);indexLine.attr("transform",function(d){return"translate("+dx(d.i)+",0)"}).attr("height",availableHeight);xAxis.scale(x).ticks(Math.min(data[0].values.length,availableWidth/70)).tickSize(-availableHeight,0);g.select(".nv-x.nv-axis").attr("transform","translate(0,"+y.range()[0]+")");d3.transition(g.select(".nv-x.nv-axis")).call(xAxis);yAxis.scale(y).ticks(availableHeight/36).tickSize(-availableWidth,0);d3.transition(g.select(".nv-y.nv-axis")).call(yAxis);functionupdateZero(){indexLine.data([index]);chart.update()}g.select(".nv-background rect").on("click",function(){index.x=d3.mouse(this)[0];index.i=Math.round(dx.invert(index.x));state.index=index.i;dispatch.stateChange(state);updateZero()});lines.dispatch.on("elementClick",function(e){index.i=e.pointIndex;index.x=dx(index.i);state.index=index.i;dispatch.stateChange(state);updateZero()});controls.dispatch.on("legendClick",function(d,i){d.disabled=!d.disabled;rescaleY=!d.disabled;state.rescaleY=rescaleY;dispatch.stateChange(state);chart.update()});legend.dispatch.on("legendClick",function(d,i){d.disabled=!d.disabled;if(!data.fi
});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.attr("viewBox");if(viewBox){viewBox=viewBox.split(" ");varratio=parseInt(svg.style("width"))/viewBox[2];e.pos[0]=e.pos[0]*ratio;e.pos[1]=e.pos[1]*ratio}}varleft=e.pos[0]+(offsetElement.offsetLeft||0),top=e.pos[1]+(offsetElement.offsetTop||0),x=xAxis.tickFormat()(lines.x()(e.point,e.pointIndex)),y=yAxis.tickFormat()(lines.y()(e.point,e.pointIndex)),content=tooltip(e.series.key,x,y,e,chart);nv.tooltip.show([left,top],content,null,null,offsetElement)};functionchart(selection){selection.each(function(data){varcontainer=d3.select(this),that=this;varavailableWidth=(width||parseInt(container.style("width"))||960)-margin.left-margin.right,availableHeight=(height||parseInt(container.style("height"))||400)-margin.top-margin.bottom;chart.update=function(){container.transition().call(chart)};chart.container=this;state.disabled=data.map(function(d){return!!d.disabled});if(!defaultState){varkey;defaultState={};for(keyinstate){if(state[key]instanceofArray)defaultState[key]=state[key].slice(0);elsedefaultState[key]=state[key]}}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",m
returnd})}state.disabled=data.map(function(d){return!!d.disabled});dispatch.stateChange(state);chart.update()});controls.dispatch.on("legendClick",function(d,i){if(!d.disabled)return;controlsData=controlsData.map(function(s){s.disabled=true;returns});d.disabled=false;switch(d.key){case"Grouped":multibar.stacked(false);break;case"Stacked":multibar.stacked(true);break}state.stacked=multibar.stacked();dispatch.stateChange(state);chart.update()});dispatch.on("tooltipShow",function(e){if(tooltips)showTooltip(e,that.parentNode)});dispatch.on("changeState",function(e){if(typeofe.disabled!=="undefined"){data.forEach(function(series,i){series.disabled=e.disabled[i]});state.disabled=e.disabled}if(typeofe.stacked!=="undefined"){multibar.stacked(e.stacked);state.stacked=e.stacked}selection.call(chart)})});returnchart}multibar.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+margin.left,e.pos[1]+margin.top];dispatch.tooltipShow(e)});multibar.dispatch.on("elementMouseout.tooltip",function(e){dispatch.tooltipHide(e)});dispatch.on("tooltipHide",function(){if(tooltips)nv.tooltip.cleanup()});chart.dispatch=dispatch;chart.multibar=multibar;chart.legend=legend;chart.xAxis=xAxis;chart.yAxis=yAxis;d3.rebind(chart,multibar,"x","y","xDomain","yDomain","forceX","forceY","clipEdge","id","delay","showValues","valueFormat","stacked","barColor");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.color=function(_){if(!arguments.length)returncolor;color=nv.utils.getColor(_);legend.color(color);returnchart};chart.showControls=function(_){if(!arguments.length)returnshowControls;showControls=_;returnchart};chart.showLegend=function(_){if(!arguments.length)returnshowLegend;showLegend=_;returnchart};chart.tooltip=function(_){if(!arguments.length)returntooltip;tooltip=_;returnchart};chart.tooltips=function(_){if(!arguments.length)returntooltips;tooltips=_;returnchart};chart.tooltipContent=function(_){if(!arguments.length)returntooltip;tooltip=_;returnchart};chart.state=function(_){if(!arguments.length)returnstate;state=_;returnchart};chart.defaultState=function(_){if(!arguments.length)returndefaultState;defaultState=_;returnchart};chart.noData=function(_){if(!arguments.length)returnnoData;noData=_;returnchart};returnchart};nv.models.multiChart=function(){varmargin={top:30,right:20,bottom:50,left:60},color=d3.scale.category20().range(),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;varx=d3.scale.linear(),yScale1=d3.scale.linear(),yScale2=d3.scale.linear(),lines1=nv.models.line().yScale(yScale1),lines2=nv.models.line().yScale(yScale2),bars1=nv.models.multiBar().stacked(false).yScale(yScale1),bars2=nv.models.multiBar().stacked(false).yScale(yScale2),stack1=nv.models.stackedArea().yScale(yScale1),stack2=nv.models.stackedArea().yScale(yScale2),xAxis=nv.models.axis().scale(x).orient("bottom").tickPadding(5),yAxis1=nv.models.axis().scale(yScale1).orient("left"),yAxis2=nv.models.axis().scale(yScale2).orient("right"),legend=nv.models.legend().height(30),dispatch=d3.dispatch("tooltipShow","tooltipHide");varshowTooltip=function(e,offsetElement){varleft=e.pos[0]+(offsetElement.offsetLeft||0),top=e.pos[1]+(offsetElement.offsetTop||0),x=xAxis.tickFormat()(lines1.x()(e.point,e.pointIndex)),y=(e.series.yAxis==2?yAxis2:yAxis1).tickFormat()(lines1.y()(e.point,e.pointIndex)),content=tooltip(e.series.key,x,y,e,chart);nv.tooltip.show([left,top],content,undefined,undefined,offsetElement.offsetParent)};functionchart(selection){selection.each(function(data){varcontainer=d3.select(this),that=this;chart.update=function